I was about to start a new thread, but it looks like everyone here is interested in the same thing(s) as me, so I’ll post here. I have two concerns:
(1) MAC address
(a) Network-Manager -random MAC option is terrible. It seems to me it only circulates through like <20 MAC addresses and then rehits the same ones. Does anyone else notice this? Where is the list of usable MACs?
(b) if I use macchanger to change my MAC, then Network-Manager (GUI) seems to override the change. Why? Any way to stop this?
(2) Hostname
(a) Parrot anonymous mode does not change the hostname like in Backbox. ? ?
(b) as mentioned above, gksu seems to break when I change my hostname unless I reboot. This is particularly problematic, as I wrote a script which I set up as a service, so my hostname always changes on reboot.
I’ll show you what I did and maybe you can critique it or get some ideas from it.
The (very simple) script: /usr/bin/[name].sh
#!/bin/bash
idomainname=$(domainname -i)
fdomainname=$(domainname -f)
newhn=$(shuf -n 1 /etc/dictionaries-common/words | sed -r ‘s/[^a-zA-Z]//g’ | awk ‘{print tolower($0)}’)
echo $newhn > /etc/hostname
mv /etc/hosts /etc/hosts.old
echo “127.0.0.1 localhost” > /etc/hosts
echo “$idomainname $fdomainname $newhn” >> /etc/hosts
echo
echo “# The following lines are desirable for IPv6 capable hosts” >> /etc/hosts
echo “::1 localhost ip6-localhost ip6-loopback” >> /etc/hosts
echo “ff02::1 ip6-allnodes” >> /etc/hosts
echo “ff02::2 ip6-allrouters” >> /etc/hosts
service hostname.sh stop
sleep 1
service hostname.sh start
service networking stop
sleep 1
service networking start
service network-manager stop
sleep 1
service network-manager start
xhost +$newhn
exit
NOTE: This pulls your new hostname from the same list as Backbox Anonymous Mode
NOTE2: This does leave a trace of your old hostname on your PC (/etc/hosts.old), but only the very last one. Delete the relevant line (#4) in the code to nix that.
Anyway, then what I did was simply set this up as a service that runs at reboot. So, create a file in:
/etc/systemd/system/[servicename].service
[Unit]
Description=Hostname Randomizer
[Service]
ExecStart=/usr/bin/[name].sh
[Install]
WantedBy=multi-user.goal
then you have to enable it with
systemctl enable changehost.service
What I eventually did to make it work without breaking gksu was change the code to use hostnamectl to change the hostname. Now, at reboot, my hostname changes and I haven’t noticed any problems with this… yet [fingers crossed]
Here’s my code:
#!/bin/bash
mv /etc/hosts /etc/hosts.old
newhn=$(shuf -n 1 /etc/dictionaries-common/words | sed -r ‘s/[^a-zA-Z]//g’ | awk ‘{print tolower($0)}’)
hostnamectl set-hostname $newhn
echo “127.0.0.1 localhost” > /etc/hosts
echo “127.0.1.1 $newhn” >> /etc/hosts
echo
echo “# The following lines are desirable for IPv6 capable hosts” >> /etc/hosts
echo “::1 localhost ip6-localhost ip6-loopback” >> /etc/hosts
echo “ff02::1 ip6-allnodes” >> /etc/hosts
echo “ff02::2 ip6-allrouters” >> /etc/hosts
exit
Let me know if you found this helpful and/or if you have any suggestions. Also, please let me know if you have any tips concerning my other questions, or if I should start a new thread to address them. Thanks!
PS. does anyone know how hostnamectl works? How to get the source code?
UPDATE: It looks like source code can be found here
systemd/src/hostname/hostnamectl.c at main · systemd/systemd · GitHub
but I haven’t looked through it yet to see what it is doing that my other script did not. thanks again everyone