Skip to content

Back to the category index / Back to the command index

Extracts SAM, LSA, and NTDS hashes, Kerberos keys, and other secrets from local hive or NTDS files or from a remote host.

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

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

ArgumentDescription
target[[domain/]username[:password]@], or LOCAL to parse local files
-tsAdd a timestamp to each log message
-debugEnable debug output
-systemSYSTEM hive to parse; requires a binary REGF hive because a .reg text file lacks boot-key metadata
-bootkeyBoot key for the SYSTEM hive
-securitySECURITY hive to parse
-samSAM hive to parse
-ntdsNTDS.DIT file to parse
-resumefileResume file for an NTDS.DIT dump via DRSUAPI; also updated with session state
-skip-samDo not parse the SAM hive on the remote system
-skip-securityDo not parse the SECURITY hive on the remote system
-outputfileBase output filename; extensions are added for SAM, secrets, cached credentials, and NTDS
-use-vssUse the NTDSUTIL VSS method instead of the default DRSUAPI method
-rodcNoRODC krbtgt account number (Kerb-Key-List approach only)
-rodcKeyRead-only domain controller AES key (Kerb-Key-List approach only)
-use-keylistUse the Kerb-Key-List method instead of the default DRSUAPI method
-exec-methodRemote execution method when using -use-vss (choices: smbexec, wmiexec, mmcexec; default: smbexec)
-use-remoteSSWMICreate a remote shadow snapshot through WMI, download SAM, SYSTEM, and SECURITY, then parse them locally
-use-remoteSSWMI-NTDSAlso dump NTDS.DIT with the remote WMI shadow snapshot method on a DC; requires -use-remoteSSWMI
-remoteSSWMI-remote-volumeRemote volume to snapshot for SAM, SYSTEM, and SECURITY (default: C:)
-remoteSSWMI-local-pathLocal download path for SAM, SYSTEM, and SECURITY from the shadow snapshot (default: current directory)
-just-dc-userExtract NTDS.DIT data only for the specified user (DRSUAPI only); implies -just-dc
-ldapfilterExtract NTDS.DIT data only for users matching an LDAP filter (DRSUAPI only); implies -just-dc
-just-dcExtract only NTDS.DIT data (NTLM hashes and Kerberos keys)
-just-dc-ntlmExtract only NTDS.DIT NTLM hashes
-trust-keysDump trusted domain object (TDO) secrets and derive inter-realm Kerberos keys (AES and RC4) for each trust direction
-just-trust-keysLike -trust-keys, but dump only trust keys and skip all account secrets
-skip-userSkip NTDS.DIT data for the specified user; accepts a comma-separated list or a text file with one user per line
-pwd-last-setShow each NTDS.DIT account’s pwdLastSet attribute (not written by -outputfile)
-user-statusShow whether a user is disabled
-historyDump password history (NTDS and SAM hashes) and LSA secret OldVal values
-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)
-keytabRead SPN keys from a keytab file
-dc-ipDomain controller IP address; if omitted, use the domain name (FQDN) from the target parameter
-target-ipTarget machine IP address; if omitted, use the target value. Useful when a NetBIOS target name cannot be resolved
-ldaps / -use-ldapsUse LDAPS instead of LDAP for directory queries

Related technology: boot keys, PEKs, and the separation of acquisition paths and decoders in DPAPI / SAM / LSA / NTDS.

For the LOCAL target, the tool opens the specified hives or database directly. For a remote target, it connects over SMB or LDAP and acquires data through the selected Remote Registry, VSS, DRSUAPI, WMI shadow copy, or Key List path. LocalOperations or RemoteOperations prepares the boot or system keys; SAMHashes, LSASecrets, NTDSHashes, and KeyListSecrets decode and output each record. cleanup() removes service, temporary-file, and resume-state resources.

secretsdump is an orchestrator that combines several acquisition methods and decoders. Local mode reads SAM, SYSTEM, SECURITY, and NTDS files directly. After identifying a remote target over SMB or LDAP, remote mode obtains the required raw data through Remote Registry, VSS, DRSUAPI replication, WMI shadow copies, RODC Key List, or another selected path.

SAMHashes and LSASecrets decrypt SAM and LSA data using the boot key. For NTDS, the boot key decrypts the PEK, which in turn decrypts each account record’s encrypted hashes and keys with the RID. The DRSUAPI path does not copy the database file; it normalizes attribute IDs and values from replication responses into the same logical records. -just-dc* and LDAP filters affect both acquisition and decoder output.

VSS or remote shadow copies and registry saves may create services, snapshots, and temporary files on the target. The resume file holds a cursor for long NTDS operations and must match the target and database when resuming. Allow partial success while recording which sources and decoders succeeded separately.

Hashes, Kerberos keys, trust secrets, and histories have different output schemas. When -trust-keys and -outputfile are used together, trust keys are saved to <base>.ntds.trustkeys separately from the usual <base>.ntds. -history also includes previous trust secrets, and -just-dc-ntlm also applies to derivation of Kerberos keys from trust keys. AES keys from a trust secret use two salts when the NetBIOS/flat name is known: {REALM_FQDN}krbtgt{PARTNER_FQDN} for the on-the-wire inter-realm key, and {REALM_FQDN}krbtgt{FLAT} labeled (trust account) for the <FLAT>$ login key. Incoming trusts use the partner’s flat name; outgoing trusts use the local domain’s flat name. If that flat name cannot be read, the trust-account key is omitted rather than guessed from the DNS label. Keep decoder byte processing separate from formatting. cleanup() restores remote resources even on exception paths. Connect new acquisition methods to the same raw-record contract rather than embedding them in existing decoders.

SymbolLocationWhere to trace its responsibility
DumpSecrets74__init__(), connect(), ldapConnect(), dump(), cleanup()
ModuleMain names used
impacketversion
impacket.exampleslogger
impacket.examples.utilsparse_target
impacket.smbconnectionSMBConnection
impacket.ldap.ldapLDAPConnection, LDAPSessionError
impacket.examples.secretsdumpKeyListSecrets, LSASecrets, LocalOperations, NTDSHashes, RemoteOperations, SAMHashes
impacket.krb5.keytabKeytab

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.
  • Some paths use temporary resources such as remote services, tasks, files, shares, and WMI/RPC resources. Cleaning them up after an abnormal exit is part of the behavior contract.
  • On failure, use protocol status codes to determine whether name resolution, connection, authentication, service state, or permissions caused the stop.
  • Cleanup-related methods include cleanup(). Check that new early returns and exception paths reach it too.

The code depends on shared implementation in impacket.examples.secretsdump, SMB, LDAP, DRS/RPC, and Kerberos keytabs. CLI class DumpSecrets handles orchestration across paths and option consistency, so keep new acquisition methods separate from decoders.