PowerShell Credential Discovery via Recursive File Search and Select-String
Flags PowerShell script blocks that recursively list files and run select-string pattern searches, indicative of credential hunting.
- Product
- windows
- Category
- ps_script
- Author
- frack113 (SigmaHQ), DRL 1.1
- Published
- 2021-12-19
- Updated
- 2026-07-31
ATT&CK techniques
Cred AccessRecon
Resource Dev
Initial Access
Execution
Persistence
Priv Esc
Defense Evasion
Cred Access
Discovery
Lateral Movement
Collection
C2
Exfiltration
Impact
What it detects
This rule flags PowerShell script block activity that combines a recursive directory listing with pattern searching using select-string, consistent with discovering files that may contain sensitive data. Attackers often use this to locate locally stored or shared files holding credentials, configuration secrets, or other embedded sensitive strings. It relies on Windows PowerShell script block text telemetry, specifically Script Block Logging, to observe the presence of the involved cmdlet and parameters.
Reporting behind it
Changelog
v2- v2Candidate ingested via manual entry.2026-07-31
- v1No changelog recorded for this version.2026-07-30
Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.
title: PowerShell Credential Discovery via Recursive File Search and Select-String
id: c9db7c2b-5fd9-4547-bed0-c05ca02175c5
status: test
description: This rule flags PowerShell script block activity that combines a recursive directory listing with pattern searching using select-string, consistent with discovering files that may contain sensitive data. Attackers often use this to locate locally stored or shared files holding credentials, configuration secrets, or other embedded sensitive strings. It relies on Windows PowerShell script block text telemetry, specifically Script Block Logging, to observe the presence of the involved cmdlet and parameters.
references:
- https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1552.001/T1552.001.md
- https://github.com/SigmaHQ/sigma/blob/master/rules/windows/powershell/powershell_script/posh_ps_susp_extracting.yml
author: frack113, Huntrule Team
date: 2021-12-19
modified: 2022-12-25
tags:
- attack.credential-access
- attack.t1552.001
logsource:
product: windows
category: ps_script
definition: "Requirements: Script Block Logging must be enabled"
detection:
selection:
ScriptBlockText|contains|all:
- ls
- " -R"
- "select-string "
- "-Pattern "
condition: selection
falsepositives:
- Unknown
level: medium
license: DRL-1.1
related:
- id: bd5971a7-626d-46ab-8176-ed643f694f68
type: derived