Kerberoasting đ„
So youâve landed in a target network, and you have a single, low-privilege domain user account. You canât dump hashes from the Domain Controller, and you donât have local admin anywhere. What do you do? Do you pack up and go home? No. You fire up the grill, because itâs time for a Kerberoasting.
Kerberoasting is one of the most effective and stealthy attacks in any pentesterâs arsenal. Itâs a method of extracting password hashes for Active Directory service accounts and cracking them offline. The best part? You can do it as any authenticated domain user. You donât need any special privileges.
Think of it like this: Youâre a tourist in a kingdom (a low-privilege user). You walk up to the royal quartermaster (the Domain Controller) and say, âIâd like a key to the royal stableâs hayloft, please.â The quartermaster, not caring who you are, gives you a key (a Kerberos ticket). The vulnerability is that this key is made of a special metal that is secretly encrypted with the stable masterâs password. You can take this key, go back to your lab, analyze the metal, and figure out the stable masterâs password. And as it turns out, the stable master often uses a very simple password.
The âWhyâ: Service Principal Names (SPNs)
Section titled âThe âWhyâ: Service Principal Names (SPNs)âThis entire attack hinges on a feature of Kerberos called a Service Principal Name (SPN).
An SPN is essentially a unique username for a service. When a service like Microsoft SQL Server or a custom web application needs to be integrated with Kerberos authentication, an SPN is registered to the user account that runs that service. For example: MSSQLSvc/sql01.corp.local:1433
.
Hereâs the crucial part: To ensure everything works correctly, any authenticated user in the domain is allowed to request a Kerberos service ticket (a Ticket-Granting Service ticket, or TGS) for any SPN. This is a fundamental feature, not a bug.
The ticket that the Domain Controller sends back is encrypted. A portion of this ticket is encrypted with the NTLM hash of the password of the service account itself. And thatâs our golden ticket.
The Heist: From Ticket Request to Plaintext
Section titled âThe Heist: From Ticket Request to PlaintextâThe attack flow is simple, elegant, and devastatingly effective.
- Find the Targets: We ask Active Directory, âShow me all the user accounts that are being used to run servicesâ (i.e., all accounts with an SPN set).
- Request the Tickets: As our low-privilege user, we go to the Domain Controller for each of those services and say, âHi, Iâd like a ticket for the MSSQL service, please.â The Domain Controller happily gives us one. We do this for all the services we found.
- Extract the Hashes: The tickets we receive are now in our possession. We can extract the encrypted part from each ticket, which contains the service accountâs hash.
- Crack Offline: We take these extracted hashes back to our powerful cracking rig and use a tool like Hashcat to crack them.
Service account passwords are often a pentesterâs dream. They are frequently weak, rarely changed (sometimes set to ânever expireâ), and often have high privileges to run their applications.
The Tools and Commands
Section titled âThe Tools and CommandsâThe best tool for this job is Impacketâs GetUserSPNs.py
, which automates the first three steps for us.
Step 1: Request Tickets and Dump Hashes
Section titled âStep 1: Request Tickets and Dump HashesâFrom your attacker machine, run this command using your low-privilege userâs credentials.
# This will find all kerberoastable accounts and request tickets for them,# saving the crackable hashes to a file.GetUserSPNs.py -request -dc-ip 192.168.1.10 'corp.local/j.smith:Password123!' -outputfile kerberoastable_hashes.txt
-request
: Tells the tool to actually request the TGS tickets.-dc-ip 192.168.1.10
: The IP of the Domain Controller.'corp.local/j.smith:Password123!'
: Your compromised userâs credentials.-outputfile
âŠ: The file where the extracted, crackable hashes will be saved.
Step 2: Crack with Hashcat
Section titled âStep 2: Crack with HashcatâNow, take kerberoastable_hashes.txt
and feed it to Hashcat
. The hash mode for these Kerberos TGS tickets is 13100.
hashcat -m 13100 kerberoastable_hashes.txt /usr/share/wordlists/rockyou.txt
If any of the service accounts have a weak password that exists in your wordlist, Hashcat will pop it in minutes. You now have the plaintext password for a service account, which could be anything from a simple web admin to a full-blown Domain Admin.
Mitigation: How to Stop the BBQ
Section titled âMitigation: How to Stop the BBQâ-
STRONG PASSWORDS: This is the number one defense. Service account passwords should be long (25+ characters) and complex. Since a human doesnât need to type them, thereâs no excuse for them to be weak.
-
Use Group Managed Service Accounts (gMSA): This is the modern, preferred way to run services. gMSAs use automatically managed, complex 240-character passwords that are rotated regularly by Active Directory itself, making them impossible to crack.
-
Principle of Least Privilege: A service account for a web server does not need to be a member of the Domain Admins group. Grant it only the permissions it absolutely needs to function.
-
Monitoring: It is possible to detect Kerberoasting by monitoring for an unusual number of TGS ticket requests, especially for tickets using weaker RC4 encryption. However, this can be difficult to distinguish from normal network traffic.