Changing Hostname makes problems with su

I managed to find what is causing my problem of applications not running as root anymore. Its since Parrot 3.11, whenever i change my hostname (i does automatically each times i connect to network) i can’t launch anything as root anymore, and i have to change it back to parrot or else i can’t.

    $sudo burpsuite
No protocol specified
No protocol specified
java.awt.AWTError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.

Any ideas how to fix that, the system won’t let me unless my hostname is “parrot” and nothing else

Additionnal note, after changing my hostname to whatever, if i reboot the computer, then it becomes the new required hostname needed to run applications as root, otherwise i need to use “xhost +” if i want to run as root apps with changed hostname which is bad. I remember being able to change hostname and still use applications as root on parrot 3.9 and 3.10, is it a new security feature toward remote connection ?

It seems to be a security feature i did not know about, whenever i change hostname, the cookies in “xauth” will be only valid for my previous hostname, unless i reboot the computer, in which case it will create a new cookie for the new hostname and authenticate with it when running applications that runs with X11.

I created a script that can successfully change hostname, and some other cool stuff that makes you a ghost.

2 Likes

Thanks, i use a similar script made by someone else. It also change hostname while adding it to the xauth, so that you can still use graphical applications as root with a modified hostname.
Its compatible with network-manager, and CLI

1 Like

Watch out, this not change the hostname to me;
It only change it until the connection activated, thats why i never use hostname

I did not answer earlier because i did not understand what you meant, but now yes. It does not change your hostname because you are probably using network-manager, the script work best with a CLI network manager i noticed, making the MAC change persistent after loss of connection, same for the hostname.

I use wicd-curses and the script works.

Also your script is great too, and have no problem i noticed with network-manager so far.

1 Like

Thanks!

I didn’t use wicd because of THIS TOPIC:

I checked HERE, and it is true. Last update in 2016.01. and no more will come.

I knew about that, but i don’t know what more updates they could do, i mean what does network-manager updates bring ? So far wicd has no updates but at least can keep its MAC and hostname after a disconnection without having to tweak, and has an option to disable auto-connect.

Thats mainly why i use it.

1 Like

Never tried wicd. The network-manager keeps mac and hostname change for me.
I think your problem is this: https://blogs.gnome.org/thaller/2016/08/26/mac-address-spoofing-in-networkmanager-1-4-0/

And instead of hostname for hostname change i use hostnamectl

2 Likes

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. ? :confused: ?
(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

https://github.com/systemd/systemd/blob/master/src/hostname/hostnamectl.c

but I haven’t looked through it yet to see what it is doing that my other script did not. thanks again everyone

1 Like

The main porpuse of duppy is to hide the computer.
Because of ignoring the ARP, the computer is invisible in the lan.
Cant ping, cant portscan.
The hostname / mac changing is just secondary.

Two week ago i planned to mix anonsurf and duppy in a shell script.

Your script seems good.
Personally, i dont like services for this, if i were you i make this as a startup script.
Instead of, a good solution as a service :wink:

Maybe need to stop the nm service before macchanger

The problem was with the xserver.
xauth list show the host that can use graphical apps.
the xhost command that you use, solve this issue

I’m pretty sure I did, but I’ll try it again

No, but that’s my point. that first script that ends with “xhost +$newhn” did NOT work. gksu was still broken after that, though I had no problems with su/sudo. That’s why I had to use the other script. Any ideas on why? Would running it as a service, in the manner that I did, cause this to not work for some reason?

So, in order to do this I

mv /usr/bin/[name].sh /etc/init.d/
chmod +x /etc/init.d/[name].sh

and if that doesn’t work then I should try to

ln -s /etc/init.d/[name].sh /etc/rc.d/

???

By the way, the benefit I saw in making it a service is because you can execute it at any time with

service [name] restart

Though, I like your way a lot, too, because I’m finding that I don’t often do that, but rather just let it run at boot and call it good enough.

thanks for your reply!

Then i read it wrong, sorry.
I had two long day with it, i learned the method for life :smiley:

So:

xauth list show something like this:

parrot/unix:0 MIT-MAGIC-COOKIE-1 53577b419b74306c2914f7b747708ede

if you change a hostame, you need to add a user to /home/user/.Xauthority

xauth add <newname>/unix:0 . <same cookie>
(Watch out for the dot! )----------^

then gksu should work now

if you want to remove a user:

xauth remove <name>/unix:0

And after this chown the .Xauthority file for the new host

Off:

Never do, but i always want to use my script with bash auto-complete :smiley: