Skip to content

Instantly share code, notes, and snippets.

@joshspicer
Created October 11, 2018 08:40
Show Gist options
  • Save joshspicer/7fc8571e7b6a04b6250631855eeea358 to your computer and use it in GitHub Desktop.
Save joshspicer/7fc8571e7b6a04b6250631855eeea358 to your computer and use it in GitHub Desktop.
Change the MAC address for a given interface on your Mac computer.
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "[-] Usage: ./changeMAC.sh <interface>"
echo "[-] Hold down the option key and click the WiFi symbol to see your default interface name"
exit 1
fi
interface=$1
echo "==BEFORE=="
ifconfig | grep -A 1 $interface | grep "ether"
randomMAC=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
sudo ifconfig $interface ether $randomMAC
echo "==AFTER=="
ifconfig | grep -A 1 $interface | grep "ether"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment