Overview
The masterkeys command searches for user masterkey files and decrypts them using a domain DPAPI backup key or user credentials. It returns :SHA1 mappings that can be used with other commands for decryption.Masterkeys are the intermediate encryption keys used by DPAPI. Once decrypted, they can decrypt any DPAPI-protected data for that user.
Basic Usage
Command Arguments
Decryption Methods
| Argument | Description |
|---|---|
/pvk:BASE64... | Base64-encoded domain DPAPI backup key |
/pvk:key.pvk | Domain backup key file |
/password:X | User’s plaintext password |
/ntlm:X | User’s NTLM hash |
/credkey:X | DPAPI credkey (SHA1 from Mimikatz sekurlsa::msv) |
/rpc | Decrypt by asking domain controller |
Targeting Options
| Argument | Description |
|---|---|
/target:FILE | Target specific masterkey file |
/target:FOLDER | Target specific folder of masterkeys |
/server:SERVER | Target remote server (requires pvk or password) |
Output Options
| Argument | Description |
|---|---|
/hashes | Output masterkey hashes in John/Hashcat format (no decryption) |
What Are Masterkeys?
Masterkeys are stored in the user’s profile at:Preferred file indicates which masterkey is currently in use.
Example: Decrypt with Domain Backup Key
Example: Extract Masterkey Hashes
Focus on cracking the “preferred” masterkeys first - these are the currently active keys for each user.
Example: Decrypt with User Password
Offline Masterkey Cracking
1
Extract Hashes
2
Crack with Hashcat
3
Use Cracked Passwords
Using Decrypted Masterkeys
Once you have the :SHA1 mappings, use them with other commands:Common Scenarios
Domain Admin - Mass Decryption
Domain Admin - Mass Decryption
Known User Password
Known User Password
Offline Analysis
Offline Analysis
Masterkey File Structure
Each masterkey file is encrypted and contains:- GUID: Unique identifier for the masterkey
- Encryption: Uses user’s password/hash-derived key
- SHA1 Hash: Decrypted masterkey value
- Domain Backup: Can be decrypted with domain backup key
Detection Considerations
Host-Based Indicators:- Reading files from
%APPDATA%\Microsoft\Protect\directories - Bulk enumeration of masterkey files
- Non-standard processes accessing DPAPI protected data
- SMB access to user profile directories on remote systems
- RPC calls to domain controller for
/rpcdecryption - Access to SYSVOL for domain backup key retrieval
Related Commands
backupkey
Retrieve domain DPAPI backup key
credentials
Decrypt credentials using masterkeys
triage
Comprehensive DPAPI data extraction
machinemasterkeys
Decrypt machine masterkeys
Tips
Maximizing Success
Maximizing Success
- Always check for the “Preferred” masterkey - it’s the active one
- Domain backup key works for all domain users across the entire domain
- Masterkey hashes can be cracked offline if you have password lists
- Save :SHA1 mappings to avoid re-running masterkey decryption
Troubleshooting
Troubleshooting
No masterkeys decrypted:
- Verify backup key or password is correct
- Check user SID matches the Protect folder path
- Ensure you have read access to the masterkey files
- Users may have multiple masterkeys from different time periods
- Focus on the “Preferred” masterkey for current data
- Older masterkeys may use different user passwords