Last active
December 24, 2016 02:52
-
-
Save mnadel/b5592ef34f36d96d98f359470b501d9b to your computer and use it in GitHub Desktop.
Change your Mac's MAC
This file contains hidden or 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
#!/usr/bin/env bash | |
MYMAC=$(/usr/sbin/networksetup -getmacaddress Wi-Fi | grep -oE "[a-zA-Z0-9]{2}:([a-zA-Z0-9]{2}:?)+") | |
if [ "$1" == "--help" ] || [ $# -gt 1 ]; then | |
echo "usage: $(basename $0) [--random|--orig]" | |
exit 1 | |
fi | |
if [ $# -eq 0 ] || [ "$1" == "--random" ]; then | |
# force first octet to be even (end in 0,2,4,6,8,a,c,e) to indicate unicast | |
newmac=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/./0/2; s/.$//') | |
elif [ "$1" == "--orig" ]; then | |
newmac=$MYMAC | |
else | |
echo huh? | |
exit 1 | |
fi | |
echo disassociating | |
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z | |
echo setting mac to: $newmac | |
sudo ifconfig en0 ether "$newmac" | |
echo restarting en0 | |
#networksetup -detectnewhardware | |
sudo ifconfig en0 down | |
sudo ifconfig en0 up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment