Detect Command and Scripting Interpreter in Google Chronicle
Adversaries may abuse command and script interpreters to execute commands, scripts, or binaries. These interfaces and languages provide ways of interacting with computer systems and are a common feature across many different platforms. Most systems come with some built-in command-line interface and scripting capabilities, for example, macOS and Linux distributions include some flavor of Unix Shell while Windows installations include the Windows Command Shell and PowerShell. There are also cross-platform interpreters such as Python, as well as those commonly associated with client applications such as JavaScript and Visual Basic. Adversaries may abuse these technologies in various ways as a means of executing arbitrary commands.
MITRE ATT&CK
- Tactic
- Execution
- Technique
- T1059 Command and Scripting Interpreter
- Canonical reference
- https://attack.mitre.org/techniques/T1059/
YARA-L Detection Query
rule t1059_scripting_interpreter_suspicious_parent {
meta:
author = "Argus Detection Engineering"
description = "Detects command and scripting interpreters spawned by suspicious parent processes including Office apps, WMI, and svchost (MITRE ATT&CK T1059)"
mitre_attack_tactic = "Execution"
mitre_attack_technique = "T1059"
severity = "HIGH"
confidence = "HIGH"
events:
$e.metadata.event_type = "PROCESS_LAUNCH"
$e.principal.process.file.full_path = /(?i)(powershell\.exe|pwsh\.exe|cmd\.exe|wscript\.exe|cscript\.exe|mshta\.exe|python\.exe|python3\.exe|perl\.exe|ruby\.exe|lua\.exe|node\.exe|AutoHotkey\.exe|AutoIt3\.exe)$/
$e.principal.process.parent_process.file.full_path = /(?i)(winword\.exe|excel\.exe|powerpnt\.exe|outlook\.exe|msaccess\.exe|mspub\.exe|visio\.exe|onenote\.exe|explorer\.exe|wmiprvse\.exe|svchost\.exe)$/
condition:
$e
} Chronicle YARA-L 2.0 rule detecting scripting interpreter binaries (PowerShell, cmd, WScript, Python, Node.js, etc.) launched by suspicious parent processes including Microsoft Office applications, WMI provider host (wmiprvse.exe), and svchost.exe. Triggers on UDM PROCESS_LAUNCH events matching the parent-child process relationship indicative of macro execution, WMI abuse, or service-spawned interpreter activity.
Data Sources
Required Tables
False Positives & Tuning
- Legitimate scheduled tasks registered under svchost service groups that invoke PowerShell or cmd.exe for maintenance operations such as disk cleanup or log rotation
- Office-integrated business intelligence tools (Power Query, Excel macros for data refresh) that launch Python or PowerShell as part of sanctioned data pipeline workflows
- WMI-based monitoring solutions (e.g., SCCM hardware inventory, Dell OpenManage) that use wmiprvse.exe to spawn scripting engines for asset discovery
Other platforms for T1059
Testing Methodology
Validate this detection against 3 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 1Office Macro Simulation — Word spawns PowerShell
Expected signal: Sysmon Event ID 1: Process Create for cmd.exe spawning powershell.exe. Security Event ID 4688 with command line details showing the full chain.
- Test 2WScript Execution of VBScript File
Expected signal: Sysmon Event ID 1: Process Create with Image=wscript.exe and CommandLine containing the .vbs file path. Sysmon Event ID 11: File Create for the .vbs file in the temp directory.
- Test 3MSHTA Executing Inline VBScript
Expected signal: Sysmon Event ID 1: Process Create with Image=mshta.exe and CommandLine containing 'vbscript:Execute'. Child process creation event for calc.exe spawned by mshta.exe.
References (6)
- https://attack.mitre.org/techniques/T1059/
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-deviceprocessevents-table
- https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/CommonStatsFunctions
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1059/T1059.md
- https://github.com/SigmaHQ/sigma/tree/master/rules/windows/process_creation
- https://lolbas-project.github.io/
Unlock Pro Content
Get the full detection package for T1059 including response playbook, investigation guide, and atomic red team tests.