VulnNet - DotJar

Date: 10, May, 2021

Author: Dhilip Sanjay S


Click Herearrow-up-right to go to the TryHackMe room.

Enumeration using nmap

$ nmap -sV <MACHINE_IP> | tee nmap.out

Starting Nmap 7.91 ( https://nmap.org ) at 2021-04-25 00:23 IST
Nmap scan report for <MACHINE_IP>
Host is up (0.22s latency).
Not shown: 998 closed ports
PORT     STATE SERVICE VERSION
8009/tcp open  ajp13   Apache Jserv (Protocol v1.3)
8080/tcp open  http    Apache Tomcat 9.0.30

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 31.85 seconds

Gobuster

AJP Shooter

Reverse shell (Java)

  • Upload using command line (manager-script role is only enabled)

Shell access

  • After uploading via command line, visit the URL in browser: http://<MACHINE_IP>:8080/reverse.war

  • Simultaneously listen using netcat on the appropriate port. Once you get a shell, upgrade it.

Linpeas

  • Get linpeas on the target machine and execute it. I have added the output of linpeas which I found to be useful.

Privilege Escalation

Accessing the shadow backup file

  • Backup folder contains the shadow file backup. Try to download the .bak or .gz file to your machine to access it.

  • Unzipping .gz file using gunzip to access the shadow file:

Cracking the Hash of jdk-admin

  • We know that it's an SHA-512 hash (via the password policy) - Check the linpeas output.

  • So let's crack the hash using john or hashcat

User.txt

  • Switch user to jdk-admin using the cracked credentials and access the user flag

Root flag

  • By listing the privileges of the jdk-admin, we find that this user can execute any jar file as root.

Creating and Executing Jar file

  • Executing Jar file, but it gives an error due to the absence of manifest attribute.

  • Adding manifest attribute and then executing the exploit:

References

Last updated