My notes about some privacy issues like mac change, hostname change on ubuntu OS. And how to make script.
1. $ sudo ifconfig wlp1s0 down To disable interface
2. $ sudo ifconfig wlp1s0 hw ether 66:66:66:00:00:00 To change MAC
3. $ sudo ifconfig wlp1s0 up To start interface with new MAC address
4. But is changes MAC only once, after restart it goes back.
5. Its saved in etc/hosts You could change it with $ hostnamectl set-hostname Petya
6. $? holds status of previously command, 0 means TRUE
7. To generate random number do.
$ RANDOM=$(date | cut -b23-24) //Set generator from time randomly
$ echo $RANDOM | cut -b1-2 //Use only first two numbers
8. Finnal script
#!/bin/bash #Script for automaticly change MAC and Hostname RANDOM=$(date | cut -b23-24) #Init random from date ifconfig wlp1s0 down if [ $? == 0 ]; then #if previous command succeeded set new MAC printf "Interface down" ifconfig wlp1s0 hw ether $(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 )) else printf "\n Error: Interface is not down" exit 1 fi #We are trying to set MAC couple of times until success because not all random numbers suitable to be MAC. until [ $? == 0 ]; do ifconfig wlp1s0 hw ether $(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 ))":"$(( $RANDOM % 99 + 10 )) done if [ $? == 0 ]; then printf "\n Success. MAC changed!: " ifconfig wlp1s0 up else printf "\n Error: MAC is not changed...Sorry man" exit 1 fi if [ $? == 0 ]; then #We install new random host name ifconfig wlp1s0 | grep "ether" | cut -d " " -f 10 printf "Success. Interface is up!" hostnamectl set-hostname $RANDOM else printf "\n Error: Interface is no up...Sorry man" exit 1 fi if [ $? == 0 ]; then printf "\n Success. Hostname changed!: " hostname else printf "\n Error: Hostname isn't changed...Sorry man" exit 1 fi |
9. Need to move script to /etc/init.d/ directory
10. sudo update-rc.d startup_file.sh defaults //Update startup file
What is Machine ID and boot id from hostnamectl ?