Detectionmediumtest

Clear PowerShell History - PowerShell

Detects keywords that could indicate clearing PowerShell history

Open in Detection LabConvert ruleBuild Package
Ilyas Ochkov, Jonhnathan Ribeiro, Daniil Yugoslavskiy, oscd.communityCreated 2022-01-25Updated 2022-12-0226b692dc-1722-49b2-b496-a8258aa6371dwindows
Log Source
WindowsPowerShell Script
ProductWindows← raw: windows
CategoryPowerShell Script← raw: ps_script

Definition

Requirements: Script Block Logging must be enabled

Detection Logic
Detection Logic4 selectors
detection:
    selection1a:
        ScriptBlockText|contains:
            - 'del'
            - 'Remove-Item'
            - 'rm'
    selection1b:
        ScriptBlockText|contains: '(Get-PSReadlineOption).HistorySavePath'
    selection_2:
        ScriptBlockText|contains|all:
            - 'Set-PSReadlineOption'
            - '–HistorySaveStyle'  # not sure if the homoglyph –/- is intended, just checking for both
            - 'SaveNothing'
    selection_3:
        ScriptBlockText|contains|all:
            - 'Set-PSReadlineOption'
            - '-HistorySaveStyle'
            - 'SaveNothing'
    condition: 1 of selection_* or all of selection1*
False Positives

Legitimate PowerShell scripts

Related Rules
Derived

dfba4ce1-e0ea-495f-986e-97140f31af2d

Rule not found
Rule Metadata
Rule ID
26b692dc-1722-49b2-b496-a8258aa6371d
Status
test
Level
medium
Type
Detection
Created
2022-01-25
Modified
2022-12-02
Path
rules/windows/powershell/powershell_script/posh_ps_clear_powershell_history.yml
Raw Tags
attack.stealthattack.t1070.003
View on GitHub