Skip to main content

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

Targeting Options

Output Options

When using /password with /target, you must also specify the /sid:X parameter with the user’s full domain SID.

What Are Masterkeys?

Masterkeys are stored in the user’s profile at:
Each user typically has multiple masterkey files. The Preferred file indicates which masterkey is currently in use.

Example: Decrypt with Domain Backup Key

Output:
Save these :SHA1 mappings to a file. You can use them with /mkfile:masterkeys.txt in other commands.

Example: Extract Masterkey Hashes

Output:
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

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
Network Indicators:
  • SMB access to user profile directories on remote systems
  • RPC calls to domain controller for /rpc decryption
  • Access to SYSVOL for domain backup key retrieval

backupkey

Retrieve domain DPAPI backup key

credentials

Decrypt credentials using masterkeys

triage

Comprehensive DPAPI data extraction

machinemasterkeys

Decrypt machine masterkeys

Tips

  • 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
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
Partial decryption:
  • Users may have multiple masterkeys from different time periods
  • Focus on the “Preferred” masterkey for current data
  • Older masterkeys may use different user passwords