miloot.com blog

site news and other musings.

How to Change MAC Address on OSX 10.9+

| Comments

Haven’t updated this blog in a while, which is a bit unfortunate, but hopefully this will be start of many new posts.

I am currently on vacation and finding internet access can be a bit tricky.

Fortunately I found that XFINITY WiFi offers free hourly internet. Unfortunately this only allows one hour every 24 hours up to two times.

Obviously this is not enough so I decided to poke around and see if I could sniff out how this was working.

By examining some of their post requests I found that they are simply limiting access by tying their network to your MAC address.

Easy !

I wrote a little script that will change my Macbooks MAC address ( until a full restart occurs ) and get around this pesky limitation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash

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

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

In addition I added the following just to make things a bit easier.

1
2
3
4
echo "Launching xfinity login page"
URL="https://wifilogin.comcast.net/wifi/start.php?cm=$MAC&tm=xfw01&bn=st02"
sleep 5
open -a "Firefox" $URL

I was going to script the whole network execution using cURL but haven’t had the time yet … maybe next time.

And as always please use at own risk, I provide no guarantees :)

Comments