T1204.002
Malicious File
Adversaries rely on users opening malicious files to gain code execution. Files delivered via spearphishing attachments or placed in shared directories include .doc, .xls, .pdf, .rtf, .scr, .exe, .lnk, .pif, .cpl, .iso, and others. Social engineering lures users into enabling macros, extracting archives, or double-clicking payloads. Execution typically manifests as an Office application, PDF reader, or shell process spawning a scripting engine, command interpreter, or LOLBin as a child process.
Microsoft Sentinel / Defender
kusto
let OfficeApps = dynamic(["winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe", "onenote.exe", "mspub.exe", "visio.exe", "wordpad.exe", "acrord32.exe", "foxitreader.exe", "sumatra.exe"]);
let SuspiciousChildren = dynamic(["cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "regsvr32.exe", "certutil.exe", "bitsadmin.exe", "msbuild.exe", "wmic.exe", "installutil.exe", "regasm.exe", "regsvcs.exe", "cmstp.exe", "explorer.exe", "schtasks.exe", "at.exe", "net.exe", "netsh.exe", "curl.exe", "wget.exe"]);
let SuspiciousPaths = dynamic(["\\AppData\\Local\\Temp\\", "\\AppData\\Roaming\\", "\\Downloads\\", "\\Desktop\\", "\\Public\\", "\\Temp\\", "\\Windows\\Temp\\"]);
// Branch 1: Office/PDF apps spawning suspicious child processes (macro/script execution)
let OfficeSuspawnBranch = DeviceProcessEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName has_any (OfficeApps)
| where FileName has_any (SuspiciousChildren)
| extend DetectionBranch = "Office_SuspiciousChildSpawn"
| extend RiskIndicator = strcat(InitiatingProcessFileName, " -> ", FileName);
// Branch 2: Script files (VBS/JS/HTA/WSF) executing from user writeable paths
let ScriptExecBranch = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("wscript.exe", "cscript.exe", "mshta.exe")
| where ProcessCommandLine has_any (SuspiciousPaths)
or ProcessCommandLine matches regex @"(?i)\.(vbs|vbe|js|jse|wsf|hta|ps1)[\"\'\s]?"
| extend DetectionBranch = "Script_UserPathExecution"
| extend RiskIndicator = strcat(FileName, ": ", ProcessCommandLine);
// Branch 3: LNK or ISO-based execution (shell spawning from mounted image or lnk shortcut)
let LnkIsoBranch = DeviceProcessEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName =~ "explorer.exe"
| where ProcessCommandLine has_any (SuspiciousChildren)
| where FolderPath has_any (SuspiciousPaths)
or InitiatingProcessCommandLine has ".lnk"
or FolderPath matches regex @"[A-Z]:\\[A-Z0-9]{1,4}\\"
| extend DetectionBranch = "LnkIso_ShellExecution"
| extend RiskIndicator = strcat("Explorer child: ", FileName, " from ", FolderPath);
// Branch 4: Executable dropped to temp/download path and immediately launched
let DroppedExecBranch = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FolderPath has_any (SuspiciousPaths)
| where FileName matches regex @"(?i)\.(exe|scr|pif|cpl|com)$"
| where InitiatingProcessFileName has_any (OfficeApps)
or InitiatingProcessFileName in~ ("explorer.exe", "winrar.exe", "7z.exe", "7zg.exe", "winzip32.exe")
| extend DetectionBranch = "Dropped_ExecutableRun"
| extend RiskIndicator = strcat("Dropped binary: ", FileName, " path: ", FolderPath);
union OfficeSuspawnBranch, ScriptExecBranch, LnkIsoBranch, DroppedExecBranch
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine, FolderPath,
DetectionBranch, RiskIndicator
| sort by Timestamp desc high severity
high confidence
Data Sources
Process: Process Creation File: File Creation Microsoft Defender for Endpoint
Required Tables
DeviceProcessEvents
False Positives
- Legitimate macro-enabled documents used by finance or HR teams that spawn cmd.exe or PowerShell for approved business automation
- IT software installation packages that extract and run executables from the user's Downloads or Temp folder (e.g., offline installers)
- PDF forms with embedded JavaScript that invoke Acrobat helper processes for printing or submission
- Developer toolchains that invoke build scripts (MSBuild, cscript) from project directories under AppData
Last updated: 2026-04-19 Research depth: deep
References (10)
- https://attack.mitre.org/techniques/T1204/002/
- https://www.bleepingcomputer.com/news/security/psa-dont-open-spam-containing-password-protected-word-docs/
- https://www.mandiant.com/resources/blog/trojanized-windows-installers-ukrainian-government
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-deviceprocessevents-table
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-devicefileevents-table
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1204.002/T1204.002.md
- https://github.com/SigmaHQ/sigma/tree/master/rules/windows/process_creation
- https://www.cybereason.com/blog/threat-analysis-report-all-paths-lead-to-cobalt-strike-how-to-protect-against-this-malware
- https://unit42.paloaltonetworks.com/threat-assessment-north-korean-threat-groups/
- https://docs.microsoft.com/en-us/deployoffice/security/internet-macros-blocked
Unlock Pro Content
Get the full detection package for T1204.002 including response playbook, investigation guide, and atomic red team tests.
Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance