Detection rules › Elastic

Inhibit System Recovery via Windows Command Shell

Time window
1m
Sequence by
process.entity_id, process.parent.entity_id
Source
github.com/elastic/protections-artifacts

Identifies the execution of Windows utilities to tamper with system recovery settings. Adversaries may delete or remove built-in operating system data and turn off services designed to aid in the recovery of a corrupted system and prevent recovery.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the execution of Windows utilities to tamper with system recovery settings. Adversaries may delete or remove
built-in operating system data and turn off services designed to aid in the recovery of a corrupted system and prevent
recovery.
"""
id = "d3588fad-43ae-4f2d-badd-15a27df72133"
license = "Elastic License v2"
name = "Inhibit System Recovery via Windows Command Shell"
os_list = ["windows"]
version = "1.0.34"

query = '''
sequence with maxspan=1m
  [process where event.action == "start" and process.name : "cmd.exe" and
    not process.parent.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe") and
    not (process.args : "\\\\*\\SysVol\\*\\Policies\\{*}\\*" and process.parent.executable : "?:\\Windows\\System32\\gpscript.exe") and
    not process.command_line : ("*\\\\*\\*.cmd*", "*\\\\*\\*.bat*") and 
    not descendant of [process where event.action == "start" and process.executable : "?:\\Windows\\System32\\gpscript.exe"] and
    not (process.parent.executable : "?:\\Windows\\System32\\wbem\\WmiPrvSE.exe" and
         user.id == "S-1-5-18" and process.args : "BOOTSTATUSPOLICY") and
    not (user.id == "S-1-5-18" and process.parent.executable : ("C:\\$VcmsTemp$\\VcmsPush.exe", "C:\\windows\\ctsrsvc.exe"))
  ] by process.entity_id
  [process where event.action == "start" and
    (
     (process.pe.original_file_name : "wmic.exe" and process.command_line : "*shadowcopy*" and process.command_line : "*delete*") or
     (process.pe.original_file_name : "vssadmin.exe" and process.command_line : "*shadows*" and process.command_line : ("*delete*", "*resize*401*")) or
     (process.pe.original_file_name : "bcdedit.exe" and process.command_line : ("*bootstatuspolicy*", "*recoveryenabled*")) or
     (process.pe.original_file_name : "wbadmin.exe" and process.command_line : ("*catalog*", "*systemstatebackup*") and process.command_line : "*delete*")
    ) and
    /* noisy FP patterns */
    not (process.name : "bcdedit.exe" and process.args : "DisplayAllFailures") and
    not (process.name : "wbadmin.exe" and process.args : "-keepVersions*") and
    not (process.name : "bcdedit.exe" and process.command_line: "*recoveryenabled*yes*") and
    /* granular deletion of a shadowcopy by unique ID often seen in legit deletion */
    not (process.name : "vssadmin.exe" and process.command_line : "*/shadow=*")
  ] by process.parent.entity_id
'''

min_endpoint_version = "7.15.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
tree = true

[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1

[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 1

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1047"
name = "Windows Management Instrumentation"
reference = "https://attack.mitre.org/techniques/T1047/"

[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.003"
name = "Windows Command Shell"
reference = "https://attack.mitre.org/techniques/T1059/003/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1490"
name = "Inhibit System Recovery"
reference = "https://attack.mitre.org/techniques/T1490/"


[threat.tactic]
id = "TA0040"
name = "Impact"
reference = "https://attack.mitre.org/tactics/TA0040/"

[internal]
min_endpoint_version = "7.15.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 process.name : "cmd.exe" and
    not process.parent.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe") and
    not (process.args : "\\\\*\\SysVol\\*\\Policies\\{*}\\*" and process.parent.executable : "?:\\Windows\\System32\\gpscript.exe") and
    not process.command_line : ("*\\\\*\\*.cmd*", "*\\\\*\\*.bat*") and 
    not descendant of [process where event.action == "start" and process.executable : "?:\\Windows\\System32\\gpscript.exe"] and
    not (process.parent.executable : "?:\\Windows\\System32\\wbem\\WmiPrvSE.exe" and
         user.id == "S-1-5-18" and process.args : "BOOTSTATUSPOLICY") and
    not (user.id == "S-1-5-18" and process.parent.executable : ("C:\\$VcmsTemp$\\VcmsPush.exe", "C:\\windows\\ctsrsvc.exe"))
  ] by process.entity_id

Stage 2: process

[process where event.action == "start" and
    (
     (process.pe.original_file_name : "wmic.exe" and process.command_line : "*shadowcopy*" and process.command_line : "*delete*") or
     (process.pe.original_file_name : "vssadmin.exe" and process.command_line : "*shadows*" and process.command_line : ("*delete*", "*resize*401*")) or
     (process.pe.original_file_name : "bcdedit.exe" and process.command_line : ("*bootstatuspolicy*", "*recoveryenabled*")) or
     (process.pe.original_file_name : "wbadmin.exe" and process.command_line : ("*catalog*", "*systemstatebackup*") and process.command_line : "*delete*")
    ) and
    not (process.name : "bcdedit.exe" and process.args : "DisplayAllFailures") and
    not (process.name : "wbadmin.exe" and process.args : "-keepVersions*") and
    not (process.name : "bcdedit.exe" and process.command_line: "*recoveryenabled*yes*") and
    not (process.name : "vssadmin.exe" and process.command_line : "*/shadow=*")
  ] by process.parent.entity_id

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.argseqBOOTSTATUSPOLICYexcludes:process.args field:"process.args" value:"BOOTSTATUSPOLICY"
process.parent.executableeq?:\Windows\System32\wbem\WmiPrvSE.exeexcludes:process.parent.executable field:"process.parent.executable" value:"?:\Windows\System32\wbem\WmiPrvSE.exe"
user.ideqS-1-5-18excludes:user.id field:"user.id" value:"S-1-5-18"
process.argswildcard\\*\SysVol\*\Policies\{*}\*excludes:process.args field:"process.args" value:"\\*\SysVol\*\Policies\{*}\*"
process.parent.executableeq?:\Windows\System32\gpscript.exeexcludes:process.parent.executable field:"process.parent.executable" value:"?:\Windows\System32\gpscript.exe"
process.parent.executableeqC:\$VcmsTemp$\VcmsPush.exe, C:\windows\ctsrsvc.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\$VcmsTemp$\VcmsPush.exe" field:"process.parent.executable" value:"C:\windows\ctsrsvc.exe"
process.command_linewildcard*\\*\*.cmd*, *\\*\*.bat*excludes:process.command_line field:"process.command_line" value:"*\\*\*.cmd*" field:"process.command_line" value:"*\\*\*.bat*"
process.parent.executablewildcard?:\Program Files\*.exe, ?:\Program Files (x86)\*.exeexcludes:process.parent.executable field:"process.parent.executable" value:"?:\Program Files\*.exe" field:"process.parent.executable" value:"?:\Program Files (x86)\*.exe"
process.argseqDisplayAllFailuresexcludes:process.args field:"process.args" value:"DisplayAllFailures"
process.nameeqbcdedit.exeexcludes:process.name field:"process.name" value:"bcdedit.exe"
process.argsstarts_with-keepVersionsexcludes:process.args field:"process.args" value:"-keepVersions"
process.nameeqwbadmin.exeexcludes:process.name field:"process.name" value:"wbadmin.exe"
process.command_linematch/shadow=excludes:process.command_line field:"process.command_line" value:"/shadow="
process.nameeqvssadmin.exeexcludes:process.name field:"process.name" value:"vssadmin.exe"
process.command_linewildcard*recoveryenabled*yes*excludes:process.command_line field:"process.command_line" value:"*recoveryenabled*yes*"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
process.command_linewildcard
  • *bootstatuspolicy* corpus 10 (elastic 8, sigma 1, splunk 1)
  • *catalog* corpus 12 (elastic 8, sigma 3, splunk 1)
  • *delete* corpus 31 (sigma 16, elastic 8, splunk 6, kusto 1)
  • *recoveryenabled* corpus 10 (elastic 8, sigma 1, splunk 1)
  • *resize*401* corpus 2 (elastic 2)
  • *shadowcopy* corpus 13 (elastic 7, sigma 3, splunk 3)
  • *shadows* corpus 11 (elastic 8, sigma 3)
  • *systemstatebackup* corpus 8 (elastic 8)
field:"CommandLine" kind:wildcard
process.namewildcard
  • cmd.exe corpus 121 (elastic 92, splunk 29)
field:"process_name" kind:wildcard value:"cmd.exe"
process.pe.original_file_namewildcard
  • bcdedit.exe corpus 13 (elastic 11, sigma 2)
  • vssadmin.exe corpus 12 (elastic 9, sigma 3)
  • wbadmin.exe corpus 19 (elastic 11, sigma 6, splunk 2)
  • wmic.exe corpus 80 (sigma 38, elastic 24, splunk 18)
field:"OriginalFileName" kind:wildcard