Detectionmediumtest
Clear PowerShell History - PowerShell
Detects keywords that could indicate clearing PowerShell history
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
References
MITRE ATT&CK
Tactics
Sub-techniques
Related Rules
Derived
Rule not founddfba4ce1-e0ea-495f-986e-97140f31af2d
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