Keyboard shortcuts

Press ← or β†’ to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🏠 Back to Blog

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 AdminServlet mapped to class com.inlanefreight.api.AdminServlet
  • Maps requests to /admin to 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:tomcat
  • admin:admin
  • admin:password
  • tomcat:password
  • manager:manager

Direct access attempt:

curl -u tomcat:tomcat http://target.com:8080/manager/html

If credentials are weak or default, you can:

  1. Log into the Manager GUI
  2. Upload a WAR (Web Application Resource) file containing a JSP web shell
  3. Gain remote code execution on the server

Key Findings During Enumeration

FindingSeverityImpact
/manager accessible with default credentialsCriticalFull application deployment capability
/docs page reveals version informationMediumEnables version-specific exploit targeting
/examples accessibleLow-MediumMay contain example servlets with vulnerabilities
Weak credentials in tomcat-users.xmlCriticalAdmin access via Manager
JSP upload capabilityCriticalRemote code execution
Exposed WEB-INF/web.xml (LFI)HighApplication structure disclosure

Best Practices for Enumeration

  1. Always check /docs β€” Easy version identification
  2. Test default credentials β€” Very common in internal environments
  3. Enumerate all paths β€” Manager, host-manager, and custom applications
  4. Check for accessible configuration files β€” Via directory listing or LFI
  5. 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.xml or web.xml
  • If nothing else works β†’ perform credential brute-force against Manager login