Skip to content

Instantly share code, notes, and snippets.

@steinfletcher
Last active August 29, 2015 14:03
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 steinfletcher/06ce978f479f86b0cc00 to your computer and use it in GitHub Desktop.
Save steinfletcher/06ce978f479f86b0cc00 to your computer and use it in GitHub Desktop.
Change the mac address of a device (useful for various spoofing, e.g. for extending limited access on public wifi networks). Tested in OSX
#!/bin/bash
# Author: Stein Fletcher <steinfletcher@gmail.com>
# Purpose: Changes the mac address for the en0 device
# get the current mac address
old_addr=`/sbin/ifconfig en0 | awk '/ether/ {print $2}'`
# Generates a random new mac address using openssl
new_addr=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
# change the actual address
sudo /sbin/ifconfig en0 ether $new_addr
timestamp=`date`
echo "$timestamp: Changed mac address from $old_addr to $new_addr"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment