Detect Scripting in Splunk
Adversaries may use scripts to aid in operations and perform multiple actions that would otherwise be manual. This deprecated technique (now superseded by T1059 Command and Scripting Interpreter) covered adversary use of scripting languages including VBScript, JavaScript, Windows Script Host, batch scripts, and macro-enabled Office documents. Scripts can be used to speed up operations, bypass process monitoring by interacting with the OS at an API level, and enable execution via spearphishing attachments containing malicious macros. Common attack patterns include VBScript/JScript execution via wscript.exe or cscript.exe, malicious Office macros spawning child processes, and batch scripts performing reconnaissance or lateral movement.
MITRE ATT&CK
- Tactic
- Defense Evasion Execution
- Canonical reference
- https://attack.mitre.org/techniques/T1064/
SPL Detection Query
index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
| eval FileName=lower(mvindex(split(Image, "\\"), -1))
| eval ParentFileName=lower(mvindex(split(ParentImage, "\\"), -1))
| eval CommandLineLower=lower(CommandLine)
| eval ParentCommandLineLower=lower(ParentCommandLine)
`comment("--- Detection Branch 1: Office spawning script interpreters (macro execution) ---")`
| eval OfficeMacroSpawn=if(
(ParentFileName IN ("winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe", "onenote.exe", "access.exe"))
AND (FileName IN ("wscript.exe", "cscript.exe", "mshta.exe", "cmd.exe", "powershell.exe", "pwsh.exe", "regsvr32.exe", "rundll32.exe")),
1, 0)
`comment("--- Detection Branch 2: Suspicious wscript/cscript arguments ---")`
| eval SuspiciousScriptInterp=if(
(FileName IN ("wscript.exe", "cscript.exe"))
AND (match(CommandLineLower, "(invoke-expression|iex\(|downloadstring|downloadfile|net\.webclient|createobject|shell\.application|shellexecute|wscript\.shell|http:\/\/|https:\/\/|certutil|bitsadmin)")
OR match(CommandLine, "(?i)\.(vbs|vbe|js|jse|wsf|wsh|hta)")),
1, 0)
`comment("--- Detection Branch 3: MSHTA running remote or inline scripts ---")`
| eval MshtaAbuse=if(
FileName="mshta.exe"
AND match(CommandLineLower, "(vbscript:|javascript:|http:\/\/|https:\/\/|\/\/|\\\\\\\\)"),
1, 0)
`comment("--- Detection Branch 4: Cmd.exe with obfuscation spawned from Office or running LOLBin chains ---")`
| eval CmdBatchAbuse=if(
FileName="cmd.exe"
AND (
(ParentFileName IN ("winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe", "onenote.exe"))
OR (match(CommandLineLower, "(\^\^|&&|\|\|)") AND match(CommandLineLower, "(http|certutil|bitsadmin|powershell|wscript|cscript)"))
),
1, 0)
| eval TotalScore=OfficeMacroSpawn + SuspiciousScriptInterp + MshtaAbuse + CmdBatchAbuse
| where TotalScore > 0
| eval DetectionTypes=mvappend(
if(OfficeMacroSpawn=1, "OfficeMacroSpawn", null()),
if(SuspiciousScriptInterp=1, "SuspiciousScriptInterp", null()),
if(MshtaAbuse=1, "MshtaAbuse", null()),
if(CmdBatchAbuse=1, "CmdBatchAbuse", null()))
| table _time, host, User, Image, CommandLine, ParentImage, ParentCommandLine,
OfficeMacroSpawn, SuspiciousScriptInterp, MshtaAbuse, CmdBatchAbuse, TotalScore, DetectionTypes
| sort - _time Detects scripting-based attack patterns using Sysmon Event ID 1 (Process Creation). Evaluates four detection branches: Office macro-spawned processes, suspicious wscript/cscript execution with download or shell patterns, mshta.exe running remote or inline script content, and cmd.exe running LOLBin chains or spawned from Office applications. Assigns per-branch flags and a total score to help analysts prioritize. Events with any positive branch flag are surfaced.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Legitimate software installers that use VBScript (wscript.exe) for install/uninstall automation, particularly older enterprise applications
- IT administration scripts run via Group Policy or SCCM that use cscript.exe or wscript.exe for inventory or configuration tasks
- Office add-ins and COM automation tools that legitimately spawn child processes from Word or Excel (e.g., mail-merge workflows, report generators)
- Help desk and remote support tools (ConnectWise, TeamViewer) that may spawn cmd.exe or scripts from unusual parent processes
- Security scanners and vulnerability assessment tools that invoke mshta.exe or script interpreters during active scanning
Other platforms for T1064
Testing Methodology
Validate this detection against 5 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1VBScript Download Cradle via wscript.exe
Expected signal: Sysmon Event ID 1: Process Create with Image=wscript.exe, CommandLine referencing df00tech_test.vbs. Sysmon Event ID 3: Network connection attempt to 127.0.0.1:8080 from wscript.exe (connection will fail). Sysmon Event ID 11: File creation of df00tech_test.vbs in %TEMP%.
- Test 2JScript Execution via cscript.exe with Shell Command
Expected signal: Sysmon Event ID 1: Process Create for cscript.exe with CommandLine referencing df00tech_shell.js. Sysmon Event ID 1 (child): cmd.exe spawned by cscript.exe with 'whoami' command. Sysmon Event ID 11: Output file creation in %TEMP%.
- Test 3MSHTA Remote HTA Execution
Expected signal: Sysmon Event ID 1: Process Create with Image=mshta.exe, CommandLine='mshta.exe http://127.0.0.1:8080/df00tech_test.hta'. Sysmon Event ID 3: Network connection attempt to 127.0.0.1:8080 (will fail — no listener). The process creation event fires regardless of connection success.
- Test 4Simulated Office Macro Child Process (cmd.exe spawned from Word context)
Expected signal: Sysmon Event ID 1: powershell.exe process create followed by cmd.exe child process. Security Event ID 4688 (if command line auditing enabled) for both processes. To fully test the OfficeMacroSpawn detection branch, the test would need to originate from a running winword.exe process — this simulation exercises the cmd.exe execution and output paths.
- Test 5VBScript Inline Execution via mshta vbscript: Protocol
Expected signal: Sysmon Event ID 1: Process Create with Image=mshta.exe, CommandLine containing 'vbscript:Execute'. A dialog box will appear briefly — dismiss it. No network connections or file writes are expected for this test variant.
References (11)
- https://attack.mitre.org/techniques/T1064/
- https://attack.mitre.org/techniques/T1059/
- https://www.uperesia.com/analyzing-malicious-office-documents
- https://blog.crowdstrike.com/deep-thought-chinese-targeting-national-security-think-tanks/
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1064/T1064.md
- https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4688
- https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon
- https://github.com/SigmaHQ/sigma/tree/master/rules/windows/process_creation
- https://www.fireeye.com/blog/threat-research/2019/10/staying-hidden-on-the-endpoint-evading-detection-with-shellcode.html
- https://lolbas-project.github.io/lolbas/Binaries/Mshta/
- https://github.com/mandiant/OfficeMalScanner
Unlock Pro Content
Get the full detection package for T1064 including response playbook, investigation guide, and atomic red team tests.