{"id":735,"date":"2018-04-29T21:43:25","date_gmt":"2018-04-29T13:43:25","guid":{"rendered":"https:\/\/networkingnotesblog.wordpress.com\/?p=735"},"modified":"2018-04-29T21:43:25","modified_gmt":"2018-04-29T13:43:25","slug":"flooding-simulation-with-linux","status":"publish","type":"post","link":"http:\/\/notes4it.com\/?p=735","title":{"rendered":"Hping3 &#8211; Flooding simulation with Linux\u00a0"},"content":{"rendered":"<p>When testing firewalls ability against the DoS and session limit, there is a program in Linux called hping3 to produce flooding with. It can generate a small amount of packet flood while still keeping at lease 50% of CPU free for management.<br \/>\nif we need to test a session limit or threshold limit for SYNC flood toward to a web server port 80, we could use the command below.<br \/>\n<a href=\"https:\/\/networkingnotesblog.files.wordpress.com\/2018\/04\/hping3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1565\" src=\"https:\/\/networkingnotesblog.files.wordpress.com\/2018\/04\/hping3.png\" alt=\"\" width=\"700\" height=\"130\" srcset=\"http:\/\/notes4it.com\/wp-content\/uploads\/2018\/04\/hping3.png 1072w, http:\/\/notes4it.com\/wp-content\/uploads\/2018\/04\/hping3-300x56.png 300w, http:\/\/notes4it.com\/wp-content\/uploads\/2018\/04\/hping3-1024x190.png 1024w, http:\/\/notes4it.com\/wp-content\/uploads\/2018\/04\/hping3-768x143.png 768w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><br \/>\n<!--more--><br \/>\n# hping3 -i u1 -S -p 80 172.16.1.5<br \/>\n-S &#8211; indicates SYN flag<br \/>\n-p 80 &#8211; Target port 80<br \/>\n-i u1 &#8211; Wait for 1 micro second between each packet<br \/>\nBased of the result below, we can see hping3 is generate a TCP type of packet and sending traffic to port 80 of 172.16.1.5 as destination. You can pay a little attention on the time frame as well.<\/p>\n<table>\n<tbody>\n<tr>\n<td>21:28:02.108024 IP (tos 0x0, ttl 64, id 30525, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n172.16.2.18.15513 &gt; 172.16.1.5.80: Flags [S], cksum 0x9967 (correct), seq 652361374, win 512, length 0<br \/>\n21:28:02.108067 IP (tos 0x0, ttl 64, id 15118, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n172.16.2.18.15514 &gt; 172.16.1.5.80: Flags [S], cksum 0x7024 (correct), seq 1361228312, win 512, length 0<br \/>\n21:28:02.108123 IP (tos 0x0, ttl 64, id 61360, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n172.16.2.18.15515 &gt; 172.16.1.5.80: Flags [S], cksum 0x471a (correct), seq 651571276, win 512, length 0<br \/>\n21:28:02.108180 IP (tos 0x0, ttl 64, id 10258, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n172.16.2.18.15516 &gt; 172.16.1.5.80: Flags [S], cksum 0x6af3 (correct), seq 954783411, win 512, length 0<br \/>\n21:28:02.108235 IP (tos 0x0, ttl 64, id 20246, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n172.16.2.18.15517 &gt; 172.16.1.5.80: Flags [S], cksum 0xae73 (correct), seq 254599339, win 512, length 0<br \/>\n21:28:02.108298 IP (tos 0x0, ttl 64, id 48823, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n172.16.2.18.15518 &gt; 172.16.1.5.80: Flags [S], cksum 0xbdc9 (correct), seq 1616407911, win 512, length 0<br \/>\n21:28:02.108375 IP (tos 0x0, ttl 64, id 11273, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n^C 172.16.2.18.15519 &gt; 172.16.1.5.80: Flags [S], cksum 0x1cf2 (correct), seq 1226450215, win 512, length 0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>But in the case if we want to spoof the source address with another address, then we can use the paramater of &#8220;-a&#8221;. With the command below, it will send packets to 172.16.1.5 on behalf of 172.16.9.9<br \/>\n# hping3 -i u1 -S -p 80 172.16.1.5 -a 172.16.9.9<br \/>\n-a\u00a0 &#8211; to amend the source address of the packets<\/p>\n<table>\n<tbody>\n<tr>\n<td>21:33:07.911051 IP (tos 0x0, ttl 64, id 3061, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n<span style=\"color:#ff0000;\">172.16.9.9<\/span>.2349 &gt; 172.16.1.5.80: Flags [S], cksum 0xde0b (correct), seq 1951941470, win 512, length 0<br \/>\n21:33:07.911124 IP (tos 0x0, ttl 64, id 21261, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n<span style=\"color:#ff0000;\">172.16.9.9<\/span>.2350 &gt; 172.16.1.5.80: Flags [S], cksum 0xc771 (correct), seq 1069435591, win 512, length 0<br \/>\n21:33:07.911200 IP (tos 0x0, ttl 64, id 55266, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n<span style=\"color:#ff0000;\">172.16.9.9<\/span>.2351 &gt; 172.16.1.5.80: Flags [S], cksum 0x6e94 (correct), seq 1019611718, win 512, length 0<br \/>\n21:33:07.911268 IP (tos 0x0, ttl 64, id 32557, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n<span style=\"color:#ff0000;\">172.16.9.9<\/span>.2352 &gt; 172.16.1.5.80: Flags [S], cksum 0x8b5d (correct), seq 1332710561, win 512, length 0<br \/>\n21:33:07.911379 IP (tos 0x0, ttl 64, id 47624, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n172.16.9.9.2354 &gt; 172.16.1.5.80: Flags [S], cksum 0x624f (correct), seq 1886164219, win 512, length 0<br \/>\n21:33:07.911636 IP (tos 0x0, ttl 64, id 59607, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n172.16.9.9.2358 &gt; 172.16.1.5.80: Flags [S], cksum 0x17a6 (correct), seq 882958296, win 512, length 0<br \/>\n21:33:07.911851 IP (tos 0x0, ttl 64, id 38747, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n172.16.9.9.2362 &gt; 172.16.1.5.80: Flags [S], cksum 0xbb26 (correct), seq 604202905, win 512, length 0<br \/>\n21:33:07.912016 IP (tos 0x0, ttl 64, id 6476, offset 0, flags [none], proto TCP (6), length 40)<br \/>\n172.16.9.9.2365 &gt; 172.16.1.5.80: Flags [S], cksum 0xd48a (correct), seq 1798537797, win 512, length 0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Hping3 has more advance feature of packet crafting. I hope the info above can give you a general idea of how we can use hping3 for testing your environment or your firewall settings. I will share some more advance or other features in the coming future.<br \/>\n!!!! Please do no perform hping testing without permission.!!!<br \/>\n!!!! Also, do no perform address spoofing behind any NAT devices, as the packet arrives to the destination will be using the source address of your public ip address.!!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When testing firewalls ability against the DoS and session limit, there is a program in Linux called hping3 to produce flooding with. It can generate a small amount of packet flood while still keeping at lease 50% of CPU free for management. if we need to test a session limit or threshold limit for SYNC [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1565,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[37,39,49,63,104,121,123,167,177],"class_list":["post-735","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-networking","tag-deny-of-service-en","tag-dos-en","tag-flooding-en","tag-hping3-en","tag-linux-en","tag-packet-crafting-en","tag-packet-generate-en","tag-spoofing-en","tag-sync-flood-en"],"_links":{"self":[{"href":"http:\/\/notes4it.com\/index.php?rest_route=\/wp\/v2\/posts\/735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/notes4it.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/notes4it.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/notes4it.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/notes4it.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=735"}],"version-history":[{"count":0,"href":"http:\/\/notes4it.com\/index.php?rest_route=\/wp\/v2\/posts\/735\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/notes4it.com\/index.php?rest_route=\/wp\/v2\/media\/1565"}],"wp:attachment":[{"href":"http:\/\/notes4it.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/notes4it.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=735"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/notes4it.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}