Skip to main content

Overview

The keepass command searches for and decrypts KeePass ProtectedUserKey.bin files. These files contain DPAPI-protected key material used by KeePass to encrypt password databases, providing access to potentially hundreds of stored credentials.
KeePass can use Windows DPAPI to protect its master key file. Decrypting this file allows you to open KeePass databases without knowing the master password.

Basic Usage

Command Arguments

Decryption Methods

This method works without needing masterkeys if run from the user context who created the protected key file. No LSASS access required!

Targeting Options

When using /target with a file, you must provide either /unprotect or :SHA1 masterkey mappings. When using /target with a folder, the folder must contain DPAPI masterkeys if using /pvk.

Execution Context

When run with administrative privileges:
  • Triages all users on the system
  • Searches all user profiles for KeePass key files
  • Maximum key recovery

Example: Using /unprotect

Output:
Save the Key Bytes output - these can be used with the modified KeePass version from KeeThief to open password databases.

Using Decrypted Key Bytes

Once you have the decrypted key bytes, you can use them to open KeePass databases:
1

Obtain Decrypted Key

2

Get Modified KeePass

Download the modified KeePass from KeeThiefThis version accepts raw key bytes instead of a master password
3

Open Database

Use the decrypted key bytes with the modified KeePass to open the user’s password database without knowing their master password

KeePass Protected Key File Location

Default Location:
Alternative Locations:
  • Custom KeePass configuration directories
  • Portable KeePass installations
  • Network/shared KeePass configurations

How KeePass DPAPI Protection Works

1

User Enables Protection

KeePass offers “User account” protection option which uses Windows DPAPI
2

Key Material Encryption

KeePass encrypts the master key material with user’s DPAPI masterkey
3

Protected Key Saved

Encrypted key saved to ProtectedUserKey.bin in KeePass profile
4

Automatic Unlock

When KeePass runs, it uses CryptUnprotectData() to automatically decrypt the key
This protection binds the KeePass database to the Windows user account. If the user logs in, KeePass can open automatically without prompting for a password.

Common Scenarios

After obtaining domain admin and backup key:
Extract masterkeys and decrypt KeePass key files:
Analyzing copied KeePass configuration:

Finding KeePass Databases

After decrypting the protected key, locate the KeePass databases: Common Locations:
Search for databases:

Detection Considerations

Host-Based Indicators:
  • Reading ProtectedUserKey.bin file
  • Non-KeePass processes accessing KeePass configuration
  • Enumeration of KeePass directories
  • Access to .kdbx database files
Defensive Monitoring:
  • Monitor access to %APPDATA%\KeePass\ProtectedUserKey.bin
  • Alert on ProtectedUserKey.bin access by non-KeePass processes
  • Track .kdbx file access patterns
  • Detect bulk KeePass configuration enumeration
  • Monitor for LSASS access (when not using /unprotect)
Event Log Indicators:

Why Target KeePass?

Credential Jackpot

Password managers contain hundreds or thousands of credentials

High-Value Targets

Often contains admin, service account, and critical system passwords

Lateral Movement

Provides credentials for multiple systems and services

Persistent Access

Credentials remain valid even after user password changes

triage

Comprehensive user DPAPI triage

credentials

Decrypt Credential Manager files

masterkeys

Decrypt user masterkeys

backupkey

Retrieve domain backup key

Tips

  • Prefer /unprotect when running as the target user
  • Look for KeePass on administrator and privileged user workstations
  • After decrypting key, search entire system for .kdbx files
  • Check network shares and cloud storage for KeePass databases
  • Combine with file search to locate all password databases
  • Use /unprotect for minimal detection footprint
  • Run without elevation when possible
  • Target specific files if locations are known
  • Redirect output to file with /consoleoutfile
  • Avoid bulk enumeration if stealth is required
No KeePass files found:
  • User may not use KeePass protection feature
  • KeePass may use master password instead of Windows protection
  • Check for portable KeePass installations
  • Look in non-standard configuration directories
Decryption fails with /unprotect:
  • Must run from the user context who created the protected key
  • Try using masterkeys or backup key instead
  • Verify you’re running as the correct user
  • File may be corrupted or invalid format
Can’t find KeePass database:
  • Search entire file system for .kdbx files
  • Check network shares and mapped drives
  • Look in cloud storage sync folders
  • User may keep database on removable media

Additional Resources

KeeThief Project

Modified KeePass version and additional tools for KeePass credential extraction