[UPDATE] helper script for changing the MAC

Filed under coding, general, linux, perl

UPDATE:
##############

I now rewrote the script a little bit to use a private MAC-area because of problems when generating some MAC-addresses. Please use this version if you want to use it …

##############

hi guys,

yesterday I told you how to change your MAC address. Because I’m unbelievably lazy I decided to write a little helper-script to do this automatically. This script generates a random MAC address and brings the interface up with it.

here it is: change-mac

#!/usr/bin/perl
use strict;
 
# name:     change-mac
# author:   ap0calypse (ap0calypse@agitatio.org)
# purpose:  helper script for bringing an interface down
#           and up again with a random MAC-address
# date:     2009-04-15
 
# replace this with your wlan-interface
my $interface = "wlan0";
 
my @val_mac = (0 .. 9, "A" .. "F");
my $rand_mac = "AC:DE:48:";
 
for (1 .. 6) {
    $rand_mac .= $val_mac[rand(@val_mac)];
    if ( ($_ % 2 == 0) && $_ != 6) {
        $rand_mac .= ":";
    }
}
 
system("ifconfig $interface down");
system("ifconfig $interface hw ether $rand_mac");
system("ifconfig $interface up");

3 Comments

  1. chaos says:

    wow, nice work, but something is missing for me! i need to reconnect to the AP automatically and to renew the IP ;) and last but not least, resign to the web-authentication (curl)

    then, but it into to a cron (29 minutes) and you get free internet access ;)

    o-o-o i got a sudden inspiration -> an ipcop firewall with an external radio relay antenna should have this :D

    cheers, chaos :)

  2. ap0calypse says:

    of course you need to, I didn’t say that it’s finished with this. this is just a helper-script for changing the MAC. Nothing more, nothing less ;)

  3. hardly says:

    My other post was previous to this. I guess I scrolled too fast.
    srsly though. check out macchanger. Neato blog.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*