Skip to content

Instantly share code, notes, and snippets.

@jacobbednarz
Last active August 29, 2015 13:56
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 jacobbednarz/8952053 to your computer and use it in GitHub Desktop.
Save jacobbednarz/8952053 to your computer and use it in GitHub Desktop.
#!/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