Detection rules › Elastic
Suspicious PowerShell Console History Deletion
Identifies when a process attempts to delete PowerShell Console History. An adversary may clear the command history of a compromised account to conceal the actions undertaken during an intrusion.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Stealth |
Rule body
[rule]
description = """
Identifies when a process attempts to delete PowerShell Console History. An adversary may clear the command history of a
compromised account to conceal the actions undertaken during an intrusion.
"""
id = "feb6d562-7c15-412a-8be1-48d93f382028"
license = "Elastic License v2"
name = "Suspicious PowerShell Console History Deletion"
os_list = ["windows"]
reference = ["https://attack.mitre.org/techniques/T1070/004/"]
version = "1.0.10"
query = '''
sequence by process.entity_id with maxspan=5m
[process where event.action == "start" and
(
process.name in~ ("powershell.exe", "rundll32.exe", "regsvr32.exe", "cmd.exe", "wscript.exe", "cscript.exe", "mshta.exe",
"winword.exe", "excel.exe") or
process.executable : ("?:\\Users\\*", "?:\\Windows\\Temp\\*", "?:\\ProgramData\\*", "?:\\Windows\\Microsoft.NEt\\*") or
(process.code_signature.trusted == false or process.code_signature.exists == false)
) and
not user.id in ("S-1-5-18", "S-1-5-19")
]
[file where event.action == "deletion" and file.name : "ConsoleHost_history.txt"]
'''
min_endpoint_version = "7.16.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1070"
name = "Indicator Removal"
reference = "https://attack.mitre.org/techniques/T1070/"
[[threat.technique.subtechnique]]
id = "T1070.003"
name = "Clear Command History"
reference = "https://attack.mitre.org/techniques/T1070/003/"
[[threat.technique.subtechnique]]
id = "T1070.004"
name = "File Deletion"
reference = "https://attack.mitre.org/techniques/T1070/004/"
[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"
[internal]
min_endpoint_version = "7.16.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 5m, correlated by process.entity_id.
Stage 1: process
[process where event.action == "start" and
(
process.name in~ ("powershell.exe", "rundll32.exe", "regsvr32.exe", "cmd.exe", "wscript.exe", "cscript.exe", "mshta.exe",
"winword.exe", "excel.exe") or
process.executable : ("?:\\Users\\*", "?:\\Windows\\Temp\\*", "?:\\ProgramData\\*", "?:\\Windows\\Microsoft.NEt\\*") or
(process.code_signature.trusted == false or process.code_signature.exists == false)
) and
not user.id in ("S-1-5-18", "S-1-5-19")
]
Stage 2: file
[file where event.action == "deletion" and file.name : "ConsoleHost_history.txt"]
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
user.id | in | S-1-5-18, S-1-5-19 | excludes:user.id field:"user.id" value:"S-1-5-18" field:"user.id" value:"S-1-5-19" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq |
file.name | wildcard |
| field:"file.name" kind:wildcard value:"ConsoleHost_history.txt" |
process.code_signature.exists | eq |
| field:"process.code_signature.exists" kind:eq value:"false" |
process.code_signature.trusted | eq |
| field:"process.code_signature.trusted" kind:eq value:"false" |
process.executable | wildcard |
| field:"Image" kind:wildcard |
process.name | in |
| field:"process_name" kind:in |