We received another malicious macro doc (Invoice_Info_99362097.doc) today that I just had to pick apart. Here's the tear down:
Extract the macros with oletools→olevba
olevba --deobf Invoice_Info_99362097.doc
Loaded under a syntax highlighter, a quick glance shows that a bunch of this script is commented out. I guess to give the appearance to a string based analyzer that this file does something normal for a macro? It seems like a pretty safe bet that they can be removed.
The Autoopen
seems to be the entry point. It calls Vulk
which does some useless looping, perhaps this confuses dynamic analyzers? Idk. Vulk
then calls Sduk
which just wraps Launch2
. There's parameters between all these calls, but, without actually looking, I'm gonna guess they're pointless attempts at obfuscation. Everything in the chain so far, and including this function, I'm going to refer to as the "loader". Everything else (DecScr
, GetXORChar
, etc) is only called by each other and their entry-point is through GetDecStr2
, which I'll refer to as the encoder.
Moved all the stuff related to the encoder into its own file.
First things first, we can drop comments and anything that is declared and never referred to again. Eg:
Dim rtu As String
rtu = "sdrgrthrhbdf45"
The functions breakdown to:
- GetDecStr2
Walks an encoded string two characters at a time into
DecScr
- DecScr
I'm guessing
k
is a 16 character key or password forGetXORChar
, which is rolled through at each pass through ofDecScr
. So the first pass selects one character, the next pass grabs the second character, and so on.
Next we grab two chars from the encoded string and pass them to GetCorrPart
and then mash them with the key part xx
in GetXORChar
.
- GetXORChar
((
UpperPart
<< 4) +LowerPart
) ^xx
, nuff said. - GetCorrPart Shifts values some, I feel like the offsets are related to A-Z, a-z, and other chars in ASCII, but I'm dumb and too lazy to verify that when I don't need to. :)
All these ActiveDocument.Paragraphs
calls seem to be reading hidden text from the actual doc, sneaky sneaky.
antiword Invoice_Info_99362097.doc
The key apparently lives at ActiveDocument.Paragraphs(2).Range
, and we know it's 16 chars so this seems like what we're looking for:
LH(;RsnZYrc&(>gb
Basically just did a 1-1 copy to js and imported the above dump, which yielded the payload.
Pretty straight-forward ps1 that attempts to download and run a file from two other hosts. I pretty printed it in 3a. /shrug
https://www.virustotal.com/#/file/d7183eb06aaea8c3c4605ca695cb27b3f11c0c60f7a1000874374c8fa7fe3236/details
https://iris-h.services/#/pages/report/10d21436ddc1dd6378093c5822d7acd4103b8113#conclusion