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

Demystifying Obfuscation Used in the Thanksgiving Spam Campaign

During Thanksgiving week, we noticed this quite unusual XML-format MS Office Document file:

Emailsample

 Figure 1: Email Sample

Saving a Word document file as XML is a legitimate option but criminals had taken advantage of this file format to circumvent malware scanners and spam filters.

Figure2
Figure 2. XML header of a Word document file saved as XML file format
 

This Microsoft Office Word document file has an almost "hidden" TextFrame object sitting in the corner. The document also has macro in it which we will also be investigating.

Figure3
Figure 3. Screen capture of the document file when opened

 

If you expand this tiny TextFrame object you will see an obfuscated CMD shell:

Figure4
Figure 4. An Obfuscated CMD shell in the hidden TextFrame

 

The entire CMD code can be seen below:

Picture1
Figure 5. The full CMD shell extracted from the TextFrame

 

Next in the investigation, we de-obfuscated this shell command, by first removing all the caret characters "^", this is because CMD shell omits this on execution.

Figure 6
Figure 6. Part of the CMD shell after removing the Caret character

 

Taking a look at the first line of code:

cmd /c %LOCalAPpdaTA:~ -3,-2%^M%SysTEmrOoT:~ +6, +1%; ; ; ; /V:^o^ ; /%appDATa:~-7, 1%"

When printing this command using the echo command, it prints "cMD; ;;; /V:o /R"

Figure 7
Figure 7

 

The code extracts the substring from the value of the environment variable and from this, it builds a command string. For example:

%localappdata% environment variable is equivalent to this path "C:\Users\Username\AppData\Local"

Then using substring command in cmd shell "%localappdata:~-3,-2%" it extracts a character between position 3 from the end of the string and position 2 from the end string:

"C:\Users\Username\AppData\Local"

Substring
Figure 8. How the " cMD; ;;; /V:o /R " string was built

 

We are not sure why the malware writer obfuscated this, since they already had a fairly obvious precursor "cmd" string in the command shell.

Figure 9
Figure 9. Highlighted in the red block is the obfuscated Powershell command, highlighted in blue is the deobfuscation routine

 

Next, we take a look at the block of obfuscated strings assigned to the variable t8Vb and the FOR loop after that (as seen in Figure 9):

for /l %m IN (2143, -4, 3) do (SeT yN5H=!yN5H!!t8Vb:~ %m, 1!) if %m==3 ;(call; %yN5H:*yN5H!=%)

The loop actually extracts each character starting from the end of the string of the variable t8Vb and steps 4 positions backward each loop until it reaches the 3rd position of the string.

To make it a lot easier, we can reverse the string block:

Figure 10
Figure 10. Reversing the obfuscated string

 

Then starting from the first position we extract every 4th character from the string block.

Pshell
Figure 11

 

After extracting, it builds a string of the powershell command shown below:

Figure 12
Figure 12

 

So how does the powershell command get executed? The answer is a macro code. When a user opens this document file and enables the macros. A VBA macro code will trigger. This code extracts the string from the TextFrame then executes it using VBA Shell command

Figure 13

 

Figure 14
Figure 13

 

So what is the payload?

Figure 15
Figure 15. A beautified code of the Powershell command

 

The PowerShell attempts to download a binary from a list of URLs:

hxxp:// danzarspiritandtruth[.]com /J7B5TiAIp

hxxp:// littlepeonyphotos[.]ru /jPGDyvIm

hxxp:// iuyouth.hcmiu.edu[.]vn /mVayv0I7S

hxxp:// exploraverde[.]co /mmR4TaGu8

hxxp:// turkaline[.]com /zGiFH0X

Then the script saves the binary to the Windows temporary folder and executes it.

The binary files at the end of the URL are Emotet - a notorious banking trojan that rolls out different behavior such as info-stealing modules for emails and browsers.

https://www.virustotal.com/gui/file/5f8aee58ec2f1342e84ed02d276c4369b1c2359a5e57ead9269bc6fa5d67ce59/detection

 

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