AS-REP Roasting Attack
Last updated
Last updated
The original Kerberos 4 protocol was susceptible to an offline dictionary and brute-force attacks since the KDC happily provides a ticket encrypted with the principals’ secret key to any requestor.
Kerberos 5 introduces pre-authentication which requires that requestors prove their identity by demonstrating the knowledge of the user's credentials before the KDC will issue a ticket for a particular principal.
There are several types of pre-authentication defined by the Kerberos.
However, only the encrypted timestamp (PA-ENC-TIMESTAMP) pre-authentication method is commonly implemented.
Pre-authentication is controlled by KDC policy.
If a client attempts to request initial tickets through the AS exchange, but the pre-authentication is enabled,
then the KDC will send a KRB_ERROR
message which tells the client that pre-authentication is required instead of an AS_REP.
The client append the required pre-authentication data to its AS_REQ message this time.
If the pre-authentication data is accepted, the KDC responds with an AS reply including the TGT ticket. Otherwise, the KDC will response another KRB_ERROR message that indicates pre-authentication failed.
Refer to the Kerberos authentication service.
The encrypted part in the KRB_AS_REP
message is encrypted using the user password hash.
The predictable content in the encrypted data allows the offline attack to be conducted:
We use the script GetNPUsers.py
to conduct the attack, for example in the HackTheBox lab machine Forest
, we use this script to get the TGT ticket for the user svc-alfresco
:
After parsing the arguments, the script initializes the class GetUserNoPreAuth
with domain account credentials:
If a file of user names is provided, the class call its method reques_users_file_TGTs
to get the TGT ticket for each account name if the pre-authentication is disabled.
If doKerberos
is set or no_pass
is false, the script will do the LDAP search to find domain accounts with property Do not require Kerberos preauthentication
setUF_DONT_REQUIRE_PREAUTH
:
Also, we can use this filter with the command ldapsearch
to get the same results:
Either way, the class will call its method getTGT
to try to get the TGT ticket for an account.
First, the method prepare the AS_REQ message:
Then it sends the AS_REQ
, receives, and parses the `AS_REP` response:
Finally, the script outputs the encrypted part in the KRB_AS_REP
message:
We can crack the hash to get the domain user password with hashcat
.