What is Kerberos?
Kerberos is a secure network authentication protocol, widely used as the default authentication mechanism for Microsoft Windows domains. It uses a ticket-based system and strong encryption to authenticate users and services securely. Kerberos improves on older protocols like NTLM by employing third-party ticket authorization and enhanced security measures. However, it still has exploitable vulnerabilities that attackers can leverage.
How Does Kerberos Work?
Kerberos operates as a Single Sign-On (SSO) protocol using a ticket-based authentication scheme. The user’s password is stored as a hashed value in the Security Account Manager (SAM) database on Windows systems:
|
|
Key steps in Kerberos authentication:
- Password Hash Encryption: The user’s password hash is used to encrypt authentication messages.
- Server Decryption: The server validates the user by decrypting the messages with the stored password hash.
Common Terminology in Kerberos
- Ticket Granting Ticket (TGT): An authentication ticket used to request service tickets for accessing domain resources.
- Key Distribution Center (KDC): A central service that issues TGTs and service tickets. It includes:
- Authentication Service (AS): Issues TGTs to users.
- Ticket Granting Service (TGS): Issues service tickets based on valid TGTs.
- Service Principal Name (SPN): An identifier for a specific service instance linked to a domain service account.
- Long Term Secret Keys:
- KDC LT Key: Encrypts TGTs and signs the Privilege Attribute Certificate (PAC).
- Client LT Key: Encrypts timestamps and session keys during authentication.
- Service LT Key: Encrypts service tickets and signs the PAC.
- Session Key: A temporary key issued for communication between the client and services.
- Privilege Attribute Certificate (PAC): Contains user information, including privileges, signed to validate authenticity.
How Kerberos Works: Step-by-Step
1. Authentication Phase (Getting a TGT)
- User Login: The user enters their password, which is hashed (e.g., SHA-256).
- Request to AS: The client sends the username to the Authentication Service (AS).
- TGT Creation: The AS verifies the user, generates a TGT, and encrypts it using the user’s password hash.
- Receive TGT: The client decrypts the TGT to authenticate and holds the TGT for future service requests.
2. Ticket Granting Phase (Getting a Service Ticket)
- Request to TGS: The client sends the TGT and an Authenticator (timestamp encrypted with the session key) to the TGS.
- Service Ticket Creation: The TGS verifies the TGT and Authenticator, then issues a Service Ticket encrypted with the target service’s key.
- Receive Service Ticket: The client uses this ticket to access the requested service.
3. Service Access Phase (Using the Service Ticket)
- Service Request: The client sends the Service Ticket and a new Authenticator to the target service.
- Access Validation: The service validates the ticket and Authenticator, granting access if they are valid.
Kerberos Tickets Overview
- TGT (Ticket Granting Ticket): Used to request service tickets from the KDC.
- Service Tickets: Specific to services, allowing users to authenticate and access resources.
Tickets can be represented in different formats (e.g., .kirbi for Rubeus or .ccache for Impacket) and may be base64-encoded for certain attacks.
Steps in Kerberos Authentication
- AS-REQ: The client requests a TGT from the AS.
- AS-REP: The AS sends back an encrypted TGT.
- TGS-REQ: The client sends the TGT to the TGS with the SPN of the service.
- TGS-REP: The TGS validates the TGT and sends a Service Ticket.
- AP-REQ: The client requests the service with the Service Ticket.
- AP-REP: The service validates the ticket and grants access.
Attacking the Kerberos Protocol
Kerbrute
A powerful tool for enumerating Active Directory users by exploiting Kerberos pre-authentication vulnerabilities.
Examples:
These commands attempt to brute-force and enumerate valid usernames by sending requests to the KDC.
Kerberos remains a critical authentication protocol in modern networks. While it enhances security, understanding its mechanics and vulnerabilities is essential for both defensive and offensive cybersecurity operations.