Trustwave's 2024 Financial Services Threat Reports Highlight Alarming Trends in Insider Threats & Phishing-as-a-Service. Learn More
Get access to immediate incident response assistance.
Get access to immediate incident response assistance.
Trustwave's 2024 Financial Services Threat Reports Highlight Alarming Trends in Insider Threats & Phishing-as-a-Service. Learn More
During Thanksgiving week, we noticed this quite unusual XML-format MS Office Document file:
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.
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.
If you expand this tiny TextFrame object you will see an obfuscated CMD shell:
The entire CMD code can be seen below:
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.
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"
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"
We are not sure why the malware writer obfuscated this, since they already had a fairly obvious precursor "cmd" string in the command shell.
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:
Then starting from the first position we extract every 4th character from the string block.
After extracting, it builds a string of the powershell command shown below:
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
So what is the payload?
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.
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.
Copyright © 2024 Trustwave Holdings, Inc. All rights reserved.