-
-
Save tel/3024994 to your computer and use it in GitHub Desktop.
Mac Address Spoofing Script
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
#!/usr/bin/env sh | |
SCRIPT=`basename $0` | |
BACKUP=$HOME/.mac.orig | |
case "$1" in | |
current) | |
ifconfig en0 | ack ether | cut -d\ -f 2 | |
;; | |
new) | |
openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//' | |
;; | |
set) | |
ifconfig en0 ether $2 | |
;; | |
spoof) | |
if [ ! -f $BACKUP ] | |
then | |
CURR=`$0 current` | |
echo $CURR > ~/.mac.orig | |
echo Backed up original address: $CURR | |
fi | |
NEW=`$0 new` | |
echo Setting to $NEW | |
`$0 set $NEW` && echo Set. | |
;; | |
unspoof) | |
if [ -f $BACKUP ] | |
then | |
OLD=`cat ~/.mac.orig` | |
echo Restoring to $OLD | |
`$0 set $OLD` && echo Restored. | |
else | |
echo File $BACKUP does not exist; cannot restore! | |
exit 1 | |
fi | |
;; | |
*) | |
echo "Usage: $SCRIPT { current | new | set [ADDRESS] | spoof | unspoof }" | |
echo "Current is $($0 current)" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment