Last active
August 29, 2015 13:56
-
-
Save glennzw/8969779 to your computer and use it in GitHub Desktop.
Change your OSX MAC address to a random value. If you don't know why this is useful, you probably don't need it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# OSX MAC address changer | |
# glenn@sensepost // @glennzw | |
# This script will disaccociate from the current AP, randomly change your WiFi MAC, and then reassociate. | |
# N.B This code is specifically for OSX | |
iface=en1 | |
ap=$(airport -I | grep SSID: | grep -v BSSID| sed 's/.*SSID://' | sed -e 's/^ *//g' -e 's/ *$//g') | |
echo "[+] Disassociating interface '$iface' from SSID '$ap'" | |
airport -z | |
sleep 4 | |
old_mac=$(ifconfig en1 | grep ether| sed 's/ether //') | |
new_mac=$old_mac | |
echo "[+] Original MAC: $old_mac" | |
while [ "$old_mac" == "$new_mac" ]; do | |
tmp=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//') | |
echo "[+] Trying to set MAC: $tmp" | |
ifconfig $iface ether $tmp | |
sleep 3 | |
new_mac=$(ifconfig $iface | grep ether| sed 's/ether //') | |
done | |
echo "[+] Successfully changed MAC address!" | |
echo "[+] Re-associating to '$ap'..." | |
networksetup -setairportnetwork $iface "$ap" | |
echo "[+] Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment