Tomcat β Discovery & Enumeration
Apache Tomcat is an open-source web server for hosting Java-based applications. It runs Java Servlets, JSP scripts, and is widely used by frameworks like Spring and tools like Gradle. Tomcat is often exposed on internal networks and is a common target during internal penetration tests.
Statistics & Prevalence
- 220,000+ live Tomcat websites (BuiltWith data)
- 904,000+ websites have used Tomcat at some point
- 1.22% of top 1 million websites use Tomcat
- 3.8% of top 100k websites use Tomcat
- Market share rank: #13 for web servers
Notable users: Alibaba, USPTO, American Red Cross, LA Times
Tomcat Directory Structure
Understanding the Tomcat installation structure is crucial for exploitation and enumeration.
tomcat_home/
βββ bin/ # Startup/shutdown scripts and binaries
βββ conf/ # Configuration files
β βββ catalina.policy # Security policy file
β βββ catalina.properties # Tomcat properties
β βββ context.xml # Default context configuration
β βββ tomcat-users.xml # User credentials and roles
β βββ tomcat-users.xsd # XML schema for tomcat-users
β βββ web.xml # Global web application configuration
βββ lib/ # JAR files for Tomcat core functionality
βββ logs/ # Log files
βββ temp/ # Temporary files
βββ webapps/ # Default web root (application deployment)
β βββ manager/ # Tomcat manager application
β β βββ images/
β β βββ META-INF/
β β βββ WEB-INF/
β βββ ROOT/ # Default application
β βββ WEB-INF/
βββ work/ # Cache and runtime data
βββ Catalina/
βββ localhost/
Key Configuration Files
tomcat-users.xml: Stores user credentials and role assignments for manager/host-manager access.
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<!-- Built-in Tomcat manager roles: -->
<!-- manager-gui - HTML GUI and status pages -->
<!-- manager-script - HTTP API and status pages -->
<!-- manager-jmx - JMX proxy and status pages -->
<!-- manager-status - Status pages only -->
<role rolename="manager-gui" />
<user username="tomcat" password="tomcat" roles="manager-gui" />
<role rolename="admin-gui" />
<user username="admin" password="admin" roles="manager-gui,admin-gui" />
</tomcat-users>
Application Structure
Each application deployed in webapps/ follows this structure:
webapps/customapp/
βββ images/
βββ index.jsp
βββ META-INF/
β βββ context.xml
βββ status.xsd
βββ WEB-INF/
βββ jsp/
β βββ admin.jsp
βββ web.xml # Deployment descriptor (IMPORTANT)
βββ lib/
β βββ jdbc_drivers.jar # Application libraries
βββ classes/
βββ AdminServlet.class # Compiled servlets
WEB-INF/web.xml (Deployment Descriptor)
The web.xml file defines servlets, servlet mappings, and other application configuration. This is critical for understanding application structure and finding potential entry points.
Example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>AdminServlet</servlet-name>
<servlet-class>com.inlanefreight.api.AdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AdminServlet</servlet-name>
<url-pattern>/admin</url-pattern>
</servlet-mapping>
</web-app>
This configuration:
- Defines a servlet
AdminServletmapped to classcom.inlanefreight.api.AdminServlet - Maps requests to
/adminto this servlet - Shows the class would be located at:
classes/com/inlanefreight/api/AdminServlet.class
Important: The web.xml file reveals application routes and handler classes, making it valuable during LFI exploitation.
Fingerprinting & Discovery
HTTP Header Detection
Tomcat versions are often revealed in the Server header. Requesting an invalid page typically exposes the server version:
curl -i http://target.com:8080/invalid
Response (Tomcat 9.0.30):
HTTP/1.1 404 Not Found
Server: Apache Tomcat/9.0.30
...
/docs Page
If custom error pages arenβt configured, the /docs endpoint provides version information:
curl -s http://target.com:8080/docs/ | grep -i tomcat
Output:
<title>Apache Tomcat 9 (9.0.30) - Documentation Index</title>
The /docs page is a default documentation page often left in place by administrators.
Enumeration
Directory Brute-Force
Use tools like Gobuster to enumerate common Tomcat directories:
gobuster dir -u http://target.com:8180/ \
-w /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt
Common Tomcat paths to find:
/docsβ Documentation (version leak)/examplesβ Example applications/managerβ Tomcat Manager (admin interface)/host-managerβ Host Manager (advanced admin)/adminβ Older admin console
Example Gobuster Output:
/docs (Status: 302)
/examples (Status: 302)
/manager (Status: 302)
/host-manager (Status: 302)
Manager & Host-Manager Pages
The /manager page is the primary target. It typically requires Basic Authentication with credentials stored in tomcat-users.xml.
Common default credentials to try:
tomcat:tomcatadmin:adminadmin:passwordtomcat:passwordmanager:manager
Direct access attempt:
curl -u tomcat:tomcat http://target.com:8080/manager/html
If credentials are weak or default, you can:
- Log into the Manager GUI
- Upload a WAR (Web Application Resource) file containing a JSP web shell
- Gain remote code execution on the server
Key Findings During Enumeration
| Finding | Severity | Impact |
|---|---|---|
/manager accessible with default credentials | Critical | Full application deployment capability |
/docs page reveals version information | Medium | Enables version-specific exploit targeting |
/examples accessible | Low-Medium | May contain example servlets with vulnerabilities |
Weak credentials in tomcat-users.xml | Critical | Admin access via Manager |
| JSP upload capability | Critical | Remote code execution |
Exposed WEB-INF/web.xml (LFI) | High | Application structure disclosure |
Best Practices for Enumeration
- Always check
/docsβ Easy version identification - Test default credentials β Very common in internal environments
- Enumerate all paths β Manager, host-manager, and custom applications
- Check for accessible configuration files β Via directory listing or LFI
- Document all findings β Note versions, paths, and potential entry points
Next Steps
Once enumeration is complete:
- If credentials are found/guessed β exploit Manager via WAR upload
- If known vulnerability exists β test for CVE
- If LFI found β attempt to read
tomcat-users.xmlorweb.xml - If nothing else works β perform credential brute-force against Manager login