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
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
Machine Masterkey Locations
Machine masterkeys are stored in:- 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:| Component | Description |
|---|---|
| Machine Key | Used for SYSTEM and machine-scope encryption |
| User Key | Used for user-scope encryption when no user is logged on |
Using Machine Masterkeys
Once you have the :SHA1 mappings, use them with machine DPAPI commands:What Machine Masterkeys Protect
Scheduled Task Credentials
Scheduled Task Credentials
- Task Scheduler stored passwords
- Service account credentials for tasks
- Automated job credentials
Service Account Passwords
Service Account Passwords
- Windows service credentials
- Application pool identities
- Background service accounts
System Credentials
System Credentials
- Credential Manager system entries
- Network authentication credentials
- System-level saved passwords
Machine Certificates
Machine Certificates
- System certificate private keys
- Computer authentication certificates
- SSL/TLS server certificates
Application Data
Application Data
- IIS application pool credentials
- SQL Server saved passwords
- System-wide application settings
Common Scenarios
Comprehensive Machine Triage
Comprehensive Machine Triage
Extract and use machine masterkeys:
Scheduled Task Credential Extraction
Scheduled Task Credential Extraction
Find credentials for scheduled tasks:
Service Account Discovery
Service Account Discovery
Identify service account credentials:
Remote Machine Masterkey Extraction
Remote Machine Masterkey Extraction
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
| Aspect | User Masterkeys | Machine Masterkeys |
|---|---|---|
| Protection | User password/hash | DPAPI_SYSTEM LSA secret |
| Scope | User profile data | System-wide data |
| Location | %APPDATA%\Microsoft\Protect\ | C:\Windows\System32\Microsoft\Protect\ |
| Persistence | Changes with password | Changes rarely (OS reinstall) |
| Privilege | User context | SYSTEM context |
| Decryption | Domain backup key / user creds | DPAPI_SYSTEM secret |
Detection Considerations
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
- 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
Related Commands
machinecredentials
Decrypt machine credential files
machinevaults
Decrypt machine vault data
machinetriage
Comprehensive machine DPAPI triage
sccm
Extract SCCM NAA credentials
Tips
Best Practices
Best Practices
- 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
OPSEC Considerations
OPSEC Considerations
- 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
Troubleshooting
Troubleshooting
Access denied:
- Need Administrator privileges
- UAC may prevent elevation
- Security software may block SYSTEM elevation
- Try running as SYSTEM directly
- Check system masterkey directories exist
- Verify DPAPI_SYSTEM was retrieved
- Fresh systems may have fewer masterkeys
- ServiceProfile accounts may not have masterkeys
- 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:- DPAPI_SYSTEM machine key for SYSTEM account
- DPAPI_SYSTEM user key for service accounts without logged-in user
- 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.