šŸ”ŽšŸ¦¶Enumeration/Foothold

Seal is an Medium Linux box from HTB and created by MrR3boot. This box features a web server with an exploitable Tomcat running jmxproxy alongside nginx which we use to access the Tomcat host manager and deploy a reverse shell. Once on the box we use ansible playbook alongside a symlink to escalate.

I begin each box by running a RustScan. This is bundled into my setup.sh script which I’ve mentioned in a few of my other posts. RunningĀ RustScanĀ withĀ nmapĀ filters. Reviewing the results I see multiple ports open:

Copy

Reviewing the results I seeĀ Port 80/443Ā open. Navigating to theĀ HTTPSĀ version of the site I am presented with a certificate error. Viewing the certificate provides the following information:

Shows the website seal.htb as well as a possible user.

Shows the website seal.htb as well as a possible user.

Seeing this I addĀ seal.htbĀ into my hosts file:

Copy
Seal Market Vegetables Shop

Seal Market Vegetables Shop

Navigating to the website shows a Seal Market vegetable shop. I see when clicking Search it adds anĀ ?+Vegetable=[input]#Ā parameter. I note this down and kick off aĀ FeroxBusterĀ scan.

Copy

Next after reviewing myĀ nmapĀ results I can see thatĀ Port 8080Ā is open and shows a registration form:

I fill out the registration form and log into the website. After logging in I can see two repositories, one of which isĀ seal_market. Navigating to it shows a ToDo and two folders:

ToDo List for Seal Market App

ToDo List for Seal Market App

So this tells us a lot as we can see that bothĀ nginxĀ andĀ tomcatĀ are running and that the manager/host-manager forĀ tomcatĀ are still available. Seeing these two items and aĀ tomcatĀ folder and check if any revisions exist. UsingĀ Ctrl+FĀ to find in Firefox I search forĀ password=Ā as that is the string you see forĀ tomcatĀ based passwords.

tomcat/tomcat-users.xml 0 ā†’ 100644

Next I reviewed my FeroxBuster scan I kicked off earlier. It showed the manager directory unfortunately it was reporting 302.

I used FeroxBuster again on the manager directory poking at it further with a tomcat discovery list by SecLists

Copy

Seeing that I was able to hit certain modules within Tomcat I began researchingĀ nginx + tomcat exploitĀ traversal and found a great presentation fromĀ Blackhat. I changed theĀ urlĀ and logged into the Host Manager.

I tried uploading a reverse shell but was unable to do so as a CSRF token prevented the upload.

Tomcat Host Manager screen and deployed reverse shell.

Tomcat host manager screen and deployed reverse shell.

I went into Burp Suite and changed the request on the upload. Reviewing the request I can see theĀ POSTĀ request is going toĀ /manager/html/uploadĀ which will fail as we do not have direct access. Change this to include the traversal exploit above allows the shell to be uploaded:

Copy
Burp Suite changing the request for the jmxproxy.

Burp Suite changing the request for the jmxproxy.

You can see the shell successfully uploaded:

Reverse shell uploaded on the Tomcat host manager.

Reverse shell uploaded on the Tomcat host manager.

šŸ”Escalation

I spawn aĀ ncĀ session and navigate over to the reverse shell page I then checkĀ /var/lib/pythonĀ to validate Python3 is installed and upgrade my session:

Copy

I then navigate to theĀ tempĀ directory and upload LinPEAS to the box.

āš  Attack Machine

Copy

šŸŽÆ Victim Machine

Copy

Reviewing the LinPEAS output I was was able to find both entries above telling me to focus on theĀ run.ymlĀ file. Reviewing the file I can see that its doing a copy to move files from one directory to another. I can also see that theĀ copy_links=yesĀ means symbolic links are allowed.

Copy

I check theĀ /admin/dashboardĀ directory and notice anĀ uploadsĀ folder with read/write access. I do a symlink to pull theĀ .sshĀ directory from Luis’ home directory.

Copy

Once the backup is done being created (takes around a minute) I copy the file into my working directory underĀ tmp

Copy

I then navigated to the uploads directory and copied the id_rsa to my attacking machine. Once on the attacking machine I set the permissions to 600 and logged into the box.

Copy

Upon entering the box viaĀ SSHĀ I check what can be run asĀ SUDO.

Copy

Just like the first escalation method we can useĀ ansible-playbookĀ as root. I create a quickĀ escalate.ymlĀ based off theĀ run.ymlĀ file and upload it to the host.

āš  Attack Machine

Copy
Copy

šŸŽÆ Victim Machine

Copy

I grab both flags and finalize the box:

Copy

Rooted

Published On: November 12th, 2021 / Categories: HTB, Technology / Tags: , , , , , , , , , /

Leave A Comment