Last active
February 8, 2021 04:31
-
-
Save shobhit/ed2641e3b2611e29e355954ea732cc0d to your computer and use it in GitHub Desktop.
Change Mac Address Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Hi! lets change our mac address." | |
echo "Step 1: hold down option key, click wifi logo. Note the mac address" | |
echo "Step 2: click 'disconnect from network' " | |
echo "Step 3: note which ethernet adapter lines up with the mac address you just saw" | |
read -p 'Step 4: Which device lined up would you like to change? (hit return for en0) ' ether_adapter | |
if [ -z $ether_adapter ] | |
then | |
ether_adapter="en0" | |
fi | |
export ether_adapter=$ether_adapter | |
generate_and_set_new_mac_address() { | |
mac=$( openssl rand -hex 6 | sed "s/\(..\)/\1:/g; s/.$//" ) | |
export mac=$mac | |
echo "OK, we will change the mac address associated with: $ether_adapter" | |
old_mac=$( ifconfig $ether_adapter | grep ether ) | |
echo "The old value was: $old_mac" | |
sudo ifconfig $ether_adapter ether $mac | |
new_mac=$( ifconfig $ether_adapter | grep ether ) | |
echo "The new value is: $new_mac" | |
} | |
echo $new_mac | |
echo $old_mac | |
while [ "$new_mac" == "$old_mac" ] | |
do | |
echo "not the same" | |
generate_and_set_new_mac_address | |
done | |
echo "go ahead and re-connect to the wifi. You should be able to join the network." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment