Created
April 18, 2019 07:46
-
-
Save djpadz/5a75112ad628ba15ea44b00f203f1b6b to your computer and use it in GitHub Desktop.
macOS: MAC address spoofing
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 | |
(( $(id -u) == 0 )) || exec sudo -E "$0" "$@" | |
# Set ATV_MAC to the MAC address of your Apple TV. | |
[[ -z $ATV_MAC ]] && ATV_MAC='aa:bb:cc:dd:ee:ff' | |
[[ -z $AIRPORT_INTERFACE ]] && AIRPORT_INTERFACE="$(networksetup -listnetworkserviceorder | grep -F 'Hardware Port: Wi-Fi' | awk '{print substr($NF,1,length($NF)-1)}')" | |
[[ -z $SSID ]] && SSID=$(networksetup -getairportnetwork "${AIRPORT_INTERFACE}" | cut -c24-) | |
[[ -z $ORIG_MAC ]] && ORIG_MAC="$(ifconfig "${AIRPORT_INTERFACE}" link | tail -1 | awk '{print $NF}')" | |
echo "Device: ${AIRPORT_INTERFACE}" | |
echo "Original MAC address: ${ORIG_MAC}" | |
echo "Changing MAC address to: ${ATV_MAC}..." | |
ifconfig "${AIRPORT_INTERFACE}" link "${ATV_MAC}" | |
networksetup -setairportpower "${AIRPORT_INTERFACE}" off | |
networksetup -setairportpower "${AIRPORT_INTERFACE}" on | |
echo "Associating with ${SSID}..." | |
sleep 1 | |
networksetup -setairportnetwork "${AIRPORT_INTERFACE}" "${SSID}" | |
read -r -s -n 1 -p "Press any key after you've logged in. " | |
echo "" | |
echo "Setting MAC address back to ${ORIG_MAC}..." | |
ifconfig "${AIRPORT_INTERFACE}" link "${ORIG_MAC}" | |
networksetup -setairportpower "${AIRPORT_INTERFACE}" off | |
networksetup -setairportpower "${AIRPORT_INTERFACE}" on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment