Skip to content

MaldocTrace v0.7.0

Latest

Choose a tag to compare

@github-actions github-actions released this 03 Dec 03:37
· 2 commits to main since this release
e741ff1

Macro viruses and self-decrypting macros are emulated through the VBE object model, RTF and .docx droppers that hid their objects are extracted again, PowerShell started through cmd /c is decoded, and the default step budget is now 10 million steps, so script loaders reach their second stage. Tested on the 2026 MalwareBazaar corpus (1,021 files) and 245 recent samples: 17 verdicts go up and none go down.

Downloads

Platform Archive
Windows x64 / ARM64 maldocTrace_0.7.0_windows_amd64.zip, maldocTrace_0.7.0_windows_arm64.zip
Linux x64 / ARM64 maldocTrace_0.7.0_linux_amd64.tar.gz, maldocTrace_0.7.0_linux_arm64.tar.gz
macOS Intel / Apple Silicon maldocTrace_0.7.0_darwin_amd64.tar.gz, maldocTrace_0.7.0_darwin_arm64.tar.gz

Or install with pip install maldoctrace (also pipx / uv tool install): the wheels contain these same binaries.

You can verify downloads against checksums.txt (SHA-256), or check that an archive was built by the release workflow with gh attestation verify <archive> --repo debugactiveprocess/MaldocTrace. The binaries are static and have no dependencies. The macOS builds are not notarized, so remove the quarantine flag before running them: xattr -d com.apple.quarantine maldocTrace.

Added

  • Self-modifying and self-replicating macros (classic Word macro viruses, self-decrypting macros). The VBE object model is emulated: VBProject.VBComponents(...).CodeModule with Lines, CountOfLines, Find, ReplaceLine, InsertLines, DeleteLines and AddFromString, over the module's real source and an empty Normal.dotm (NormalTemplate). A macro that decrypts its own body and then calls it runs the decrypted code, and the decrypted lines are reported as decoded strings. Writes are reported as vba_code_write events, or as vba_template_infection events when they go into the global template. Options.VirusProtection / SaveNormalPrompt set to False are reported as security_setting_disabled. A code block inserted into a module (the copy a virus writes into Normal.dotm) is kept whole as an artifact of type VBA source (code module), with its SHA-256 also on the event (extra.artifact, extra.sha256), and --dump-payloads saves it as .txt. In text output, code-write events are summarised on one line, and a new Code revealed at run time section lists the lines the macro decrypted or generated, with their line numbers. Each module that revealed code is also delivered decoded: its source at the moment most of it was rewritten (the decrypted body in place, before the macro wipes it again), as an artifact that --dump-payloads saves. When that is the very copy the virus wrote into Normal.dotm, the same artifact says so instead of a duplicate.

  • vba_code_executed finding (medium): VBA absent from the stored source was written into one of the macro's own modules during emulation and then run (self-decrypting or self-generating macro). The vba_self_replication and vba_code_modification rules also run on code revealed during emulation, so a virus whose replication code is encrypted is still recognised.

  • vba_self_replication finding (malicious): the macro writes VBA code into Normal.dotm / Personal.xlsb through the VBE object model (VBProject.VBComponents(...).CodeModule.InsertLines / AddFromString), as macro viruses do to infect every document opened afterwards. Turning off Options.VirusProtection / SaveNormalPrompt is listed as evidence. vba_code_modification finding (low): the source writes VBA code through the VBE. It is low on its own because legitimate tools do this too: on 843 Office samples from MalwareBazaar (2026), it fired on Oracle Web ADI workbooks, which copy their modules into the workbooks they create, and on a UserForm generator. Both rules also run for --input-format vba.

  • RTF OLE Package objects now deliver the file they carry: it is extracted (name and original path in the finding) and analysed as an embedded file, so a VBScript dropped by an RTF is emulated and its commands are reported. On the 2026 corpus this extracts VBScript stagers and PE DLLs from about 20 RTF droppers.

  • PowerShell commands that decode a Base64 literal with [Convert]::FromBase64String, directly or through a variable assigned in the same -Command, now deliver the decoded text as a payload (UTF-8 or UTF-16LE; C# sources compiled in memory are labelled as such), and its URLs, domains and paths become indicators. A ScreenConnect dropper whose only network indicators were inside a Base64 C# loader now reports its relay and MSI download address (#24).

Changed

  • The default interpreter step budget is now 10 million steps (was 1 million), for documents and for plain-text scripts. Script loaders decode their next stage one character at a time and needed several million steps: with the old default, AgentTesla and AsyncRAT VBS loaders stopped before writing their second stage and were rated suspicious (30) with only junk indicators; they are now malicious with the stage recovered. On the 2026 corpus, ten Office droppers whose macro writes and starts a .js move from suspicious (25) to malicious (100) for the same reason. To keep the larger budget from multiplying, all the modules of a VBA project now share one step budget (it was per module), and emulation may use half of the analysis timeout (60 s with the default 120 s): a macro whose steps are slow, such as operations on very large strings, stops there and the rest of the analysis completes, instead of the whole file ending as timeout. When either budget runs out, the diagnostic and the verdict reasons now say that decoded stages may be missing and suggest a larger --max-steps or --timeout (#24).
  • Faster interpreter on the loops script loaders use, so that the larger budget costs little time: Mid, Left, Right, Len and InStr no longer convert the whole string to characters on every call (a loop of Mid(s, i, 1) over a large string was quadratic), a string built piece by piece (s = s & Chr(x)) is appended in place instead of being copied at every step, and ReDim Preserve a(UBound(a) + 1) grows the array in place. An AsyncRAT VBS loader now takes 0.6 s instead of 7 s, and an Office dropper that needed 145 s with the new budget takes 0.6 s. Analysing many files at once is no longer slowed down several times by memory traffic: on the 2026 corpus (1,021 files, 20 workers) no emulation reaches the time budget.

Fixed

  • -EncodedCommand was not decoded when PowerShell was started through cmd /c or %ComSpec%, as HTA droppers do ("%ComSpec%""/c POWErSHelL -eX BYPass -NOP -W 1 -Ec ...): the doubled quote made the whole command one argument, so it was not recognised as PowerShell. The interpreter wrapper is now removed before the command is examined, with abbreviated switches, mixed case and tabs between switches (#24).
  • URLs ended with a typographic quote (”) when a script used them as string delimiters, which PowerShell accepts.
  • Domain indicators no longer include .NET names (System.Net from System.Net.dll, System.IO, system.net.webclient) or fragments of Base64 and junk text (q.es, kwn2suoz.by, n7.kr): matches in random mixed case, one-character upper-case labels, parts of longer dotted identifiers and matches inside long encoded runs or punctuation-heavy text are dropped (#24).
  • InStr on non-ASCII text returned a byte offset instead of a character position.
  • --dump-payloads labelled every artifact as "file written by the macro", including objects embedded in the document (an altChunk RTF, an RTF OLE Package). The manifest kind now follows how the artifact was found: object embedded in the document, file written by the macro or script, or decoded payload (#24).
  • Single-line If statements: only the first statement after Then was conditional, the statements after a : always ran, and Else was read as a call to a procedure named "Else". A guard such as If x = "" Then MsgBox "...": Exit Sub therefore ended every procedure, and the rest of its code was never emulated. Colon-separated statements, Else branches and the If x Then: a: b Else: c form are now parsed as VBA does.
  • .docx droppers that pad an altChunk RTF past the 32 MiB part limit were reported clean. The RTF (about 54 MB of table junk around an Equation.3 object with \objupdate) was skipped with only an info diagnostic, and the import was not even counted. altChunk imports and OOXML embeddings are now read up to the input size limit (256 MiB), like a file of their own. One beyond every limit is still reported as an altchunk / embedded_ole finding and marks the analysis as limited, so it can no longer look clean. Found on two MalwareBazaar samples of 2026-11-24 and one in the 2026 corpus.
  • RTF \objdata decoding counted hex digits inside nested groups that switch to another destination. Droppers insert groups such as {\dao97556105\panose "function hexadeciamlTobinary(){...}"} in the object data: Word sends that text to \panose, but MaldocTrace read its hex letters as object bytes, so everything after them was shifted by a nibble and decoded as noise (a 3.6 KB Equation.3 object came out as 720 KB, and an OLE Package as an object with a corrupted header). Text after an RTF destination control word in a nested group is now ignored, as Word does. On the 2026 corpus this recovers 54 droppers' objects, including 5 CVE-2017-11882 Equation Editor exploits that were not detected.
  • Modules stored with bare CR line breaks (old macro viruses, some generators) were read as one line. This caused a false vba_stomping finding ("no procedures in its source") and wrong IOC line numbers. Line breaks are now normalised to CRLF when modules are extracted (also for --input-format vba).