KDC (Key Distribution Center) คืออะไร?
KDC (Key Distribution Center) คือ เซิร์ฟเวอร์กลางที่เชื่อถือได้ (Trusted Third Party) ซึ่งเป็นหัวใจของโปรโตคอล Kerberos ทำหน้าที่ แจกจ่ายคีย์ (Key Distribution) และ ยืนยันตัวตน (Authentication) ให้กับ Client และ Server ในเครือข่าย เพื่อให้สามารถสื่อสารกันได้อย่างปลอดภัยโดยไม่ต้องส่งรหัสผ่านผ่านเครือข่าย
🏗️ โครงสร้าง KDC (2 บริการหลัก)
| บริการ (Service) | ชื่อ | หน้าที่ | Output |
|---|---|---|---|
| Authentication Service (AS) | AS | ยืนยันตัวตน Client เริ่มต้น (Initial Authentication) | Ticket Granting Ticket (TGT) + Session Key (Client-TGS) |
| Ticket Granting Service (TGS) | TGS | ออก Service Ticket ให้ Client เข้าถึง Server เป้าหมาย | Service Ticket + Session Key (Client-Server) |
ใน Microsoft Active Directory: Domain Controller (DC) = KDC (รัน AS และ TGS บน DC ทุกตัว)
🔄 กระบวนการทำงานของ KDC (Kerberos Flow)
- AS Request (KRB_AS_REQ): Client → KDC (AS): User ID (Principal Name) + Timestamp (Pre-auth: Encrypted Timestamp with Client Key)
- AS Reply (KRB_AS_REP): KDC (AS) → Client: TGT (Encrypted with KDC's Secret Key/krbtgt) + Session Key (Client-TGS) (Encrypted with Client Key)
- TGS Request (KRB_TGS_REQ): Client → KDC (TGS): TGT + Target SPN (Service Principal Name) + Authenticator (Timestamp + Client Name, Encrypted with Client-TGS Session Key)
- TGS Reply (KRB_TGS_REP): KDC (TGS) → Client: Service Ticket (Encrypted with Server's Secret Key) + Session Key (Client-Server) (Encrypted with Client-TGS Session Key)
- AP Request (KRB_AP_REQ): Client → Target Server: Service Ticket + Authenticator (Timestamp, Encrypted with Client-Server Session Key)
- AP Reply (KRB_AP_REP) - Optional: Server → Client: Timestamp+1 (Encrypted with Client-Server Session Key) → Mutual Authentication
🔑 คีย์ที่ KDC ใช้ (Key Hierarchy)
- User's Long-term Key: Derived from Password (String2Key: PBKDF2/HMAC-SHA1/AES) → ใช้ถอดรหัส TGT & Client-TGS Session Key
- Service's Long-term Key: Derived from Service Account Password / Keytab → ใช้ถอดรหัส Service Ticket
- KDC's Secret Key (krbtgt): ใช้เซ็น/เข้ารหัส TGT (Critical! → Golden Ticket Attack)
- Session Keys: สร้างแบบสุ่ม (Random) ต่อ Session ใช้เข้ารหัส Authenticator และ Application Data
🌐 KDC ใน Active Directory (AD)
- ทุก Domain Controller (DC) เป็น KDC (Multi-master Replication)
- DNS SRV Records ค้นหา KDC:
_kerberos._udp.dc._msdcs.domain.com(Port 88 UDP/TCP) - Read-Only Domain Controller (RODC): มี KDC แต่ไม่เก็บ krbtgt key ของโดเมนหลัก (มี krbtgt key ของตัวเอง) ป้องกันการโจมตีที่สาขา
- Trust Relationships: KDC ระหว่างโดเมนที่ Trust กันแลกเปลี่ยน Inter-realm Keys (Trust Keys) เพื่อออก Cross-realm TGTs
⚠️ โจมตีที่เกี่ยวข้องกับ KDC และการป้องกัน
| โจมตี | เป้าหมาย | การป้องกัน |
|---|---|---|
| Kerberoasting | ขอ Service Ticket (TGS-REQ) สำหรับ SPN ที่มี Password อ่อน → Crack Offline ได้ Service Account Hash | Service Account Password ยาวซับซ้อน (>25 chars), gMSA (Group Managed Service Accounts), แจ้งเตือน Event ID 4769 (TGS Request) แบบผิดปกติ |
| AS-REP Roasting | ขอ TGT (AS-REQ) สำหรับ User ที่ไม่ตั้งค่า Pre-authentication (DONT_REQ_PREAUTH) → ได้ AS-REP ที่มีส่วนเข้ารหัสด้วย User Key → Crack Offline | บังคับ Pre-authentication สำหรับทุก User (Default ใน AD ใหม่), Audit UserAccountControl flags |
| Pass-the-Ticket (PtT) | ขโมย TGT/Service Ticket จาก LSASS Memory (Mimikatz, Rubeus) → ใช้เข้าถึงทรัพยากรโดยไม่ต้องรู้ Password | Protected Users Group, Credential Guard (VBS), LSASS Protection (RunAsPPL), Monitoring 4769/4770, Restrict Delegation |
| Golden Ticket | ปลอม TGT ด้วย KRBTGT Hash (Golden Ticket) → เป็น Domain Admin ได้ทุกอย่าง นาน 10 ปี (Default) | เปลี่ยน KRBTGT Password 2 ครั้ง (Double Reset) ทุก 6-12 เดือน / หลังเหตุการณ์, Monitoring, Tiered Admin (Red Forest/ESAE) |
| Silver Ticket | ปลอม Service Ticket ด้วย Service Account Hash → เข้าถึงบริการนั้นๆ ได้อย่างเดียว | Service Account Password แข็งแกร่ง, gMSA, Resource-based Constrained Delegation (RBCD) |
| Skeleton Key | Patch LSASS บน DC ให้รับ Master Password ใดๆ ก็ได้ (Backdoor) | Credential Guard, Monitoring DC Integrity, ATA/Defender for Identity |