Skip to content

Instantly share code, notes, and snippets.

Last active July 4, 2016 13:09
What would you like to do?
osx mac address changer
function remac() {
local progress='.oO°Oo'
local airport=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport
local ssid=$($airport -I|awk '/^ *SSID/ {print $2}')
local iface=$(networksetup -listallhardwareports|grep -A1 Wi-Fi|awk '/Device:/ {print $2}')
local mac=${1:-00$(openssl rand -hex 5|sed 's/\(..\)/:\1/g')}
echo Disconnecting Wi-Fi $iface from SSID $ssid to set new mac address $mac...
sudo $airport -z
local i n=0
until ifconfig $iface ether | grep -q $mac ; do
sudo ifconfig $iface ether $mac
sleep .1
i=$[++n % $#progress + 1]
echo -n "$progress[$i]\r"
networksetup -setairportnetwork $iface $ssid \
&& echo mac is $mac \
|| echo failed $mac && false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment