Skip to main content

Overview

The certificates command searches for and decrypts DPAPI-protected certificate private keys for users or machines. Recovered certificates can be used for authentication, code signing, or encrypting/decrypting data.
Windows stores certificate private keys encrypted with DPAPI. Decrypting these keys allows certificate export and usage without the original user context.

Basic Usage

Command Arguments

Decryption Methods

Works without masterkeys if run from the user context who owns the certificates. No LSASS access required!

Targeting Options

When using /machine, you need elevation. The /mkfile and /target arguments can be used with /machine triage.

Certificate File Locations

User Certificate Private Keys (CAPI):
User Certificate Private Keys (CNG):
Machine Certificate Private Keys:

Execution Context

  • Run elevated to access all users
  • Run unelevated for current user only
  • Use /unprotect for unprivileged decryption

Example: User Certificates with Masterkeys

Output:
Certificates with “Client Authentication” EKU can be used for authentication to systems and services. These are high-value targets!

Example: Using /unprotect

Output:

Example: Machine Certificates

Output:

Certificate Usage Scenarios

EKU: 1.3.6.1.5.5.7.3.2
  • Used for user/computer authentication
  • Can authenticate to Active Directory
  • Access web services and APIs
  • Remote desktop services
  • High value for lateral movement
EKU: 1.3.6.1.5.5.7.3.3
  • Sign executables and scripts
  • Sign driver packages
  • Create trusted applications
  • Bypass application whitelisting
EKU: 1.3.6.1.5.5.7.3.4
  • S/MIME email encryption
  • Email signing
  • Access encrypted email archives
EKU: 1.3.6.1.5.5.7.3.1
  • SSL/TLS server certificates
  • Web server authentication
  • Service authentication
EKU: 1.3.6.1.4.1.311.10.3.4
  • Decrypt EFS-encrypted files
  • Access encrypted user data
  • Recover encrypted documents

Common Scenarios

After obtaining domain backup key:
Extract certificates from current user context:
Look for certificates usable for authentication:
These can be used for:
  • Kerberos authentication (PKINIT)
  • Web service authentication
  • Network service access
Extract system certificates for service impersonation:

Using Recovered Certificates

The output provides both the private key and certificate in PEM format:
1

Save Output

Save the private key and certificate sections to separate files:
  • cert.key - Private key portion
  • cert.crt - Certificate portion
2

Convert to PFX

3

Import Certificate

Import the PFX to use for authentication or signing

Detection Considerations

Host-Based Indicators:
  • Reading files from %APPDATA%\Microsoft\Crypto\RSA\
  • Access to C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\
  • Non-standard processes accessing certificate private key files
  • Bulk enumeration of certificate stores
  • LSASS access for machine certificate operations
Defensive Monitoring:
  • Monitor access to user crypto directories
  • Alert on MachineKeys folder access
  • Track certificate private key file reads
  • Detect bulk certificate enumeration
  • Monitor for certificate export operations
Event Log Indicators:

triage

Includes user certificate triage

machinetriage

Includes machine certificate triage

masterkeys

Decrypt user masterkeys

backupkey

Retrieve domain backup key

Tips

  • Look for “Client Authentication” EKU for authentication
  • Check machine certificates on domain controllers and servers
  • Code signing certificates are valuable for persistence
  • EFS certificates can decrypt user files
  • Smart card certificates are high-value targets
  • Use /unprotect for unprivileged, stealthy extraction
  • Target specific certificate files if locations are known
  • Machine certificate operations require elevation (more visible)
  • Redirect output to file to avoid console display
  • Consider exfiltration method for recovered certificates
No certificates found:
  • User may not have certificate private keys
  • Try /showall to see all decrypted keys
  • Check both CAPI and CNG locations
  • Verify masterkeys are correct
Certificate shows but no private key recovered:
  • Masterkey may not be available
  • Try using domain backup key
  • Certificate may use different DPAPI protection
  • Check if /cng flag is needed
Machine certificates require elevation:
  • Must run as Administrator or SYSTEM
  • Uses DPAPI_SYSTEM LSA secret
  • Cannot use /unprotect for machine certs