Private Keys Reconnaissance Via Command Line Tools
Adversaries utilize native Windows utilities to enumerate local file systems for improperly stored private keys and cryptographic credentials.
Adversaries frequently perform reconnaissance on compromised endpoints to identify sensitive cryptographic material stored in insecure locations. By leveraging standard command line interfaces and built-in Windows utilities, attackers can recursively search for common file extensions associated with private keys, PGP/GPG configurations, and certificates. This activity is a common precursor to credential theft and lateral movement, as these files may grant unauthorized access to remote services, encrypted data, or developer environments. Detecting this behavior is essential, as the tools used (cmd, PowerShell, findstr) are native to the operating system and often blend into normal administrative activity.
Attack Chain
- Attacker gains interactive command execution access on a Windows endpoint.
- Attacker identifies potential directory paths of interest (e.g., user profiles, SSH configs, or development folders).
- Attacker initiates a search for specific file extensions using
dir,Get-ChildItem, orfindstr/s. - The search targets extensions including .key, .pgp, .gpg, .ppk, .p12, .pem, .pfx, .cer, .p7b, or .asc.
- Attacker observes command output to verify the presence of keys on the local disk.
- Attacker exfiltrates or directly utilizes discovered private keys for persistence or unauthorized access.
Impact
Successful reconnaissance of private keys leads to the compromise of identity-based assets, potential exfiltration of encrypted communications, and the bypass of multi-factor authentication systems that rely on certificate-based authentication. If attackers secure these keys, they can establish long-term persistence within development or infrastructure environments, leading to potential supply chain or data integrity breaches.
Recommendation
Deploy detection rules to monitor for recursive file listing operations that target sensitive cryptographic file extensions.
- Implement the provided Sigma rule to alert on suspicious combinations of file search commands and key-related extensions.
- Review baseline administrative scripts in the environment to identify legitimate automated key management tasks and tune out noise.
- Use endpoint detection and response (EDR) telemetry to correlate the reconnaissance activity with subsequent suspicious file access or egress traffic.
Immediate actions
Deploy the Sigma detection rule to monitor for recursive key searches
Threat Hunt
Search command line logs for wide-scope 'dir' or 'Get-ChildItem' operations targeting known key extensions
Data: Process creation telemetry
Detection coverage 1
Detect Private Keys Reconnaissance via Command Line
mediumDetects recursive file search commands targeting common private key and certificate file extensions
Detection queries are available on the platform. Get full rules →