Trustwave Unveils New Offerings to Maximize Value of Microsoft Security Investments. Learn More

Trustwave Unveils New Offerings to Maximize Value of Microsoft Security Investments. Learn More

Managed Detection & Response

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

Co-Managed SOC (SIEM)

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

Advisory & Diagnostics

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

Penetration Testing

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

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

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

Digital Forensics & Incident Response

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

Firewall & Technology Management

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

Offensive Security
Solutions to maximize your security ROI
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
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.  


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.  


Figure 3. Suspicious document before the padding is removed. 

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


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. 


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. 


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. 


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.  


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. 


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. 


Figure 10. Obfuscated code of the decode function. 


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


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. 


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. 












File Name 

Hash Type 


ACH Payment   








File Name 

Hash Type 


ACH Payment info.doc  








File Name 

Hash Type 









File Name 

Hash Type 









Latest SpiderLabs Blogs

Network Isolation for DynamoDB with VPC Endpoint

DynamoDB is a fully managed NoSQL database service offered by Amazon Web Services (AWS). It is renowned for its scalability, dependability, and easy connection with other AWS services....

Read More

The Underdog of Cybersecurity: Uncovering Hidden Value in Threat Intelligence

Threat Intelligence, or just TI, is sometimes criticized for possibly being inaccurate or outdated. However, there are compelling reasons to incorporate it into your cybersecurity defense strategy....

Read More

Clockwork Blue: Automating Security Defenses with SOAR and AI

It’s impractical to operate security operations alone, using manual human processes. Finding opportunities to automate SecOps is an underlying foundation of Zero Trust and an essential architecture...

Read More