July 15, 2020

HackTheBox Writeup— Jerry

This was a pretty easy box, but it had nice techniques and I learn about exploiting vulnerable TomCat Server, it was fun doing this box

The IP for this machine is 10.10.10.95

NMAP Scan Results

We run the nmap scan using the command nmap -sC -sV -oA nmap 10.10.10.95

As the nmap scan blocking our ping probes, we gave an extension -Pn

Now we see that port 8080 is open and is running HTTP service of Apache Tomcat/Coyote JSP engine 1.1

HTTP Service

We run the IP 10.10.10.95:8080 in the browser and we get the default or normal Apache Tomcat server page

Let’s now run dirb scan

Dirb Scan

We got many directories, interesting ones look host-manager and manager, let’s see what it has

The /host-manager Path

Here when we tried to access http://10.10.10.95:8080/host-manager

It prompted for username and password, so I tried random username and passwords like admin/admin or root/admin etc.

But no luck, then when I clicked on Cancel button, I was redirected to this page

Here we clearly see that username=”tomcat” and password=”s3cret”, which by first I thought was a leak from the server, but after researching I came to know that it is the Apache Tomcat default username/password.

I tried to re-enter this as username and password, but it didn’t prompt me due to the cookie stored, so I will try this on http://10.10.10.95:8080/manager and see what it shows

The /manager Path

So here we try to access http://10.10.10.95:8080/manager, we get

Scrolling down more, we see

We see that we can upload a WAR file, now let’s begin some enumeration and google

Enumeration

So after doing google searches and enumeration, I came to know that we can upload WAR files and also we can create a MSF payload using msfvenom in WAR format, so let’s do it

Creating WAR Backdoor using msfvenom

Here we create a WAR format backdoor to upload in the Tomcat manager and then access it to get the reverse shell

Payload created, now let’s upload it

Uploading WAR Backdoor

Now we upload our created backdoor “faisal.war” in the Tomcat manager

Now we click on Deploy

Our backdoor has been uploaded and now we can access it using the URL http://10.10.10.95:8080/faisal

Getting Shell

Before we access http://10.10.10.95:8080/faisal, we need to set up a listener

Boom, we got shell just after accessing the backdoor link

Looking Further

Now let’s see which user we are

We are already now to NT Authority\system so we don’t need to do privilege escalation

Getting The Flags

We saw there was a folder names flags in C:\Users\Administrator\Desktop

Inside of it had a txt file name as “2 for the price of 1.txt” when we tried to read it from the shell, the shell died, I did many times, but again the same thing happened

So, now I create a windows backdoor in exe format using msfvenom and then uploaded it using powershell command Invoke-WebRequest and then set up another listener in msfconsole to get a meterpreter shell

Now we try to read the txt file from meterpreter or else download it to our machine

We couldn’t read it, so i tried downloading it my box and it downloaded, now let’s see what it has

Boom, we got both the user flag and root flag

Vulnerabilities Used To Exploit This Box

WAR File Backdoor Upload At Apache Tomcat

References

Below are the links for the resources which helped me in solving this box

Leave a Reply