MAC Address Changer

by Plasticman

As a college student, a hacker, and an all around semi-paranoid person, I recently became obsessed with protecting my personal privacy and security.

At my university, whenever a user connects a new computer to the network, they must log in with their Unique ID.  After this login procedure, the MAC address of the user's network device is registered with the network under their name.  Now, as a sysop, I fully understand the necessity and benefits of this sort of registration procedure.  However, as I also enjoy my privacy, I would prefer that nobody has the ability to see what I am doing on any network.

The key to being able to get around this type of logging is noticing how the network devices are associated with users: the MAC address.

Changing your MAC address is a simple task on any system, but the problem is that you have to re-register yourself whenever you change it, putting you back at square one.  So, in order to maintain our privacy, we must build a list of MAC addresses that are already registered on the network under different users.

The tool I used for this was Nmap, which is a free open-source port scanner available for both UNIX and Windows systems.  I won't go into the details on how to use Nmap.  Instead, you can look at www.nmap-tutorial.com, which is a great resource about proper use of this tool.

After I built my list of MAC addresses, I wrote a Bash script which will shut down my network device, pick a new MAC address at random out of that list, assign it to my network device, and start it back up.

The script also has the ability manually to assign a MAC address, and to restore my original MAC address as well.  The purpose of this script was for me to conceal my own network uses; as with all things, though, there are both good and evil uses.

I do not condone the use of this script in illegal activities, as it could potentially get an innocent person in a lot of trouble.

The file macs.dat should contain a list of random MAC addresses.

change-mac.sh:

#!/bin/bash
# This script allows you to change your MAC address.
# Proper syntax is as follows:

# change-mac home       # Changes MAC Address to Original
# change-mac <MAC>      # Changes MAC Address to One Specified
# change-mac random     # Changes MAC Address Randomly

# macs.dat required format:
#   XX:XX:XX:XX:XX:XX

file="macs.dat"

if [ ! -f $file ] ; then
        echo "File $file Does Not Exist"
        exit 0
fi

NB_LINES=$(expr $(wc -l $file | sed -e 's/ *//' | cut -f1 -d " "))
NB_RAND=0

while [ "$NB_RAND" -eq 0 ]
        do
        NB_RAND=$(expr $RANDOM \% $NB_LINES)
done

random=`sed -n "${NB_RAND}p;${NB_RAND}q" $file`

if [ "$1" == home ]; then
        ifconfig eth0 down
        ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX # Change to your original MAC address
        ifconfig eth0 up
        echo "Original MAC Address Restored."
        exit 0
elif [ "$1" == random ]; then
        ifconfig eth0 down
        ifconfig eth0 hw ether $random
        ifconfig eth0 up
        echo "MAC Address Randomly Changed To $random"
        exit 1
elif [ "$1" ]; then
        ifconfig eth0 down
        ifconfig eth0 hw ether $1
        ifconfig eth0 up
        echo "MAC Address Changed To $1."
        exit 2
else
        echo "change-mac home      # Changes MAC Address to Original"
        echo "change-mac <MAC>     # Changes MAC Address to One Specified"
        echo "change-mac random    # Changes MAC Address Randomly"
        exit 3
fi

Code: change-mac.sh

Return to $2600 Index