Skip to main content

Overview

The machinemasterkeys command elevates to SYSTEM, retrieves the DPAPI_SYSTEM LSA secret, and uses it to decrypt all accessible machine DPAPI masterkeys. It returns :SHA1 mappings that can be used with other machine DPAPI commands.
Machine masterkeys are used to protect system-level credentials, scheduled task passwords, service account credentials, and other machine-scope DPAPI data.

Basic Usage

This command requires elevation (Administrator privileges) to:
  • Elevate to SYSTEM via token duplication
  • Retrieve the DPAPI_SYSTEM LSA secret
  • Access system masterkey files

How It Works

1

Elevation to SYSTEM

Duplicates a SYSTEM token to elevate privileges
2

DPAPI_SYSTEM Retrieval

Retrieves the DPAPI_SYSTEM LSA secret used to protect machine masterkeys
3

Masterkey Discovery

Locates all machine masterkey files in system directories
4

Masterkey Decryption

Decrypts each masterkey using the DPAPI_SYSTEM secret
5

Output Mappings

Returns :SHA1 mappings for use with other commands

Example Output

Output:
Save these :SHA1 mappings to a file. They can be used with machine credential/vault commands or saved for future use.

Machine Masterkey Locations

Machine masterkeys are stored in:
Protected Accounts:
  • S-1-5-18: SYSTEM account
  • LocalService: Local Service account
  • NetworkService: Network Service account

DPAPI_SYSTEM Secret

The DPAPI_SYSTEM LSA secret consists of two keys: Format:

Using Machine Masterkeys

Once you have the :SHA1 mappings, use them with machine DPAPI commands:

What Machine Masterkeys Protect

  • Task Scheduler stored passwords
  • Service account credentials for tasks
  • Automated job credentials
  • Windows service credentials
  • Application pool identities
  • Background service accounts
  • Credential Manager system entries
  • Network authentication credentials
  • System-level saved passwords
  • System certificate private keys
  • Computer authentication certificates
  • SSL/TLS server certificates
  • IIS application pool credentials
  • SQL Server saved passwords
  • System-wide application settings

Common Scenarios

Extract and use machine masterkeys:
Find credentials for scheduled tasks:
Identify service account credentials:
With admin access to remote system:
The machinemasterkeys command doesn’t support /server since it requires local SYSTEM access. Use machine triage commands with /pvk for remote operations.

Comparison: User vs Machine Masterkeys

Detection Considerations

Machine masterkey extraction is a high-privilege operation that should trigger security alerts.
Host-Based Indicators:
  • Process elevation to SYSTEM privileges
  • Token duplication activity
  • LSA secret retrieval (DPAPI_SYSTEM)
  • Access to system masterkey directories
  • Reading SYSTEM profile DPAPI folders
Event Log Indicators:
Defensive Monitoring:
  • Monitor for SYSTEM token impersonation
  • Alert on LSA secret access (DPAPI_SYSTEM)
  • Track access to system masterkey directories
  • Detect SharpDPAPI or similar tool execution
  • Monitor privilege escalation to SYSTEM

machinecredentials

Decrypt machine credential files

machinevaults

Decrypt machine vault data

machinetriage

Comprehensive machine DPAPI triage

sccm

Extract SCCM NAA credentials

Tips

  • Run immediately after gaining admin access
  • Save masterkey mappings for future use
  • DPAPI_SYSTEM secret rarely changes (persistent)
  • Use with machinetriage for comprehensive extraction
  • Combine with service enumeration for context
  • Requires elevation (high visibility)
  • SYSTEM privilege elevation generates events
  • LSA secret access triggers security alerts
  • Consider timing and detection capabilities
  • May trigger EDR/AV behavioral detections
Access denied:
  • Need Administrator privileges
  • UAC may prevent elevation
  • Security software may block SYSTEM elevation
  • Try running as SYSTEM directly
No masterkeys found:
  • Check system masterkey directories exist
  • Verify DPAPI_SYSTEM was retrieved
  • Fresh systems may have fewer masterkeys
  • ServiceProfile accounts may not have masterkeys
Partial decryption:
  • Some masterkeys may use different protection
  • Check for multiple DPAPI_SYSTEM secrets (rare)
  • Verify retrieved secret is complete

Technical Details

DPAPI_SYSTEM Storage

The DPAPI_SYSTEM secret is stored as an LSA secret:

Masterkey Encryption

Machine masterkeys are encrypted using:
  1. DPAPI_SYSTEM machine key for SYSTEM account
  2. DPAPI_SYSTEM user key for service accounts without logged-in user
  3. Standard DPAPI encryption algorithms (3DES, AES)

Persistence

The DPAPI_SYSTEM secret:
  • Generated during Windows installation
  • Persists until OS reinstall
  • Does not change with password changes
  • Stored in protected registry location
  • Backed up with system state
The DPAPI_SYSTEM secret is one of the most valuable secrets on a Windows system, providing access to all machine-scope DPAPI data.