Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More

Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More

Services
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.

Solutions
BY TOPIC
Microsoft Security
Unlock the full power of Microsoft Security
Offensive Security
Solutions to maximize your security ROI
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

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

 

ABOUT TRUSTWAVE

Trustwave is a globally recognized cybersecurity leader that reduces cyber risk and fortifies organizations against disruptive and damaging cyber threats. Our comprehensive offensive and defensive cybersecurity portfolio detects what others cannot, responds with greater speed and effectiveness, optimizes client investment, and improves security resilience. Learn more about us.

Latest Intelligence

Discover how our specialists can tailor a security program to fit the needs of
your organization.

Request a Demo