Last active
October 9, 2018 08:47
-
-
Save maesoser/705f916f4a3c2272d4c418977430b88f to your computer and use it in GitHub Desktop.
Configure every saved WiFi connection in NetworkManager with a spoofed MAC # address, seeded from the UUID of the connection and the date
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/sh | |
# /etc/NetworkManager/dispatcher.d/pre-up.d/randomize-mac-addresses | |
# Configure every saved WiFi connection in NetworkManager with a spoofed MAC | |
# address, seeded from the UUID of the connection and the date plus the hour eg: | |
# 'c31bbcc4-d6ad-11e7-9a5a-e7e1491a7e20-2017-11-20-09' | |
# This makes your MAC difficult to track across WiFi providers, and | |
# for one provider to track across days. | |
export PATH=$PATH:/usr/bin:/bin | |
LOG_FILE=/var/log/randomize-mac-addresses | |
echo "$(date): $*" > ${LOG_FILE} | |
WIFI_UUIDS=$(nmcli --fields type,name, uuid connection show | grep wifi | grep -v BYOD | awk '{print $3}') | |
for UUID in ${WIFI_UUIDS} | |
do | |
UUID_HASH=$(echo "${UUID}-$(date +"%F")" | md5sum) | |
OLD_RND_MAC=$(nmcli connection show uuid ${UUID} | grep cloned-mac-address | awk '{print $2}') | |
NEW_RND_MAC="02:$(echo -n ${UUID_HASH} | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5/')" | |
LOGLINE="Connection ${UUID} changed MAC from ${OLD_RND_MAC} to ${NEW_RND_MAC}" | |
CMD="nmcli connection modify ${UUID} wifi.cloned-mac-address ${NEW_RND_MAC}" | |
echo "$LOGLINE" >> ${LOG_FILE} | |
$CMD & | |
done | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment