Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Services
Capture
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

twi-managed-portal-color
Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

twi-briefcase-color-svg
Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

tw-laptop-data
Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

twi-database-color-svg
Database Security

Prevent unauthorized access and exceed compliance requirements.

twi-email-color-svg
Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

tw-officer
Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

tw-network
Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Deobfuscating the Recent Emotet Epoch 4 Macro

In early March, one of the notorious botnets, Emotet, resumed its spamming activities after a 3-month period of inactivity.  

Recently, Trustwave SpiderLabs saw Emotet switch focus to using OneNote attachments, which is a tactic also adopted by other malware groups in recent months. This analysis is intended to help the cybersecurity community better understand the wider obfuscation and padding tricks Emotet is using.  

For a more in-depth analysis of this technique, please refer to our series of blog posts which can be found here: Trojanized OneNoteA Noteworthy Threat, and OneNote Spear-Phishing Campaign 

At first, this spam campaign followed the typical scenario with a document file carrying malware that was attached to a convincing reply-chain email. However, Emotet used a ‘new old trick’ in an attempt to bypass security scanners by compressing a bloated document file into a ZIP file.  

19826_image002

Figure 1. Recent Emotet spam campaign with a ZIP compressed document file 

Twitter handle @Cryptolaemus1 who tracks this botnet noticed this spam activity coming from Emotet Epoch 4.     

Figure 2. A tweet from Cryptolaemus 

At the surface level, the ZIP file appears small in file size but when extracting the document from the ZIP, we see that the decompressed file size is a little over 500MB. Upon further investigation of the document, we found the reason for the abnormal file size is a zero-byte padding technique.  

This technique is where a file's size is inflated by appending null bytes or useless data to the end of a file. Often, this is done as an evasion technique to avoid security software as many tools do not allow uploading or scanning of large files. It is extremely suspicious, so much so, that our Trustwave MailMarshal email gateway simply blocked all the samples up-front due to the massively redundant data.  

19828_image006

Figure 3. Suspicious document before the padding is removed. 

After removing most of the padding, the file comes down to just 303KB. 

19829_image008

Figure 4. Suspicious document after the padding is removed. 

Deobfuscating the Macro: 

The document file is similar to previous Emotet spam campaigns and includes a highly obfuscated malicious macro. The code obfuscation may initially appear messy and difficult to read. 

19830_image010

Figure 5. Emotet’s obfuscated VBA macro1 

It contains random function and variable names, as well as thousands of lines of seemingly unused code. However, there is a recognizable macro name present in the code: AutoOpen. This macro is an event that is triggered when the document file is opened, making it the entry point function. 

19831_image012

Figure 6. Emotet’s use of random macro names2 

Within the AutoOpen macro, a specific function named ‘uYiCsM’ is called. This is repeatedly called throughout the code, appearing a total of 41 times. 

19832_image014

Figure 7. Function uYiCsM is the decode function3 

Before calling the decode function, a block of code initializes the variables that will be passed as parameters to the decode function. These parameters include the character table, a list of character indices, and string length.  

19833_image016

Figure 8. Before calling the decode function, it initializes variables for the string length, the character table.  

Deobfuscating a single string can require a block of code that is notably lengthy and may span several hundred lines of code. Nevertheless, as one delves deeper into the code, a pattern may start to emerge and become easier to discern. 

19834_image018

Figure 9. Initializing character indices is a pattern that becomes evident throughout the code. However, assigning a single value to one index uses three lines of code, contributing to the code's overall length and complexity. 

The length of obfuscated code is primarily due to the initialization of the list of character indices, which can be convoluted. Additionally, the use of individual lines of code to assign each value to an index can contribute to the overall length of the code. 

The code below is the decode function that takes a character table and a list of character indices and uses them to decode a string by reading characters from the character table based on the indices and appending them to a new string. 

19835_image020

Figure 10. Obfuscated code of the decode function. 

19836_image022

Figure 11. Right is the deobfuscated and beautified code for easy readability. 

19837_image024

Figure 12. We converted the decode function into a Python code to decode the strings in a controlled manner. 

Once strings are decoded, we can refactor the code and beautify it for easy readability. We have shared the complete deobfuscated VBA macro code in our Gists. 

19838_image026

Figure 13. Comparison of the obfuscated and the deobfuscated AutoOpen macro. 

This summary describes the flow of the AutoOpen macro:

  • Declare variables and assign values to the variables for URLs and file extensions. 
  • Generate a filepath with the current time and append the ‘.tmp’ file extension to it. 
  • Try to download a file from the first URL, and if that fails, try to download from the remaining URLs until a download is successful. 
  • If a download is successful, it checks whether the file is a PE or a ZIP archive. 
  • If the file is a ZIP archive, the malware unpacks the binary. 
  • Proceeds to execute the binary via regsvr32.exe. 

It is worth noting that the file extracted from the downloaded archive also contains an excessive amount of null bytes, which gives the impression that it is a much larger file than it actually is. 

IOCs

URLs

hxxp://xyktza.nbxyk.net/bwzysov/index/X3hFHbueMtgoEi/etaJ35/ 

hxxp://arlex.su/services/IE2h6fBsQRQOhHBI691U/ 

hxxp://api.660011.cc/wp-includes/b028GIRSxa4lY/ 

hxxp://www.garrett.kz/faq/B0faEHvS9msSo9xbVe/ 

hxxp://abrokov.com/lang/SZnqErcEtuE/ 

hxxp://rref.su/uchastniki/rNNdVArBjNc100n3p/ 

hxxp://mealux.by/pab4/wxuGxcqF85M/ 

 

Hashes 

File Name 

Hash Type 

Hashes 

ACH Payment info.zip   

MD5 

68612b3d0094d51d3ca89ed6e3b16b4c  

SHA1 

b80ac7dda1b65be5297ba03b1ac17dbc2bb10339  

SHA256 

7041a0d1b2d0c1199e4b7505b0ab181ad2cdc881e01a520fb66758f081e4d40d 

 

File Name 

Hash Type 

Hashes 

ACH Payment info.doc  

MD5 

141c079135312197dcb6d2adfe8b5663  

SHA1 

4f2e8fcbdb60e099241c0e8e203c700d9d4941b2  

SHA256 

57903dc1811ef431a8480dc489764d9b2dae324fcf002c924c8f3a592b96a922 

 

File Name 

Hash Type 

Hashes 

downloaded.zip  

MD5 

20758c45171dfad6bb02a77b773782d3  

SHA1 

e0ea8e2d0580ffe40ec5ed3bdd2bb78c6c7b2ffb  

SHA256 

a189c6cecce39ab05abb5386ca036887170c28a40cd1acd76dd7b4c36e0a2d9d 

 

File Name 

Hash Type 

Hashes 

sHwNyPFidh5lkT7KX86sNryPMvM4.dll  

MD5 

fa914c6c9744ea25592dfca65a9d13e1  

SHA1 

663861e36c8d55911a036bbc9108c3d774a97b2a  

SHA256 

cecdb3028c0879a850ccbf0535cc3918912d9b6e19b40b6dbfedb0c58265227c 

Latest SpiderLabs Blogs

Hunting For Integer Overflows In Web Servers

Allow me to set the scene and start proceedings off with a definition of an integer overflow, according to Wikipedia:

Read More

Welcome to Adventures in Cybersecurity: The Defender Series

I’m happy to say I’m done chasing Microsoft certifications (AZ104/AZ500/SC100), and as a result, I’ve had the time to put some effort into a blog series that hopefully will entertain and inform you...

Read More

Trustwave SpiderLabs: Insights and Solutions to Defend Educational Institutions Against Cyber Threats

Security teams responsible for defending educational institutions at higher education and primary school levels often find themselves facing harsh lessons from threat actors who exploit the numerous...

Read More