Last active
August 29, 2015 13:56
-
-
Save jacobbednarz/8952053 to your computer and use it in GitHub Desktop.
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 | |
# | |
# Generate a random mac address, the old fashioned way. | |
# Ensure we are running as root. | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root." 2>&1 | |
exit 1 | |
fi | |
# Check we have the device defined. | |
if [ $# -eq 0 ]; then | |
echo "You have not passed through a device name such as wlan0. Please" | |
echo "check the usage example." | |
echo | |
echo " Usage:" | |
echo " sudo mac-spoof wlan0" | |
fi | |
DEVICE=$1 | |
FRESH_MAC=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//') | |
ifconfig $DEVICE down | |
ifconfig $DEVICE hw ether $FRESH_MAC | |
ifconfig $DEVICE up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment