Skip to content

Instantly share code, notes, and snippets.

@kjellberg
Last active June 18, 2018 05:41
Show Gist options
  • Save kjellberg/50dd482f697290499f25 to your computer and use it in GitHub Desktop.
Save kjellberg/50dd482f697290499f25 to your computer and use it in GitHub Desktop.
#!/bin/bash
: '
Change your mac address on a MacBook
Can be used for free wifi on airports or train stations =)
$ chmod +x freewifi.sh
$ ./freewifi.sh
'
interface=en1 # en0 for cable & en1 for wifi
oe=$(ifconfig $interface | grep ether) # save old ether output
a=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//') # generate new mac address
sudo ifconfig $interface ether $a # change mac address
ne=$(ifconfig $interface | grep ether) # get old ether output
if [ "$oe" != "$ne" ] # check if mac address is changed.
then
echo "Mac address changed."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment