Detection rules › Sigma

Clearing Windows Console History

Status
test
Severity
high
Log source
product windows, category ps_script
Author
Austin Songer @austinsonger
Source
github.com/SigmaHQ/sigma

Identifies when a user attempts to clear 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

Event coverage

Rule body yaml

title: Clearing Windows Console History
id: bde47d4b-9987-405c-94c7-b080410e8ea7
status: test
description: Identifies when a user attempts to clear console history. An adversary may clear the command history of a compromised account to conceal the actions undertaken during an intrusion.
references:
    - https://stefanos.cloud/blog/kb/how-to-clear-the-powershell-command-history/
    - https://www.shellhacks.com/clear-history-powershell/
    - https://community.sophos.com/sophos-labs/b/blog/posts/powershell-command-history-forensics
author: Austin Songer @austinsonger
date: 2021-11-25
modified: 2022-12-25
tags:
    - attack.stealth
    - attack.t1070
    - attack.t1070.003
logsource:
    product: windows
    category: ps_script
    definition: 'Requirements: Script Block Logging must be enabled'
detection:
    selection1:
        ScriptBlockText|contains: Clear-History
    selection2a:
        ScriptBlockText|contains:
            - Remove-Item
            - rm
    selection2b:
        ScriptBlockText|contains:
            - ConsoleHost_history.txt
            - (Get-PSReadlineOption).HistorySavePath
    condition: selection1 or selection2a and selection2b
falsepositives:
    - Unknown
level: high

Stages and Predicates

Stage 0: condition

selection1 or selection2a and selection2b

Stage 1: selection1

selection1:
    ScriptBlockText|contains: Clear-History

Stage 2: selection2a

selection2a:
    ScriptBlockText|contains:
        - Remove-Item
        - rm

Stage 3: selection2b

selection2b:
    ScriptBlockText|contains:
        - ConsoleHost_history.txt
        - (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)
  • Clear-History
  • ConsoleHost_history.txt
  • Remove-Item corpus 3 (sigma 2, splunk 1)
  • rm corpus 2 (sigma 2)