Created
May 28, 2014 01:47
-
-
Save predominant/39a032db2fb11bef915c to your computer and use it in GitHub Desktop.
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 | |
INTERFACE="en0" | |
MACCMD="ifconfig $INTERFACE ether" | |
MACREAL="aa:aa:aa:aa:aa:aa" | |
MACFAKE="bb:bb:bb:bb:bb:bb" | |
function usage { | |
echo "Usage:" | |
echo " mac fake" | |
echo " mac real" | |
echo " mac show" | |
} | |
function showmac { | |
CURRENTMAC=$(ifconfig en0 | grep ether | awk '{print $2}') | |
echo "MAC Address is $CURRENTMAC" | |
} | |
if [[ "$#" -ne 1 ]]; then | |
usage | |
fi | |
case "$1" in | |
real) | |
sudo $MACCMD $MACREAL | |
showmac | |
;; | |
fake) | |
sudo $MACCMD $MACFAKE | |
showmac | |
;; | |
show) | |
showmac | |
;; | |
gen) | |
RANDMAC=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//') | |
echo "New random MAC Address:" | |
echo " $RANDMAC" | |
;; | |
*) | |
usage | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment