Skip to content

New Rules : PowerShell Console History File Access - file_access + proc_creation #5253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
title: PowerShell Console History File Access
id: 4d052abb-0bee-44f3-9aa0-8dab6b1bd349
related:
- id: f4ff7323-b5fc-4323-8b52-6b9408e15788
type: derived
status: experimental
description: Detects access to the PowerShell console history file (ConsoleHost_history.txt), possibly to retrieve plaintext passwords used in PowerShell commands.
references:
- https://0xdf.gitlab.io/2018/11/08/powershell-history-file.html
author: Luc Génaux
date: 2025-04-03
tags:
- attack.credential-access
- attack.t1552.001
logsource:
product: windows
category: file_access
definition: 'Requirements: Microsoft-Windows-Kernel-File ETW provider'
detection:
selection:
FileName|endswith: 'PSReadLine\ConsoleHost_history.txt'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Powershell, AV, Windows itself and many other processes will request access to this file.

The filters have to be more strict or the rule will generate a lot of FPs

filter:
Image|endswith:
- '\notepad.exe'
- '\notepad++.exe'
condition: selection and not filter
falsepositives:
- Curious user opening it's own history file
level: medium
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
title: Possible PowerShell Console History File Access Attempt
id: f4ff7323-b5fc-4323-8b52-6b9408e15788
related:
- id: 4d052abb-0bee-44f3-9aa0-8dab6b1bd349
type: derived
status: experimental
description: Detects possible access attempts to the PowerShell console history file (ConsoleHost_history.txt) in order to retrieve plaintext passwords used in PowerShell commands.
references:
- https://0xdf.gitlab.io/2018/11/08/powershell-history-file.html
author: Luc Génaux
date: 2025-04-03
tags:
- attack.credential-access
- attack.t1552.001
logsource:
category: process_creation
product: windows
detection:
selection:
CommandLine|contains:
- 'ConsoleHost_history.txt'
- '(Get-PSReadlineOption).HistorySavePath'
filter:
Image|endswith:
- '\notepad.exe'
- '\notepad++.exe'
Comment on lines +23 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the rule is looking for access attempt, why exclude notepad? Its the easiest way to access that file for an attacker.

I know the aim is to reduce FP from admin. But that should be left to the rule user as it is env specific.

condition: selection and not filter
falsepositives:
- Curious user opening it's own history file
level: medium
Loading