Reading width
Wide uses the full column for everything, text, diagrams, code, and exercises. Narrow keeps the standard reading width.
Text size
Scales the body text. Headings and code blocks keep their size.
In this section
0.1 How Malware Reaches a Host Now
Introduction
Malware analysis starts with a file someone hands you, and that file is almost never the malware. It is the delivery: the attachment, the download or the shortcut that a person opened, and that carried the real program one or more layers further in. The route it took decides what you are holding, which control it got past, what the host recorded, and who else received the same thing.
This lesson sets out the routes malware takes onto a Windows host now and why they moved.
Office stopped running macros from the internet by default, so attackers turned to containers that shed the warning, to shortcuts, to web pages that build their payload inside the browser, to signed installers and finally to lures that have the user paste the command themselves. Then it opens one delivery chain layer by layer to its first stage, and checks an assistant's account of the same chain claim by claim.
The First File Is the Delivery
Why the route comes firstA host does not get infected by accident. Someone opened something, and the first look at that thing takes two commands: one says what the file is, whatever its name claims, and the other gives the hash every log will know it by.
$ file mw01-shared-document.html
mw01-shared-document.html: HTML document, ASCII text, with very long lines (65340)
$ sha256sum mw01-shared-document.html | cut -d' ' -f1
88d6512616a0606a16dcdae28858a4382c515fca27297cc164f9cfdd6aa7c551
The lab pack's first specimen is a web page with lines tens of thousands of characters long, which is not a page anyone wrote by hand. Before opening anything inside it, the hash goes into the mail gateway, proxy and endpoint searches, because the same lure almost always reached more than one person. That order, scope first and depth second, is the whole triage:
Triage of a delivery file. The first three steps happen before anything inside the file is opened, so the scope of the incident is known before its depth.
Analysts who skip to the payload tend to answer the wrong question well. They write a thorough report on what the final program does, nobody can say how it arrived, nothing changes at the edge, and the same chain lands again a week later with a new payload inside it.
Step 3 is usually three searches. The mail gateway gives every message that carried the file or linked to it, with sender, subject and recipients. The web proxy gives every user who fetched the same address. Endpoint telemetry gives every host that wrote a file with the same hash to disk, which is the list of machines to look at next, whether or not anyone there opened it.
The route is step 4, and it has changed more in the last few years than at any point before. Each change answered a control: when one door closed, attackers moved to the next one still open.
The routes in the order attackers moved to them. Each one gets past a control the one before it ran into, and the last gets past file checks altogether.
Almost every chain you will meet is one of these five, or several of them stacked. The rest of the lesson takes them in order, then opens a stacked one.
Macros Blocked by Default
The door that closedFor years the commonest first file was an Office document with a VBA macro, and the only protection was a bar asking whether to enable content. Microsoft changed the default so that Office blocks macros in files from the internet, calling VBA macros a common way for malicious actors to deploy malware and ransomware. How Office decides a file is from the internet is a procedure with one weak step:
How Office decides to block a macro. Every step depends on step 2, which is why every route after this one is built to skip it.
The mark is Mark-of-the-Web, a Zone.Identifier stream that Windows writes on browser downloads and email attachments from the Internet or Restricted sites zones. Microsoft's own example draws the line: ZoneId 2 for trusted sites leaves macros alone, and ZoneId 3 for the internet blocks them. The block covers Access, Excel, PowerPoint, Project, Publisher, Visio and Word on Windows, not Office on a Mac, on mobile or on the web.
Microsoft's page reads the mark in Notepad by opening the file name followed by :Zone.Identifier. In PowerShell on the host the same stream is read directly:
PS C:\> Get-Content -Path .\Invoice_4471.iso -Stream Zone.Identifier
The side brackets in the diagram are where the defense thins. The mark is only written on NTFS, not on FAT32 devices, and Microsoft lists routes that never add it, including Open in Desktop App from OneDrive or SharePoint and files the OneDrive sync client downloads.
A user can still clear it through the file's Properties and Unblock. A file that should carry the mark and does not is evidence in itself.
So the attacker's problem became simple to state: deliver something that never gets the mark, loses it on the way to the user, or does not need a macro at all. Every route after this one answers that problem.
For an analyst, the procedure turns into questions about the host as much as the file.
If a macro document ran on a Windows machine that blocks internet macros, either the file reached it without the mark, the mark was cleared, or the file came from a zone Office trusts. Each of those is a finding about how the file arrived, and each points to a different record: the download path, the user's actions on the file, or the zone settings.
Disk Images and Shortcuts
Losing the mark inside a containerThe first answer was a disk image. An ISO is a complete copy of a disc, file system included, and Windows mounts one as a new drive on a double-click. 7-Zip reads that file system without mounting it, which shows what the user would have seen in the new drive:
$ 7z l mw01-invoice.iso | tail -n 5
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2026-01-01 00:00:00 ..... 937 937 Invoice_4471.pdf.lnk
------------------- ----- ------------ ------------ ------------------------
2026-01-01 00:00:00 937 937 1 files
$ 7z x -y mw01-invoice.iso > /dev/null
One file, named as a PDF and ending in .lnk. In Explorer, which hides the shortcut extension, that is an invoice. Red Canary's explanation of why attackers moved to ISOs is that the image itself is marked when it is downloaded, but the files inside cannot be, because the disc's file system has no alternate data streams to hold the mark:
Where the mark is lost. The image is marked when it lands, and the file the user actually opens is not.
Microsoft patched a Mark-of-the-Web bypass, CVE-2022-41091, on 8 November 2022, and Red Canary reports that the fix mitigates the technique. Their other advice holds on any host: turn off automatic mounting of ISO and VHD files, block disk images in mail and at the web gateway, and watch the Microsoft-Windows-VHDMP-Operational log, which records image activity.
What sits inside is usually a shortcut. An LNK file names a target program, the arguments to start it with, an icon and a description, which is everything a delivery needs. LnkParse3, the lnkparse command in REMnux, prints every structure in it; four lines carry the point:
$ lnkparse Invoice_4471.pdf.lnk | grep -E 'Primary name|Description|Icon location'
Primary name: Windows
Primary name: System32
Primary name: WindowsPowerShell
Primary name: v1.0
Primary name: powershell.exe # ◄ the program it starts
Description: Invoice 4471 # ◄ shown on hover
Icon location: C:\Windows\System32\imageres.dll # ◄ a system icon
The target is spelled out one folder at a time down to powershell.exe, the description is what the user sees on hover, and the icon is borrowed from a system library so the shortcut looks like something else. The image got past the mark, the name and icon get past the user, and the target program does the work.
Those four fields are also what a defender writes down, because each one is something to search for. A shortcut whose name ends in a document extension before .lnk, a target that is a script host or a shell rather than an application, and arguments that hide the window and pass an encoded command are each unusual on their own.
Together, inside a disk image that arrived by mail or download, they describe this delivery route in a way a mail rule, an endpoint query or a YARA rule can match.
HTML Smuggling
A page that builds its own payloadA disk image attached to an email is easy for a gateway to block, so the next answer was to send a web page that builds the file instead.
MITRE ATT&CK describes HTML smuggling as hiding malicious payloads inside seemingly benign HTML files to get them past content filters, which see ordinary types such as text/html and may never look inside. The page assembles the file in the browser, after the last filter has looked:
HTML smuggling as a sequence. The file is assembled after the last filter has looked, inside the browser, from parts the filter saw as text.
The lab pack's page does exactly that, built inert: every layer is real, and the program at the end prints a marker. It is 85134 bytes, almost all of it one base64 string, and four calls in its script do the whole job:
$ grep -o -E 'atob|new Blob|createObjectURL|download = "[^"]*"' \
mw01-shared-document.html
atob # ◄ base64 text to bytes
createObjectURL # ◄ an address inside the browser
new Blob # ◄ the bytes as a file
download = "Invoice_4471.iso" # ◄ the name the browser saves
Nothing is fetched from anywhere: the next stage is already in the page. Taking it out by hand is the same three steps on the command line, and comparing hashes shows what came out:
$ grep -o 'var p = "[^"]*"' mw01-shared-document.html \
| cut -d'"' -f2 | base64 -d > Invoice_4471.iso
$ file Invoice_4471.iso
Invoice_4471.iso: ISO 9660 CD-ROM filesystem data ''
$ sha256sum Invoice_4471.iso mw01-invoice.iso
3c76db9cb34e46117d15bce72201b7843aa04ac55ddbdab79d409a91a61518cd Invoice_4471.iso
3c76db9cb34e46117d15bce72201b7843aa04ac55ddbdab79d409a91a61518cd mw01-invoice.iso
The two hashes match, so the page carries exactly the disk image from section 3, byte for byte. The mail gateway saw a web page; the user's browser saved an ISO.
MITRE's procedure examples show the same stacking in real intrusions. APT29 embedded an ISO in an HTML attachment whose JavaScript started the malware, its EnvyScout dropper writes an encoded blob from its HTML body to disk, and QakBot has arrived as ZIP files smuggled the same way.
The page is also where a smuggling chain is easiest to detect, because the four calls the script needs are present in plain text however the blob is encoded.
A page that decodes a long encoded string, wraps the result as a file and triggers a download of it has no ordinary reason to exist in a mail attachment. Lesson 0.10 writes that observation as a rule and measures it against clean pages, which is where a rule built on it either holds or fails.
Installers and Signed Packages
A download the warnings did not stopAnother route went for installers. App Installer used to accept an ms-appinstaller link that installed an MSIX package straight from a web page, and from mid-November 2023 Microsoft Threat Intelligence watched financially motivated actors use it to push signed malicious packages:
The App Installer route. The package never arrived as an ordinary download, so the checks built around downloads did not see it.
The lures were malicious ads for popular software, poisoned search results leading to spoofed download sites, and, for one actor, Microsoft Teams chats from tenants it created, with pages impersonating OneDrive and SharePoint.
Microsoft assessed the route was chosen because it can bypass SmartScreen and the browser warnings for executable downloads. Behind it came loaders such as BATLOADER, remote access tools such as NetSupport, Lumma and Redline stealers, and handoffs to Black Basta ransomware.
The packages were signed, and in Microsoft's examples the publisher did not match the software impersonated. A signature says who signed a file, not that it is safe, so the first check on a signed installer is whether the signer matches the product.
Microsoft turned the handler off by default on 28 December 2023, in App Installer 1.21.3421.0 and later, and in October 2024 added safeguards in 1.24.2411.0, including a SmartScreen reputation check on the download URL. MSRC's check for the version on a host:
PS C:\> (Get-AppxPackage Microsoft.DesktopAppInstaller).Version
Below 1.21.3421.0 the handler is still on by default, and the EnableMSAppInstallerProtocol policy can turn it back on at any version, so the host's settings are part of the evidence.
An installer that arrives this way is still a container to open. The analyst records the signer and compares it with the product the lure named, then looks inside the package for what it actually runs, which in Microsoft's cases was a loader or a remote access tool rather than the software advertised.
The signer is worth recording even when it is valid, because the same certificate tends to sign more than one package.
Paste-to-Run Lures
No file at allThe latest answer removes the file. Microsoft describes ClickFix as tricking users into running commands themselves by exploiting their habit of fixing small technical problems. The page copies a command to the clipboard while the user reads instructions to open the Run dialog, paste and press Enter:
A paste-to-run infection, with the step each of Microsoft's mitigations breaks. None of them depends on a file, because there is none.
Because a person launches the command, defenses built around files have nothing to inspect. Microsoft lists powershell, mshta, rundll32, wscript, curl and wget as the programs abused, PowerShell most of all. The lures arrive by phishing, by malicious ads and through compromised legitimate sites, and behind them Microsoft reports Lumma Stealer as the most prolific payload, with remote access tools and loaders, mostly run in memory, which is lesson 0.6.
The brackets in the diagram are Microsoft's mitigations, each placed at the step it breaks: web and network protection at the lure, the Run dialog disabled by Group Policy where nobody needs it, App Control and attack surface reduction rules at the program, and PowerShell script block logging to record what ran. With logging on, Windows PowerShell writes each script block to its Operational log as event 4104:
PS C:\> Get-WinEvent -LogName 'Microsoft-Windows-PowerShell/Operational' |
Where-Object Id -EQ 4104 |
Select-Object -First 5 TimeCreated, Message
For an analyst, that log is the closest thing a paste-to-run infection has to a first file. The command is in it as it ran, beside the process record of the program that started it.
The record to keep from a paste-to-run infection therefore comes from the host, not a sample: the script block text, the program that ran it and its parent, the time, and the lure page the user was on, which usually has to come from the user or the browser's history.
With those, the lure can be blocked and the other users who reached the same page found through the proxy, the same scoping step as for a file.
Opening the Specimen Layer by Layer
From the shortcut to the first commandThe shortcut section 3 extracted is the last layer before code runs. Its arguments are long enough to need folding to read:
$ lnkparse -j Invoice_4471.pdf.lnk | jq -r .data.command_line_arguments | fold -w 60
-NoProfile -WindowStyle Hidden -EncodedCommand VwByAGkAdABlA # ◄ hidden, no profile
C0ATwB1AHQAcAB1AHQAIAAiAFIASQBEAEcARQBMAEkATgBFAC0AUwBQAEUAQ
wBJAE0ARQBOACAAbQB3ADAAMQAgAHMAdABhAGcAZQA6ACAAaQBuAGUAcgB0A
CIA
PowerShell, no profile, a hidden window and an encoded command. Encoded commands are base64 of UTF-16LE text, so decoding takes two steps, and the result is saved as a script to read rather than run:
$ lnkparse -j Invoice_4471.pdf.lnk | jq -r .data.command_line_arguments \
| awk '{print $NF}' | base64 -d | iconv -f UTF-16LE -t UTF-8 > stage1.ps1
The file holds one line of PowerShell, the command the shortcut hands to the hidden window:
Write-Output "RIDGELINE-SPECIMEN mw01 stage: inert"
That is the first stage, and in this specimen it prints the lab pack's marker. In a real chain this line would be a download, a decoder or a loader, and the analysis would continue into it, which is where lesson 0.2 picks up. With it read, every layer of the chain is accounted for:
The specimen's chain. Four layers sit between the file that arrived and the command that runs, and the analysis stops at the command because it says what it does.
The rule for when to stop is the same in every chain: stop peeling layers when you reach code that runs and you can say what it does. Every layer before it was the delivery, and each one named the tool that opens the next.
In a real chain the first stage is where the questions change. A download line gives a host and a path to scope, a decoder gives the next layer to open with the same method, and a loader means the payload is still ahead, which lesson 0.2 takes up. The delivery record, meanwhile, is finished: each layer, the tool that opened it, and the output that proved it.
Working With the Assistant
Prompt, session, recordAn assistant makes this chain quicker to open, and how much quicker depends mostly on the first prompt. Asked for a verdict, it gives one:
- It is an HTML smuggling dropper.
- It downloads a second-stage payload from a remote server and runs it in memory.
- Block the sender and quarantine the file.
That answer is a verdict with nothing behind it. It skips every layer, and its second line describes what droppers usually do rather than what this one does. The prompt that gets useful work names the evidence, the method, the question and the boundary:
- mw01-shared-document.html in REMnuxnames the evidence and where it is, so every step is a command on it
- a link to a shared documentgives the context: a delivery, so the job is the route, not a verdict
- layer by layersets the method: each layer opened with the tool the last one names
- the first code that would runkeeps to one question, and says where to stop
- Nothing from the sample is to runsets the boundary the analyst will hold it to
- wait for its outputmakes each step rest on output you have seen, not on what chains usually do
With that prompt the assistant works the chain with you, one command at a time, and each answer rests on the output of the last step rather than on what chains like this usually do:
- YouI have mw01-shared-document.html in REMnux, a file a user downloaded from a link to a shared document. Help me open the delivery chain layer by layer, down to the first code that would run. Nothing from the sample is to run. Give me one command at a time and wait for its output before the next step.
- AssistantStart without opening anything: what the file is, then the calls an HTML smuggling page needs. Hash it for the mail and proxy searches while you are there.
- REMnux
$ file -b mw01-shared-document.html | cut -d, -f1 HTML document $ sha256sum mw01-shared-document.html | cut -c1-64 88d6512616a0606a16dcdae28858a4382c515fca27297cc164f9cfdd6aa7c551 $ grep -o -E 'atob|new Blob|createObjectURL|download = "[^"]*"' \ mw01-shared-document.html | sort -u atob createObjectURL download = "Invoice_4471.iso" new Blob - AssistantIt decodes base64 into a Blob and saves it as Invoice_4471.iso. The quickest way to get that file is to open the page in Firefox inside REMnux and let the download happen.
- YouThat runs the page's script. Can we get the ISO out without running anything?
- AssistantYes. The base64 is the string in var p. Cut it out and decode it, then list the image without mounting it.
- REMnux
$ grep -o 'var p = "[^"]*"' mw01-shared-document.html \ | cut -d'"' -f2 | base64 -d > Invoice_4471.iso $ 7z l Invoice_4471.iso | grep -F .lnk 2026-01-01 00:00:00 ..... 937 937 Invoice_4471.pdf.lnk $ 7z x -y Invoice_4471.iso > /dev/null - AssistantOne shortcut named as a PDF. Print the arguments it passes to its target.
- REMnux
$ lnkparse -j Invoice_4471.pdf.lnk \ | jq -r .data.command_line_arguments | cut -c1-60 -NoProfile -WindowStyle Hidden -EncodedCommand VwByAGkAdABlA - AssistantHidden PowerShell with an encoded command. -EncodedCommand is base64 of UTF-16LE text, so decode it with iconv and write it to a file to read rather than run.
- REMnux
$ lnkparse -j Invoice_4471.pdf.lnk | jq -r .data.command_line_arguments \ | awk '{print $NF}' | base64 -d | iconv -f UTF-16LE -t UTF-8 > stage1.ps1 $ wc -l stage1.ps1 0 stage1.ps1 - AssistantOne line, saved as a script you can read without running. Open it in a viewer, not in PowerShell.
- REMnux
Write-Output "RIDGELINE-SPECIMEN mw01 stage: inert" - AssistantThe first stage prints a marker and fetches nothing, so the chain ends here: an HTML page smuggling a disk image, a shortcut inside it, and a hidden PowerShell command. Do you want the delivery record?
Most of the assistant's suggestions ran as given. One did not: opening the page in a browser would have run the sample's script, which the prompt ruled out, and saying so got a static way to the same file in one more turn.
That is the normal shape of working with an assistant. Its suggestions are usually sound, the analyst decides which to run, and a short reply that restates the boundary is all the steering it needs.
The time it saved is in the details. The carving line and the decode, base64 of UTF-16LE text through iconv, are each a minute's lookup done by hand, and the assistant supplied both at the point they were needed. Its last offer, the delivery record, is worth taking: layer by layer with the tool and the output behind each, it is the part analysts most often leave unwritten.
Before the record goes in a report, the analyst checks the claims the decision rests on, which here are few and quick to check:
What the report rests on
Both of the first two are already on the page, so the check takes seconds. The third is the one an assistant should not answer from the file, and the record sends it to the host owner. Lesson 0.8 sets out where assistants need steering in this work and how to steer them.
Practice
How did this reach the host? prepared evidenceThe scenario below holds the working session and the output of each tool run in this lesson. Choose the prompt, decide what to do with the assistant's suggestions, then name the route and the control that would have broken it.
In the lab, run the same commands on mw01-shared-document.html from the lab pack in your REMnux machine, then work the chain in OpenCode, started in the pack's lab folder, using the prompt above, and steer it the same way when it suggests running the sample. The specimen's known answer is in the pack's answer key, answer-key/answers.json.
Malware reaches a host through a route, and the route moved each time a control closed the last one: from macro documents to disk images and shortcuts that shed the mark, to pages that build the file in the browser, to signed installers that slipped past the download warnings, and to lures that have the user paste the command so there is no file at all.
Reading the route first tells you what you hold, which control failed and where the other recipients are, and opening each layer with the tool its predecessor names gets you to the first stage with every step backed by an output.
Resources
Vendors and projects revise these pages; where a page and this lesson disagree, the page is newer.
- Microsoft Learn: Macros from the internet are blocked by default in Office
- Red Canary, on Zscaler: Why so, ISO? Mark-of-the-Web, explained
- MITRE ATT&CK: T1027.006 HTML Smuggling
- Microsoft Security Blog: Financially motivated threat actors misusing App Installer
- MSRC: Microsoft addresses App Installer abuse
- Microsoft Security Blog: Think before you Click(Fix)
- Microsoft Learn: about_Logging_Windows