A few days ago, @killamjr outlined the steps he used to analyze this document. I haven’t done much with using other tools like XORsearch or scdbg.exe so decided to give it a go.
It didn’t go so well. But thanks to @killamjr’s help, updating all of Didier Steven’s tools, and this SANS blog post, it all worked out fine. Let’s work through it.
First things first, let’s use oledump.py to see what lies underneath this document.
Instead of macros or vbaProject.bin files, we see ‘EncryptedPackage’. This means that the document itself has been protected with a password. However, if we try to open the document it won’t prompt for a password at all. What can we do from here?
msoffcrypto-crack.py is a simple tool that can be used to crack passwords on MS documents. Running that tool gives us the password:
VelvetSweatshop? There’s only one man who would have a password like that.

Anyway, even though we know the password, there’s no place for us to put it in the document so that we can get access to the macros like we normally would. But at this point we have two options.
We could run msoffcrypto-crack.py on the document and use the output option (-o) to save the cracked file. We could then use OfficeMalScanner with inflate to dump all of the macros and .bin files.

Instead, we will be piping the output from msoffcrypto-crack.py directly into oledump.py. We will still need to make use of the output option (-o) as well as the ‘-‘ option to make the output go to stdout. All of that will get directed into oledump.py

We can now see that streams A3 – A6 have macros. They might be worth investigating. Stream B3’s size may contain something interesting as well. But stream C2’s name is ‘EQuAtIOn NatiVE’. This can contain shellcode or other encoded commands. That one is definitely worth looking at.
To do so, we need to add a few more options to oledump.py. We want to select C2 (-s C2) and then dump (-d) out to a file. We’ll call it oledump.bin.
Running strings on oledump.bin doesn’t give us much of anything at all.
This means that the .bin file is likely shell code. To decode the binary, we will be using the tool XORsearch.exe. From the website:
XORSearch is a program to search for a given string in an XOR, ROL, ROT or SHIFT encoded binary file… XORSearch will try all XOR keys (0 to 255), ROL keys (1 to 7), ROT keys (1 to 25) and SHIFT keys (1 to 7) when searching.
We will also be using the -W option to make use of XORsearch’s built in signatures.
It looks like a GetEIP instruction was found at position 0x2A7 without any encoding at all (XOR 00).
With our shellcode (oledump.bin) and offset (0x2A7) in hand, we can make us of a shellcode analyzer/emulator called scdbg.exe. There are two ways that we can use this. We can use the GUI to point it at oledump.bin, add the Start Offset, click Launch, and the decoded shellcode appears.

Or we can use the command line version of it. We just need to point it at the file (option -f) and also give it the offset of 2A7 (option -foff). we should be getting the same output.

Note that we see the URL from which the file is going to be downloaded and also the location where it will be dropped.
Thanks for reading!
One thought on “Crimson Rat (02-24-2020): VelvetSweatshop and shellcode”