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
- CryptUnprotectData
- Domain Backup Key
- Masterkey Mappings
- User Credentials
Targeting Options
| Argument | Description |
|---|---|
/target:FILE | Target specific ProtectedUserKey.bin file |
/target:FOLDER | Target folder containing KeePass key files |
/server:SERVER | Triage remote server (requires admin access + pvk/password) |
Execution Context
- Elevated
- Unelevated
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
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:- 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
Unprivileged Execution (Recommended)
Unprivileged Execution (Recommended)
Run as the target user without elevation:Benefits:
- No LSASS access required
- No elevation needed
- Minimal detection footprint
Post-Domain Compromise
Post-Domain Compromise
After obtaining domain admin and backup key:
Using Mimikatz-Extracted Masterkeys
Using Mimikatz-Extracted Masterkeys
Extract masterkeys and decrypt KeePass key files:
Offline/Forensic Analysis
Offline/Forensic Analysis
Analyzing copied KeePass configuration:
Finding KeePass Databases
After decrypting the protected key, locate the KeePass databases: Common Locations:Detection Considerations
Host-Based Indicators:- Reading ProtectedUserKey.bin file
- Non-KeePass processes accessing KeePass configuration
- Enumeration of KeePass directories
- Access to .kdbx database files
- 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)
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
Related Commands
triage
Comprehensive user DPAPI triage
credentials
Decrypt Credential Manager files
masterkeys
Decrypt user masterkeys
backupkey
Retrieve domain backup key
Tips
Best Practices
Best Practices
- Prefer
/unprotectwhen 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
OPSEC Considerations
OPSEC Considerations
- Use
/unprotectfor 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
Troubleshooting
Troubleshooting
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
- 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
- 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