How to easily change (or spoof) your MAC Address in OS X

I have only tested this script on OS X 10.6.8, meaning: I have no idea if it works in other versions of OS X. For the most part, it should work without any issues – or worst case scenario: with minor modifications to this script.

This script automates the following process:

1. Identify current MAC Address
2. Generate a random MAC Address (for spoofing/changing)
3. Disconnect/Disassociate Interface
4. Change existing MAC Address with randomly generated MAC Address
5. Power up device/interface

Be sure to change the INTERFACE variable to suit your needs.

Here it is:

#!/bin/bash

# Change your network inteface ID here network interface here
INTERFACE=en1

ORIGINAL_MAC=`ifconfig $INTERFACE | grep ether | cut -d' ' -f2`

MAC=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`

echo "Intial status:"
sudo ifconfig $INTERFACE

DISCONNECT_NETWORK="sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z"

echo "Disconnect from current network"
eval $DISCONNECT_NETWORK
sleep 2

echo "Changing interface mac"
sudo ifconfig $INTERFACE lladdr $MAC
sleep 2

echo "Shutting down interface: $INTERFACE"
sudo ifconfig $INTERFACE down
sleep 2

echo "Starting up interface: $INTERFACE"
sudo ifconfig $INTERFACE up
sleep 2

echo "MAC changed from: $ORIGINAL_MAC to: $MAC"
echo "Retrieving new network status:"
sleep 10
ifconfig $INTERFACE

Having trouble?

If the above method does not work for any reason, try the following:

sudo airport -z
sudo ifconfig en1 ether c9:b2:5e:85:b2:dd
sudo ifconfig en1 ether

*change c9:b2:5e:85:b2:dd to anything you want

If you have a different version of OS X and have successfully ran a modified version of this script, please let me know.

Thanks.

 

Tags: , , , ,

Leave a comment..