Detection rules › Sigma

Clear PowerShell History - PowerShell

Severity
medium
Author
Ilyas Ochkov, Jonhnathan Ribeiro, Daniil Yugoslavskiy, oscd.community
Source
upstream

Detects keywords that could indicate clearing PowerShell history

MITRE ATT&CK coverage

TacticTechniques
Defense EvasionT1070.003 Indicator Removal: Clear Command History

Event coverage

ProviderEvent IDTitle
PowerShell4104Creating Scriptblock text (MessageNumber of MessageTotal).

Stages and Predicates

Stage 1: 1 of selection_2

ScriptBlockText|contains: SaveNothing
ScriptBlockText|contains: Set-PSReadlineOption
ScriptBlockText|contains: '–HistorySaveStyle'

Stage 2: 1 of selection_3

ScriptBlockText|contains: -HistorySaveStyle
ScriptBlockText|contains: SaveNothing
ScriptBlockText|contains: Set-PSReadlineOption

Stage 3: all of selection1a

or:
ScriptBlockText|contains: Remove-Item
ScriptBlockText|contains: del
ScriptBlockText|contains: rm

Stage 4: all of selection1b

ScriptBlockText|contains: '(Get-PSReadlineOption).HistorySavePath'

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
ScriptBlockTextmatch
  • (Get-PSReadlineOption).HistorySavePath corpus 2 (sigma 2)
  • -HistorySaveStyle
  • Remove-Item corpus 2 (sigma 2)
  • SaveNothing
  • Set-PSReadlineOption
  • del
  • rm corpus 2 (sigma 2)
  • –HistorySaveStyle

Neighbors

Broader alternatives (more inclusive than this rule)

These rules match a superset of what this rule catches. They cover the same events plus more. Use them if you want wider coverage and can absorb more false positives.