The Windows Data Protection API (DPAPI) encrypts secrets with keys derived from the user logon password or the system account, and stores those secrets in places testers routinely overlook - Credential Manager vaults, browser login databases, Wi-Fi profiles, RDP connection files, and application config stores. Recovering a DPAPI secret is rarely about breaking encryption. It is about obtaining the right key material in the right context - the user master key, the system master key, or a domain backup key - and then decrypting blobs that were already sitting on disk. This sub-skill maps the DPAPI hierarchy, shows where secrets live, and explains offline decryption inside authorized scope. It builds on the parent skill privesc-windows-vectors, which covers stored credentials generally.
Quick Workflow
- Confirm scope and context - record which user profile, host, and credential stores are in scope, and whether you hold the user context, SYSTEM, or only a disk image or backup.
- Inventory DPAPI-protected material on the host - vault files, browser login databases, credential files, Wi-Fi profiles, and RDP files, with paths and owners recorded.
- Determine which key material you can reach - user master keys in the profile, system master keys as SYSTEM, or a domain backup key if the engagement includes domain controller access.
- Decrypt in the matching context first - user context for user blobs, SYSTEM for system blobs - and fall back to offline decryption only with legitimately obtained key material.
- Validate every recovered secret by testing it inside scope, and record which store it came from, because the remediation differs by store.
- Report secrets by store and by privilege impact - a recovered domain admin password, a Wi-Fi key, and a saved website password are different severities and different fixes.
- Clean up extracted key material and decrypted secrets at engagement end, following the rules of engagement for credential handling and retention.
1. How DPAPI keys and blobs fit together
DPAPI has two layers. The master key is a random key protected by the user password (for user master keys) or by the system LSA secret (for system master keys), and stored in the profile under AppData Roaming Microsoft Protect. The data blob is encrypted with a session key derived from the master key. To decrypt a blob you need the master key that protected it, plus the entropy and context the application used, which is usually none or a documented value.
Get-ChildItem "$env:APPDATA\Microsoft\Protect\" -Recurse |
Select-Object FullName, Length
Get-ChildItem "$env:LOCALAPPDATA\Microsoft\Credentials\" -Recurse |
Select-Object FullName
The Protect directory holds master key files named by GUID, and the Credentials directory holds vault credential files. The presence of many master key files is normal - Windows rotates them, and older blobs may need older master keys. When decryption fails with the newest master key, try each GUID in turn rather than concluding the blob is undecryptable. The system master key lives in a protected system location and is reachable only as SYSTEM, which is why a SYSTEM shell changes the DPAPI picture completely.
Domain environments add a third key path - the domain backup key. Domain controllers hold a backup key that can decrypt any domain user master key, by design, so that credentials survive password resets. Access to that backup key inside scope, for example during a domain escalation phase, converts every domain user master key on every host into decryptable material. Treat backup key access as a domain-tier finding, and handle the key material with the strictest retention rules in the engagement.
2. Credential Manager vaults and saved credentials
Windows Credential Manager stores generic credentials, domain credentials, and certificate-based credentials in vault files. The classic enumeration starts with the built-in listing, then moves to vault files on disk when the listing is empty or when you hold only a profile copy.
cmdkey /list
Get-ChildItem "$env:LOCALAPPDATA\Microsoft\Vault\" -Recurse |
Select-Object FullName
A cmdkey entry shows the target name, which often reveals the system the credential belongs to, but not the secret itself. Vault files under the Vault directory hold the encrypted credential blobs, and each blob needs the user master key for decryption. On an authorized host where you run as the user, native DPAPI calls decrypt directly. From a profile copy or backup, offline tooling needs the master key file plus the user password hash or the domain backup key, depending on the environment. Always note which method you used, because a vault decrypted from a backup with a domain backup key is a stronger finding than a vault read in a live user session.
Common vault-derived secrets and their usual next steps inside scope:
- Saved RDP credentials for a server, which may be a domain admin session on a jump host.
- Generic credentials for a web application, database, or cloud console, which may reuse a privileged password.
- Certificate credentials that unlock a smart card or client certificate store, which may authenticate as another principal.
- Wi-Fi credentials stored as network profiles, which give network access but rarely direct privilege, and should be reported as network exposure rather than escalation.
3. Browser and application secrets
Modern browsers on Windows encrypt stored logins with DPAPI, then store them in a SQLite login database alongside the encrypted password field. Chromium-based browsers and Firefox use different stores and different key paths, so check both, and check per-user profiles rather than only the default profile.
Get-ChildItem "$env:LOCALAPPDATA\Google\Chrome\User Data\" -Recurse -Filter "Login Data" |
Select-Object FullName
Get-ChildItem "$env:APPDATA\Mozilla\Firefox\Profiles\" -Recurse -Filter "logins.json" |
Select-Object FullName
For Chromium browsers, the encryption key is stored in the Local State file, itself DPAPI protected, and each login password is encrypted with that key. The decryption chain is therefore DPAPI to Local State key, then AES decryption of the password field. For Firefox, the key database and logins file work together, and a recovered master password, if one is set, changes the difficulty completely. Document the browser, profile path, and decryption chain for each recovered login, because the remediation is browser policy and password hygiene, not a single patch.
Other applications follow the same pattern with their own stores - email clients, FTP clients, database tools, and remote administration tools frequently keep DPAPI or custom encrypted credentials in config files or registry values. When a config file contains a long base64 blob near a username field, treat it as a candidate DPAPI blob and test decryption before dismissing it as opaque data. The parent skill lists config file locations, and this sub-skill adds the decryption step that turns those blobs into usable secrets.
4. Wi-Fi, RDP, and system-context secrets
Wi-Fi profiles store pre-shared keys in XML files protected by DPAPI in the system context, and RDP files may store passwords in encrypted form. System-context secrets need SYSTEM, not just the user, which makes this section a bridge between local privilege escalation and credential recovery - get SYSTEM first, then harvest system secrets.
netsh wlan show profiles
netsh wlan show profile name="CorpWiFi" key=clear
Get-ChildItem "$env:USERPROFILE\Documents\" -Filter "*.rdp" |
Select-Object FullName
The netsh key equals clear output shows the Wi-Fi key only when run with sufficient privilege, which is itself a useful privilege check. RDP files with a password hash field use a different encryption scheme than DPAPI, and the hash can be decrypted with known tooling inside scope when the engagement includes credential recovery. Report Wi-Fi keys as network access findings and RDP credentials by the privilege of the account they belong to, not by the file type. A Wi-Fi key alone rarely escalates privilege, but an RDP credential for a domain admin does, and the report should separate those impacts clearly.
System DPAPI secrets also include LSA secrets, scheduled task credentials, and service account passwords stored by the system. As SYSTEM, enumeration tooling can list LSA secrets, and each one should be checked for reuse against domain accounts inside scope. The discipline here is the same as for vaults - inventory first, decrypt with the matching key context, validate by a scoped logon test, and report by impact.
5. Offline decryption with a recovered master key
Offline decryption is the case where you do not hold the live user session - you hold a disk image, a profile backup, or a VSS copy, plus key material obtained inside scope. The standard offline workflow extracts master keys, obtains the user password hash or the domain backup key through the authorized domain phase, decrypts the master key, and then decrypts each blob.
python3 dpapick.py masterkey -d /mnt/profile/AppData/Roaming/Microsoft/Protect/S-1-5-21-xxx/ \
--password 'UserPasswordHere'
python3 dpapick.py credential -d /mnt/profile/AppData/Local/Microsoft/Credentials/ \
--masterkey <decrypted-master-key-hex>
Replace the profile path, SID directory, password, and master key hex with real values from the engagement, and run offline tooling only against material obtained inside scope. If the user password is unknown and no domain backup key is available, offline decryption of that user master key is not feasible, and the finding becomes a key-material exposure note - the profile copy itself is sensitive even without decryption, because it becomes decryptable the moment the password or backup key is obtained later. That time dimension matters for retention advice - profile backups should be treated as credential material, not as ordinary files.
Detection note for this family - DPAPI decryption itself is a legitimate Windows function, so defenders rarely detect the decryption call directly. They detect the surrounding activity instead - mass vault file access, credential file copying to unusual locations, LSASS access for key material, and logons with recovered credentials from unexpected hosts. Harden by reducing stored credentials, enforcing Credential Guard where supported, rotating credentials found in vaults, and treating profile backups as credential stores in backup access policy.
Edge cases
- A master key protected by an old password still decrypts old blobs after a password change, because DPAPI keeps the old master key until rotation completes.
- Blobs encrypted with entropy fail to decrypt when the entropy value is unknown, even with the correct master key, so record the application context for each blob.
- System master keys are not reachable from a user session, so a user-context decryption attempt against a system blob fails by design, not by tool error.
- Domain backup keys decrypt domain user master keys, but not local account master keys, which use the local password path instead.
- Browser decryption chains differ by browser version - a chain that works on one Chromium build may need adjustment on another, so check the Local State format first.
- Vault files may be locked by a running process on a live host, so copy them to a working directory inside scope rather than reading them in place during an active session.
- Credential files in roaming profiles may be out of date relative to the live host, so validate recovered secrets against current accounts before reporting them as active.
- Some applications use DPAPI with additional application-specific encryption on top, so a successful DPAPI step may yield another encrypted layer, not plaintext.
Key references
- MITRE ATT&CK T1555 (Credentials from Password Stores), T1555.001 (Keychain), T1555.003 (Credentials from Web Browsers), T1003 (OS Credential Dumping)
- Microsoft DPAPI documentation - https://learn.microsoft.com/en-us/dotnet/standard/security/how-to-use-data-protection
- HackTricks DPAPI section - https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dpapi
- Impacket secretsdump and DPAPI tooling - https://github.com/fortra/impacket
- Credential Guard overview - https://learn.microsoft.com/en-us/windows/security/identity-protection/credential-guard/
