Machine Overview#
Thompson is an easy-rated boot2root machine from TryHackMe, designed for the FIT and BSides Guatemala CTF. This machine demonstrates common web application misconfigurations, particularly around Apache Tomcat deployments, and highlights the critical importance of proper file permissions in Unix-like systems.
Skills Required#
- Basic Linux knowledge
- Web application enumeration
- Understanding of Java web applications (WAR files)
- Privilege escalation fundamentals
Skills Learned#
- Tomcat Manager exploitation
- WAR file deployment for reverse shells
- Cron job privilege escalation
- File permission exploitation
Machine Information#
| Attribute | Details |
|---|---|
| Name | Thompson |
| Platform | TryHackMe |
| Difficulty | Easy |
| OS | Linux (Ubuntu) |
| Attack Vector | Tomcat Manager → WAR Deployment → Cron Exploitation |
Phase 1: Reconnaissance#
Network Scanning#
We begin with an Nmap scan to identify open ports and running services:
| |
Scan Results:
| |
Key Findings:
- Port 22: SSH (OpenSSH 7.2p2) - Standard SSH service
- Port 8009: AJP13 (Apache Jserv Protocol) - Used for Tomcat clustering
- Port 8080: Apache Tomcat 8.5.5 - Our primary attack vector
The presence of Apache Tomcat 8.5.5 immediately suggests we should investigate the Tomcat Manager interface, as misconfigurations here are common in CTF environments and real-world scenarios.
Phase 2: Enumeration#
Web Application Analysis#
Navigating to http://10.10.x.x:8080 presents us with the default Apache Tomcat welcome page.
The welcome page includes helpful links:
- Manager App
- Host Manager
- Documentation
- Examples
Tomcat Manager Discovery#
Attempting to access the Tomcat Manager at http://10.10.x.x:8080/manager/html prompts for HTTP Basic Authentication.
Credential Discovery#
Here’s where things get interesting. After a failed login attempt with common credentials like admin:admin, we’re presented with an error page. However, this isn’t just any error page—it’s a security misconfiguration goldmine.
The 401 Unauthorized page displays example configuration instructions, including:
| |
This is a critical finding. The error page is essentially handing us valid credentials on a silver platter. While this might seem unrealistic, similar information disclosure vulnerabilities exist in production environments through:
- Verbose error messages
- Exposed configuration files
- Default credentials that were never changed
- Documentation left accessible on production systems
Credentials Discovered:
- Username:
tomcat - Password:
s3cret
Authenticated Access#
Using these credentials, we successfully authenticate to the Tomcat Manager interface:
| |
The Manager interface provides extensive capabilities:
- Deploy new applications
- Start/stop existing applications
- View server information
- Access diagnostic tools
Phase 3: Initial Access#
Understanding WAR Files#
Web Application Archive (WAR) files are the standard packaging format for Java web applications. The Tomcat Manager allows authenticated users to deploy WAR files, which will be automatically unpacked and executed by the server.
This functionality, while legitimate, becomes an attack vector when:
- Weak or default credentials are used
- The manager interface is exposed to untrusted networks
- No additional access controls are implemented
Weaponization#
We’ll create a malicious WAR file containing a JSP-based reverse shell using msfvenom:
| |
Payload Breakdown:
java/jsp_shell_reverse_tcp: A JSP-based reverse shell payloadLHOST: Our attacking machine’s IP (TryHackMe VPN interface)LPORT: The port we’ll listen on-f war: Output format as a WAR file-o shell.war: Output filename
Example Output:
| |
Setting Up the Listener#
Before deploying, we need a listener to catch the reverse shell:
| |
Deployment#
There are multiple ways to deploy the WAR file:
Method 1: Web Interface
- Navigate to the “WAR file to deploy” section
- Click “Choose File” and select
shell.war - Click “Deploy”
- The application appears in the applications list as
/shell
Method 2: cURL
| |
Triggering the Shell#
Once deployed, we trigger the reverse shell by accessing the application:
| |
Alternatively, simply click the /shell link in the Manager interface.
Shell Stabilization#
Upon receiving the connection, we have a basic shell as the tomcat user:
| |
We can upgrade to a fully interactive TTY:
| |
This provides us with:
- Tab completion
- Command history (up/down arrows)
- Proper terminal sizing
- SIGINT handling (Ctrl+C works properly)
Phase 4: Privilege Escalation#
User Enumeration#
Now that we have a foothold, let’s enumerate the system:
| |
First Flag Located: The user flag is in /home/jack/user.txt
Critical Discovery: Writable Cron Job#
Three files in Jack’s directory immediately stand out:
id.sh- A script with full permissions (-rwxrwxrwx)test.txt- Contains output from a recent commanduser.txt- Our first objective
Let’s examine these files:
| |
This is highly significant. The test.txt file shows uid=0(root), indicating that id.sh was recently executed with root privileges. The script itself is trivial—it just runs the id command and redirects output to test.txt.
Cron Job Analysis#
Let’s check for scheduled tasks:
| |
Jackpot! The last line reveals our privilege escalation vector:
| |
Breaking down this cron entry:
* * * * *- Executes every minuteroot- Runs as the root usercd /home/jack && bash id.sh- Changes to Jack’s directory and executes id.sh
The Vulnerability:
- The script runs as root every minute
- The script is world-writable (
-rwxrwxrwx) - We have write access as the tomcat user
- We can replace the script contents with any commands we want
This is a critical security misconfiguration that violates the principle of least privilege.
Exploitation Strategy#
We have several options for exploiting this vulnerability:
Option 1: Reverse Shell (Chosen Method)#
Set up a new listener on a different port:
| |
Replace the script with a reverse shell:
| |
Alternative reverse shell payloads:
Bash TCP:
| |
Python:
| |
Option 2: SUID Binary#
Create a SUID copy of bash:
| |
Wait for the cron to execute, then:
| |
Option 3: SSH Key Injection#
Add your public key to root’s authorized_keys:
| |
Root Access#
After modifying id.sh with our reverse shell payload and waiting approximately one minute:
| |
Success! We’ve achieved root access and can read the final flag.
Key Takeaways#
For Attackers (Penetration Testers)#
Default Credentials are Everywhere: Always test default credentials, especially on common services like Tomcat, Jenkins, and database systems.
Information Disclosure Matters: Error messages, default pages, and verbose outputs can leak sensitive information. Always read error pages carefully.
WAR File Deployment = Code Execution: Any authenticated access to Tomcat Manager essentially gives you code execution as the Tomcat user.
File Permissions Tell a Story: World-writable files, especially those in user directories or executed by the system, are prime privilege escalation candidates.
Cron Jobs are Powerful: System-wide cron jobs running as root with writable scripts are critical vulnerabilities.
Conclusion#
The Thompson machine demonstrates how multiple small misconfigurations can chain together to create a complete system compromise:
- Information Disclosure → Credential exposure via error messages
- Weak Authentication → Default credentials on Tomcat Manager
- Insecure Deployment → Ability to deploy arbitrary code (WAR files)
- Poor File Permissions → World-writable script in user directory
- Privilege Misuse → Root running user-controlled scripts via cron
While this is a CTF environment designed for learning, these vulnerabilities exist in production systems. According to recent security reports:
- 80% of breaches involve weak or default credentials
- 60% of organizations have at least one Tomcat instance exposed to the internet
- Privilege escalation via cron jobs remains a common vector in Linux compromises
Understanding these attack vectors—and more importantly, how to prevent them—is crucial for both red team operators and system administrators.
Additional Resources#
- Apache Tomcat Security Documentation
- OWASP Top 10
- Linux Privilege Escalation Guide
- CIS Benchmarks for Linux


