Skip to content

Back to the category index / Back to the command index

Parses and decrypts DPAPI master keys, credentials, Vault data, CREDHIST, and related structures. Some operations retrieve key material from a remote host.

ItemDetails
Implementationexamples/dpapi.py
CategorySecrets / DPAPI / registry / file analysis
Size633 lines
DistributionInstalled as a script through scripts=examples/*.py in setup.py

Run python examples/dpapi.py -h for the current option definitions.

Subcommands: backupkeys, masterkey, credential, vault, unprotect, credhist

ArgumentDescription
-debugEnable debug output
-tsAdd a timestamp to each log message
-t / --target[[domain/]username[:password]@]; required
-hashesNTLM hashes in LMHASH:NTHASH format
-no-passDo not prompt for a password (useful with -k)
-kUse Kerberos authentication. Look for matching credentials in the ccache file named by KRB5CCNAME; if none are valid, use those specified on the command line
-aesKeyAES key for Kerberos authentication (128 or 256 bits)
-dc-ipDomain controller IP address; if omitted, use the domain name (FQDN) from the target parameter
--exportExport keys to a file
-fileMaster key file to parse; required
-sidUser SID
-pvkDomain backup private key for decryption
-keySpecific key for decryption
-passwordUser password; if a SID is specified without a password, prompt for it
-systemSYSTEM hive to parse
-securitySECURITY hive to parse
-vcrdVault credential file
-vpolVault policy file
-entropyExtra entropy string required for decryption
-entropy-fileFile containing binary entropy; overrides -entropy
-outfileSave bytes decrypted by unprotect to a file; if omitted, display a hex dump
-entryEntry index in CREDHIST

Related technology: the master key hierarchy, deriveKeysFromUser, and Vault in DPAPI / SAM / LSA / NTDS.

The subcommands backupkeys, masterkey, credential, vault, unprotect, and credhist select the input structure. The tool parses each binary file with its corresponding structure, derives candidate keys from sources such as passwords, SIDs, user keys, domain PVKs, and DPAPI_SYSTEM, verifies MACs or signatures, and decrypts and displays the results.

DPAPI does not encrypt every secret directly with a single password. Instead, it protects master keys with user or machine keys and uses those master keys to protect individual credentials and Vault blobs. The subcommands differ by which file in this hierarchy is available and which key sources are known.

masterkey parses a MasterKeyFile header and its sections, then derives decryption keys from SID plus password, NT/SHA keys, DPAPI_SYSTEM, domain backup private keys, and other sources. credential and unprotect accept a master key’s SHA1 or equivalent, then inspect each DPAPI_BLOB’s algorithm and salt, verify its HMAC, and decrypt its ciphertext. credhist is a format for tracing a chain of user keys from before password changes.

A Vault policy file (vpol) contains encrypted Vault keys, which decrypt attributes in credential records (vcrd). The domain backup key path retrieves and converts private key material through remote BKRP/LSA. Match blobs to master keys by GUID and never display a plaintext candidate as a success when MAC verification fails; this matters for every subcommand.

SymbolLocationWhere to trace its responsibility
DPAPI64__init__(), getDPAPI_SYSTEM(), getLSA(), run()
ModuleMain names used
impacket.uuidbin_to_string
impacketcrypto, version
impacket.smbconnectionSMBConnection
impacket.dcerpc.v5bkrp, lsad, transport
impacket.dcerpc.v5.rpcrtRPC_C_AUTHN_GSS_NEGOTIATE, RPC_C_AUTHN_LEVEL_PKT_PRIVACY
impacket.exampleslogger
impacket.examples.utilsparse_target
impacket.examples.secretsdumpLSASecrets, LocalOperations
impacket.structurehexdump
impacket.dpapiCREDENTIAL_BLOB, CREDHIST_FILE, CredHist, CredentialFile, DPAPI_BLOB, DPAPI_DOMAIN_RSA_MASTER_KEY, DomainKey, MasterKey, MasterKeyFile, PREFERRED_BACKUP_KEY, PRIVATE_KEY_BLOB, PVK_FILE_HDR, P_BACKUP_KEY, VAULT_KNOWN_SCHEMAS, VAULT_VCRD, VAULT_VPOL, VAULT_VPOL_KEYS, deriveKeysFromUser, deriveKeysFromUserkey, privatekeyblob_to_pkcs1
Import nameDistribution packageImport path and declaration status
CryptodomepycryptodomexImported directly; declared
sixsixImported directly; declared

Output, side effects, and required privileges

Section titled “Output, side effects, and required privileges”
  • The tool primarily makes queries and authentication attempts. Frequent runs can affect audit logs, account lockouts, and target load.
  • Options may create or update local files. Check how existing files are handled and the permissions on output containing secrets.
  • On failure, use protocol status codes to determine whether name resolution, connection, authentication, service state, or permissions caused the stop.

The code depends on impacket.dpapi, crypto, Cryptodome, SMB/RPC bkrp and lsad, and examples.secretsdump. The main points are action dispatch and key source priority in DPAPI.run().