Skip to content

Instantly share code, notes, and snippets.

@predominant
Created May 28, 2014 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save predominant/39a032db2fb11bef915c to your computer and use it in GitHub Desktop.
Save predominant/39a032db2fb11bef915c to your computer and use it in GitHub Desktop.
#!/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