F5 threat researchers have discovered a new Apache Struts campaign. This new campaign is a sophisticated multi-staged attack targeting internal networks with the NSA-attributed EternalBlue and EternalSynergy exploits. We have dubbed the campaign “Zealot” based on the name of the zip file containing the python scripts with the NSA-attributed exploits. As we continue to research this campaign, we will update this publication. This is what we know so far:
When F5’s threat researchers first discovered this new Apache Struts campaign dubbed Zealot, it appeared to be one of the many campaigns already exploiting servers vulnerable to the Jakarta Multipart Parser attack (CVE-2017-56381) that have been widespread since first discovered in March 2017. It also exploits the DotNetNuke (DNN) vulnerability (CVE-2017-98222), disclosed in July 2017. The Zealot campaign aggressively targets both Windows and Linux systems with the DNN and Struts exploits together. When looking more closely at the unusually high obfuscated payload, we discovered a much more sophisticated multi-staged attack, with lateral movement capabilities, leveraging the leaked NSA-attributed EternalBlue and EternalSynergy exploits.
The Zealot campaign is currently mining the cryptocurrency Monero, however, attackers could use compromised systems to do whatever they want.
The attack starts with the threat actor scanning the web and sending two HTTP requests. One of the requests is the notorious Apache Struts exploit via the Content-Type header. While most of the similar Apache Struts campaigns target either Windows or Linux platforms, Zealot is equipped with payloads for both.
If the server is vulnerable, it will execute JAVA code to determine the underlying OS.
For Linux, it will run shell commands in the background, using the more robust “nohup” command, which allows the process to run even after the shell is closed. The command will download and execute a spearhead bash script.
Download and Execute Methods
Zealot will try to fetch the script using several methods. It will try to connect to a remote server over a TCP socket and redirect the received data directly to the shell. If failed, it will use “curl” and “wget” tools (that ship with Linux) to download a file name “larva”, then execute and delete it after a second.
Those download and execute techniques are later applied in all the delivered malwares and are referred to by the author as “tcp” and “http” download functionality.
“larva” Spearhead Deliveries
The downloaded bash script will check whether the machine is already infected by testing for the existence of a predefined mutex (“21914”). It will terminate if it exists; then it will execute in a loop.
Then it will use the same download and execute techniques to fetch a file named “mule”, which is a crypto-miner malware.
Next, it will pipe an embedded base64 obfuscated python code to a new python process.
Little Snitch and the Unknown Functionality
Once revealed, you can see that the python code checks whether a “Little Snitch” process is running (a firewall solution for macOS) and will terminate it if it is.
If the firewall process is not running, it will send a request to a C&C server to fetch another piece of python code.
At the time we conducted this research, we could not collect that additional python code as the server was down.
It doesn’t appear that the attackers are targeting MACs currently. The attackers seem to be using the EmpireProject post-exploitation framework (see section below) which generates a python agent for both Linux and OS X. The Little Snitch check is part of this python agent. Currently the campaign delivers crypto-miner MZ for Windows and ELF for Linux. There is no binary for OSX.
The way this script communicates with the server is levels of sophistication beyond the common botnet herder, so it grabbed our attention. When sending the request to the C&C, specific User-Agent and Cookie headers are added. This technique means that anyone (like us researchers) who tries to access the C&C from their own browser or a tool won’t get the same response as the malware.
The received response is curious, as well, because the content is encrypted using the RC4 cipher, so typical network inspection devices can see it but they cannot analyze or scan it. Only the script has the key. The response is another piece of Python code that is decrypted using the RC4 cipher, and once decrypted, is executed.
If the detected OS is Windows, the STRUTS payload will run a PowerShell interpreter in a hidden mode, which will run a base64 encoded code. Once decoded two times, the result is another obfuscated script. Once de-obfuscated, it reveals a URL to another file to be downloaded from another domain.
Reflective DLL Injection of the Crypto-Miner
The downloaded file is an even more heavily obfuscated PowerShell script “scv.ps1”. Once this wall of resistance is broken, all the action begins.
This main deployer will download miner malware and run it. It will then download the same malware as a DLL and use the reflective DLL injection technique to inject the malware into the PowerShell process for more stealth.
If python 2.7 is not installed on the Windows machine, it will download the python installer and deploy it. Then it will download the main python module (“probe.py”) which initiates the propagation into the internal network. The script is obfuscated using the “pyminifier”, a public package for python code minimization, obfuscation, and compression. The original script was base64-encoded and zipped 20 times.
The “probe.py” script determines whether the platform is 32- or 64-bit and the underlying OS.
If the variable names and their values sound familiar, you are probably a fan of the legendary StarCraft game, same as the attacker. Zealot, Raven, Observer, and Overlord are all types of characters in the game.
As the exploit is running on a Windows machine, it will download the “zealot.zip” and “raven64.exe” files. “zealot.zip” includes several python scripts and libraries while all attacker’s scripts are obfuscated with the same “pyminifier” tool.
All the other files are known python packages.
“raven64.exe” will scan the internal network for port 445 and will invoke zealot.py, which will inject three different shellcodes for Windows 7 and Windows 8 to exploit EternalSynergy and EternalBlue.
Once the injected shellcode is successfully executed, it will run PowerShell to download the same “scv.ps1” agent, however, this time from a different server.
The EternalSynergy exploit has built-in shellcode, unlike the EternalBlue exploit which has external files as their shellcodes (residing in “data” folder). The shellcodes in both exploits have PowerShell commands to run in them. Unlike the EternalBlue shellcodes, the EternalSynergy is trying to download and execute a PowerShell script named “minerd_n.ps2” from another server that was not available during this research.
The “mule” malware is a cryptocurrency malware mining for the Monero currency. Monero has become the cybercrime currency of choice due to its high anonymity. The amount that was paid for this specific miner address was approximately $8,500 USD. It is not known how much profit the threat actor has overall.
After some more research on the deployed scripts, it seems that the Zealot attacker made use of the public EmpireProject,3 which is a PowerShell and Python post-exploitation agent.
Another request sent by the Zealot attacker is exploiting DotNetNuke, a content management system based on ASP.NET, by sending a serialized object via a vulnerable DNNPersonalization cookie (CVE-2017-9822).
To obtain arbitrary code execution, attackers are using an ASP.NET “ObjectDataProvider” gadget and the “ObjectStateFormatter” formatter, to embed another object and invoke a shell. The “ObjectStateFormatter” provides a second level of obfuscation because the embedded object is in a base64 encoded format. The invoked shell will execute a base64-encoded PowerShell script, the same one delivered via the Apache Struts exploit.
Zealot seems to be the first Struts campaign using the NSA exploits to propagate inside internal networks. There were other malware campaigns like NotPetya and WannaCry ransomware, and also Adylkuzz cryptominer launching attacks by directly4 scanning the Internet for SMBs to exploit with the NSA tools the ShadowBrokers released. The Zealot campaign, however, seems to be opening new attack vector doors, automatically delivering malware on internal networks via web application vulnerabilities. The level of sophistication we are currently observing in the Zealot campaign is leading us to believe that the campaign was developed and is being run by threat actors several levels above common bot herders.
Stay tuned for more updates from F5 Labs on this campaign. For now, patch your systems immediately for the CVEs being exploited if you haven’t already, and strongly consider implementing a web application firewall for automated protection.
MODIFIED: Jan 18, 2018