Created
February 14, 2022 03:12
-
-
Save ph00lt0/cdbdccb09f5b36a38a7e389ceae17648 to your computer and use it in GitHub Desktop.
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
# Origin: https://github.com/sunknudsen/privacy-guides/tree/master/how-to-spoof-mac-address-and-hostname-automatically-at-boot-on-macos | |
set -e | |
set -o pipefail | |
export LC_CTYPE=C | |
basedir=$(dirname "$0") | |
# Spoof computer name | |
first_name=$(sed "$(jot -r 1 1 2048)q;d" $basedir/first-names.txt | sed -e 's/[^a-zA-Z]//g') | |
model_name=$(system_profiler SPHardwareDataType | awk '/Model Name/ {$1=$2=""; print $0}' | sed -e 's/^[ ]*//') | |
computer_name="$first_name’s $model_name" | |
host_name=$(echo $computer_name | sed -e 's/’//g' | sed -e 's/ /-/g') | |
sudo scutil --set ComputerName "$computer_name" | |
sudo scutil --set LocalHostName "$host_name" | |
sudo scutil --set HostName "$host_name" | |
printf "%s\n" "Spoofed hostname to $host_name" | |
# Spoof MAC address of Wi-Fi interface | |
mac_address_prefix=$(sed "$(jot -r 1 1 768)q;d" $basedir/mac-address-prefixes.txt | sed -e 's/[^A-F0-9:]//g') | |
mac_address_suffix=$(openssl rand -hex 3 | sed 's/\(..\)/\1:/g; s/.$//') | |
mac_address=$(echo "$mac_address_prefix:$mac_address_suffix" | awk '{print toupper($0)}') | |
networksetup -setairportpower en0 on | |
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport --disassociate | |
sudo ifconfig en0 ether "$mac_address" | |
printf "%s\n" "Spoofed MAC address of en0 interface to $mac_address" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment