Created
March 3, 2017 23:27
-
-
Save mikedoubintchik/91ac859e3f588c3714de646503ca7fab to your computer and use it in GitHub Desktop.
Here's a little bash script snippet for randomizing and spoofing your MAC address both on OS X and Linux
This file contains hidden or 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
#!/usr/bin/env bash | |
echo "Are you on Mac? [y,n]" | |
read input | |
if [[ $input == "Y" || $input == "y" ]]; then | |
## Show active interfaces | |
ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active' | |
## Ask which interface to spoof | |
echo "Which interface are you spoofing?" | |
read interface | |
################################# | |
## Generate random MAC Address ## | |
################################# | |
MAC=$( openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//' ) | |
################################### | |
## Randomize MAC address on OS X ## | |
################################### | |
## Set random address | |
sudo ifconfig $interface ether $MAC | |
## Display new address | |
ifconfig $interface | grep ether | |
else | |
echo "Are you on Linux? [y,n]" | |
read input | |
if [[ $input == "Y" || $input == "y" ]]; then | |
## Show active interfaces | |
ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active' | |
## Ask which interface to spoof | |
echo "Which interface are you spoofing?" | |
read interface | |
################################# | |
## Generate random MAC Address ## | |
################################# | |
MAC=$( openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//' ) | |
#################################### | |
## Randomize MAC address on Linux ## | |
#################################### | |
service network-manager stop | |
sudo ifconfig $interface down | |
sudo ifconfig $interface hw ether $MAC | |
sudo ifconfig $interface up | |
service network-manager start | |
## Display new address | |
echo $MAC | |
else | |
echo "Use another script foo" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment