Blog

Coinminer on a Vulnerable Tomcat Server

BY eSentire Threat Response Unit (TRU)

February 6, 2024 | 4 MINS READ

Attacks/Breaches

Threat Intelligence

Threat Response Unit

TRU Positive/Bulletin

Want to learn more on how to achieve Cyber Resilience?

TALK TO AN EXPERT

Adversaries don’t work 9-5 and neither do we. At eSentire, our 24/7 SOCs are staffed with Elite Threat Hunters and Cyber Analysts who hunt, investigate, contain and respond to threats within minutes.

We have discovered some of the most dangerous threats and nation state attacks in our space – including the Kaseya MSP breach and the more_eggs malware.

Our Security Operations Centers are supported with Threat Intelligence, Tactical Threat Response and Advanced Threat Analytics driven by our Threat Response Unit – the TRU team.

In TRU Positives, eSentire’s Threat Response Unit (TRU) provides a summary of a recent threat investigation. We outline how we responded to the confirmed threat and what recommendations we have going forward.

Here’s the latest from our TRU Team…

What did we find?

At the beginning of January 2024, the eSentire Threat Response Unit (TRU) investigated a cryptojacking incident involving exploitation of a customer’s vulnerable Apache Tomcat server(Figure 1).

Figure 1: Infection process tree

The command shown above downloads the malicious script from 45.125.131[.]17 and uses “| sh” that pipes the output of the downloaded file directly into “sh”, a Unix shell, which executes the content of the downloaded file.

The downloaded file is a shell script (MD5: f63d58eba01f63cfd9ca24f2b390c4bc).

In Figure 2, the code is responsible for downloading a binary file from a remotehost. The code uses “wget” or “curl” to download a file named amd64 from the server specified at “HTTP_SERVER” and save it under “/tmp/.systemd-private-77435dd5909847103069367864234-color.service-vKDO4qY/”. The code introduces a random delay (RAND) before starting the download.

Figure 2: Snippet of code responsible for downloading coinminer binary

In the code below (Figure 3), the script attempts to create one of the following directories:

Figure 3: Code snippet responsible for creating directories

Once the directory is successfully created in any one of these locations, the script sets “PATH_BIN” to the path of this directory and exits the loop. If the script fails to create the directory in all three locations, it prints an error message and breaks out of the loop.

The code in Figure 4 is responsible for executing the downloaded binary with certain parameters:

Figure 4: Mining configuration

The code snippet in Figure 5 checks if a cron job involving the C2 server already exists. If not ($TEMP_CRON -eq 0), it creates a new cron job. The cron job is scheduled to run at a random minute every hour ($RAND_CRON). It uses curl or wget to download and execute the shell script from the server. The cron job is written to a temporary file named “Koajd.txt”, which is then added to the crontab and subsequently deleted.

The script then checks if there are fewer than three processes running that match certain criteria (involving "$ADDRESS" (coinminer address), amd64, and specific mining configuration). If the conditions are met ($TEMPxa2 -lt 3), it calls the “two_loop” function, which goes to the beginning of the shell script and produces the same steps we have described.

Figure 5: Snippet of the code responsible for setting up the cron job

Upon checking the BTC wallet address (referenced in Figure 6), it is observed that the current balance stands at approximately $333.

Figure 6: BTC wallet balance

What did we do?

What can you learn from this TRU Positive?

Recommendations from our Threat Response Unit (TRU) Team:

eSentire TRU is a world-class team of threat researchers who develop new detections enriched by original threat intelligence and leverage new machine learning models that correlate multi-signal data and automate rapid response to advanced threats.  

To learn what it means to have an elite team of Threat Hunters and researchers that works for you, connect with an eSentire Security Specialist now. 

Indicators of Compromise

Name

Indicators

df2vGJJ58ivF

f63d58eba01f63cfd9ca24f2b390c4bc

C2

45.125.131[.]17

Pool’s server address

ghostrider.jp.mine.zpool[.]ca:5354

BTC wallet

bc1q8szxzvt4y2wzvew0x8mrgpkhf9dah5twx847wg

eSentire Unit
eSentire Threat Response Unit (TRU)

The eSentire Threat Response Unit (TRU) is an industry-leading threat research team committed to helping your organization become more resilient. TRU is an elite team of threat hunters and researchers that supports our 24/7 Security Operations Centers (SOCs), builds threat detection models across the eSentire XDR Cloud Platform, and works as an extension of your security team to continuously improve our Managed Detection and Response service. By providing complete visibility across your attack surface and performing global threat sweeps and proactive hypothesis-driven threat hunts augmented by original threat research, we are laser-focused on defending your organization against known and unknown threats.

Read the Latest from eSentire