AS-REP Roasting Attack

Pre-authentication

History

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 V5

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.

Implementation

There are several types of pre-authenticationarrow-up-right defined by the Kerberos.

However, only the encrypted timestamp (PA-ENC-TIMESTAMP) pre-authentication method is commonly implemented.

AS-REQ Review

Pre-authentication is controlled by KDC policy.

  1. If a client attempts to request initial tickets through the AS exchange, but the pre-authentication is enabled,

  2. then the KDC will send a KRB_ERROR message which tells the client that pre-authentication is required instead of an AS_REP.

  3. The client append the required pre-authentication data to its AS_REQ message this time.

  4. 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.

ASREPRoasting Attack

The encrypted part in the KRB_AS_REP message is encrypted using the user password hash.

The predictable contentarrow-up-right in the encrypted data allows the offline attack to be conducted:

Tools

We use the script GetNPUsers.pyarrow-up-right 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:

AS-REQ Request

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:

Encrypted Part

Finally, the script outputs the encrypted partarrow-up-right in the KRB_AS_REP message:

Password Crack

We can crack the hash to get the domain user password with hashcat.

Mitigation

Last updated