Created
January 15, 2014 11:42
-
-
Save pallih/8434784 to your computer and use it in GitHub Desktop.
Bash function to randomize MAC address and hostname on OS X. Could live in ~/.bash_profile
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
function mask(){ | |
# Changes MAC address to a random one and sets the hostname to a random word | |
# Tested on OS X 10.9 (Macbook Pro) | |
# Based on http://blog.kejsarmakten.se/all/software/2013/08/30/spoof-mac-on-osx.html | |
# and http://osxdaily.com/2010/09/06/change-your-mac-hostname-via-terminal/ | |
# Note: neither are permanent (a reboot resets both) | |
# For a permanent change to hostname: sudo scutil –-set HostName NEWHOST | |
# Consider using SpoofMAC: https://github.com/feross/SpoofMAC | |
NEWMAC=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//') | |
echo "Changing MAC " $(ifconfig en0 | grep ether) | |
sudo ifconfig en0 ether $NEWMAC | |
echo "New MAC is:" $(ifconfig en0 | grep ether) | |
NEWHOST=$(sed `perl -e "print int rand(99999)"`"q;d" /usr/share/dict/words) | |
echo "Changing hostname: " $(hostname) | |
sudo hostname $NEWHOST | |
echo "New hostname is:" $(hostname) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment