#!/usr/bin/perl -w # macninja.pl - by dual # # Spoofs Orinoco MAC with choice of address # # Usage: # perl macninja.pl -[abcdr] ########################################### # Get and check args #################### help() unless defined($oui = shift); help() unless defined($eth = shift); if ($oui =~ /-a/) { agere(); } elsif ($oui =~ /-b/) { belkin(); } elsif ($oui =~ /-c/) { cisco(); } elsif ($oui =~ /-d/) { define(); } elsif ($oui =~ /-r/) { random(); } else { print "Try again with -a, -b, -c, -d or -r...\n"; exit; } # Provide assistance #################### sub help { print < -a : Agere (00:02:2D) -b : Belkin (00:30:BD) -c : Cisco (00:40:96) -d : Define your MAC -r : Random MAC address ethX : Interface to manipulate, e.g. eth1 EOF exit; } # Agere (Lucent, Orinoco) OUI ############################# sub agere { $cnt = 3; $mac[0] = "00"; $mac[1] = "02"; $mac[2] = "2D"; while ($cnt < 6) { $rand = rand(255); if ($rand < 16) { $rand += 16; $hex = sprintf("%X", $rand); } else { $hex = sprintf("%X", $rand); } $mac[$cnt] = $hex; $cnt++; } spoof(@mac); } # Belkin OUI ############ sub belkin { $cnt = 3; $mac[0] = "00"; $mac[1] = "30"; $mac[2] = "BD"; while ($cnt < 6) { $rand = rand(255); if ($rand < 16) { $rand += 16; $hex = sprintf("%X", $rand); } else { $hex = sprintf("%X", $rand); } $mac[$cnt] = $hex; $cnt++; } spoof(@mac); } # Cisco OUI ########### sub cisco { $cnt = 3; $mac[0] = "00"; $mac[1] = "40"; $mac[2] = "96"; while ($cnt < 6) { $rand = rand(255); if ($rand < 16) { $rand += 16; $hex = sprintf("%X", $rand); } else { $hex = sprintf("%X", $rand); } $mac[$cnt] = $hex; $cnt++; } spoof(@mac); } # User defined MAC ################## sub define { print "Please enter MAC address\n"; print "(e.g. 00:DE:AD:BE:EF:00): "; chomp($mac = <>); print "Try again with the format XX:XX:XX:XX:XX:XX...\n" and exit unless ($mac =~ /.{2}:.{2}:.{2}:.{2}:.{2}:.{2}/); @mac = split(/:/, $mac); spoof(@mac); } # Random MAC ############ sub random { $cnt = 0; while ($cnt < 6) { $rand = rand(255); if ($rand < 16) { $rand += 16; $hex = sprintf("%X", $rand); } else { $hex = sprintf("%X", $rand); } $mac[$cnt] = $hex; $cnt++; } spoof(@mac); } # Here's where the MAC is spoofed ################################# sub spoof { system("/sbin/ifconfig $eth down"); sleep 1; system("/sbin/ifconfig $eth hw ether $mac[0]:$mac[1]:$mac[2]:$mac[3]:$mac[4]:$mac[5] up"); print "MAC spoofed successfully.\n"; exit; }