Detection rules › Elastic
Command and Scripting Interpreter from Suspicious Parent
Identifies when a script interpreter is executed with a long command line and from an unsigned parent executable.
MITRE ATT&CK coverage
Rule body
[rule]
description = "Identifies when a script interpreter is executed with a long command line and from an unsigned parent executable."
id = "61b8b978-847b-4b1f-9771-b646cde53a9a"
license = "Elastic License v2"
name = "Command and Scripting Interpreter from Suspicious Parent"
os_list = ["windows"]
version = "1.0.6"
query = '''
sequence with maxspan=1m
[process where event.action == "start" and not user.id : "S-1-5-18" and
(
(process.Ext.device.product_id : ("Virtual DVD-ROM", "Virtual Disk", "USB *") and
not process.executable : "C:\\*") or
((process.Ext.relative_file_creation_time <= 900 or process.Ext.relative_file_name_modify_time <= 900) and
not process.code_signature.status : ("trusted", "errorExpired", "errorCode_endpoint*") and
not process.executable : ("?:\\Program Files (x86)\\*", "?:\\Program Files\\*")) or
(process.executable :
("?:\\Users\\*\\AppData\\*",
"?:\\Users\\*\\Downloads\\*",
"?:\\Users\\*\\Desktop\\*",
"?:\\Users\\Public\\*") and not process.code_signature.status : ("trusted", "errorExpired", "errorCode_endpoint*"))
) and
not process.parent.executable : "C:\\Program Files\\Microsoft Visual Studio\\*\\VsDebugConsole.exe"
] by process.entity_id
[process where event.action == "start" and process.name : ("cmd.exe", "powershell.exe") and
length(process.command_line) >= 200 and not process.args : ("?:\\Program Files\\*", "?:\\Program Files (x86)\\*") and
not (process.args : "-InputFormat" and process.args : "-command") and
not process.args : "UwB0AGEAcgB0ACAAIgBoAHQAdABw*" and
process.command_line : ("*New-ScheduledTaskAction*", "*New-ItemProperty*", "*WScript.Shell*", "*schtasks* /create*",
"*\\Start Menu\\Programs\\*", "*CurrentVersion\\Run*", "*.Invoke(*", "*MpPreference*",
"*-EncodedCommand*", "*Get-Content*", "*Windows Defender*", "*powershell* -e *", "*setZeroData*",
"*Get-Clipboard*", "*http* -xf *", "*dns-query?name=*")
] by process.parent.entity_id
'''
min_endpoint_version = "8.4.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1
[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.001"
name = "PowerShell"
reference = "https://attack.mitre.org/techniques/T1059/001/"
[[threat.technique.subtechnique]]
id = "T1059.003"
name = "Windows Command Shell"
reference = "https://attack.mitre.org/techniques/T1059/003/"
[[threat.technique.subtechnique]]
id = "T1059.007"
name = "JavaScript"
reference = "https://attack.mitre.org/techniques/T1059/007/"
[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[internal]
min_endpoint_version = "8.4.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 1m, correlated by process.entity_id, process.parent.entity_id.
Stage 1: process
[process where event.action == "start" and not user.id : "S-1-5-18" and
(
(process.Ext.device.product_id : ("Virtual DVD-ROM", "Virtual Disk", "USB *") and
not process.executable : "C:\\*") or
((process.Ext.relative_file_creation_time <= 900 or process.Ext.relative_file_name_modify_time <= 900) and
not process.code_signature.status : ("trusted", "errorExpired", "errorCode_endpoint*") and
not process.executable : ("?:\\Program Files (x86)\\*", "?:\\Program Files\\*")) or
(process.executable :
("?:\\Users\\*\\AppData\\*",
"?:\\Users\\*\\Downloads\\*",
"?:\\Users\\*\\Desktop\\*",
"?:\\Users\\Public\\*") and not process.code_signature.status : ("trusted", "errorExpired", "errorCode_endpoint*"))
) and
not process.parent.executable : "C:\\Program Files\\Microsoft Visual Studio\\*\\VsDebugConsole.exe"
] by process.entity_id
Stage 2: process
[process where event.action == "start" and process.name : ("cmd.exe", "powershell.exe") and
length(process.command_line) >= 200 and not process.args : ("?:\\Program Files\\*", "?:\\Program Files (x86)\\*") and
not (process.args : "-InputFormat" and process.args : "-command") and
not process.args : "UwB0AGEAcgB0ACAAIgBoAHQAdABw*" and
process.command_line : ("*New-ScheduledTaskAction*", "*New-ItemProperty*", "*WScript.Shell*", "*schtasks* /create*",
"*\\Start Menu\\Programs\\*", "*CurrentVersion\\Run*", "*.Invoke(*", "*MpPreference*",
"*-EncodedCommand*", "*Get-Content*", "*Windows Defender*", "*powershell* -e *", "*setZeroData*",
"*Get-Clipboard*", "*http* -xf *", "*dns-query?name=*")
] by process.parent.entity_id
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.parent.executable | wildcard | C:\Program Files\Microsoft Visual Studio\*\VsDebugConsole.exe | excludes:process.parent.executable field:"process.parent.executable" value:"C:\Program Files\Microsoft Visual Studio\*\VsDebugConsole.exe" |
user.id | eq | S-1-5-18 | excludes:user.id field:"user.id" value:"S-1-5-18" |
process.args | eq | -InputFormat | excludes:process.args field:"process.args" value:"-InputFormat" |
process.args | eq | -command | excludes:process.args field:"process.args" value:"-command" |
process.args | starts_with | ?:\Program Files\, ?:\Program Files (x86)\ | excludes:process.args field:"process.args" value:"?:\Program Files\" field:"process.args" value:"?:\Program Files (x86)\" |
process.args | starts_with | UwB0AGEAcgB0ACAAIgBoAHQAdABw | excludes:process.args field:"process.args" value:"UwB0AGEAcgB0ACAAIgBoAHQAdABw" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"start" |
process.Ext.device.product_id | wildcard |
| field:"process.Ext.device.product_id" kind:wildcard |
process.Ext.relative_file_creation_time | le |
| field:"process.Ext.relative_file_creation_time" kind:le value:"900" |
process.Ext.relative_file_name_modify_time | le |
| field:"process.Ext.relative_file_name_modify_time" kind:le value:"900" |
process.command_line | wildcard |
| field:"CommandLine" kind:wildcard |
process.executable | wildcard |
| field:"Image" kind:wildcard |
process.name | wildcard |
| field:"process_name" kind:wildcard |