Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบเครือข่าย >> ความปลอดภัยเครือข่าย

KDC (Key Distribution Center) ในความปลอดภัยเครือข่ายคืออะไร?

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)

  1. AS Request (KRB_AS_REQ): Client → KDC (AS): User ID (Principal Name) + Timestamp (Pre-auth: Encrypted Timestamp with Client Key)
  2. AS Reply (KRB_AS_REP): KDC (AS) → Client: TGT (Encrypted with KDC's Secret Key/krbtgt) + Session Key (Client-TGS) (Encrypted with Client Key)
  3. TGS Request (KRB_TGS_REQ): Client → KDC (TGS): TGT + Target SPN (Service Principal Name) + Authenticator (Timestamp + Client Name, Encrypted with Client-TGS Session Key)
  4. 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)
  5. AP Request (KRB_AP_REQ): Client → Target Server: Service Ticket + Authenticator (Timestamp, Encrypted with Client-Server Session Key)
  6. 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 และการป้องกัน

🛠️ การจัดการและตรวจสอบ KDC

  • Time Synchronization (Critical!): NTP ทุก DC/Client ผ่อนคลาย ≤ 5 นาที (Default) ไม่งั้น Kerberos Fail
  • Event Logs (Security Log): 4768 (TGT Request), 4769 (Service Ticket Request), 4770 (Ticket Renewal), 4771 (Pre-auth Failed) - ส่งไป SIEM
  • Tools: klist (View Tickets), kinit (Get TGT Linux/Mac), setspn (Manage SPNs), Rubeus (Offensive/Testing), BloodHound (AD Graph Analysis), PingCastle (AD Health Check)
  • KRBTGT Rotation: วางแผนเปลี่ยน KRBTGT Password เป็นระยะ (Scripted, Tested, Double Reset)

📋 สรุป

KDC = Heart of Kerberos = Trusted Third Party ที่ออก TGT (AS) และ Service Tickets (TGS) ใช้ Symmetric Keys (derive จาก Passwords) และ Session Keys (Random) ทำให้ได้ SSO, Mutual Auth, No Password on Wire ใน AD: DC = KDC ความปลอดภัยของ KDC = ความปลอดภัยของ KRBTGT Key + Service Account Keys + Time Sync + Monitoring

โจมตีเป้าหมายการป้องกัน
Kerberoastingขอ Service Ticket (TGS-REQ) สำหรับ SPN ที่มี Password อ่อน → Crack Offline ได้ Service Account HashService 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) → ใช้เข้าถึงทรัพยากรโดยไม่ต้องรู้ PasswordProtected 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 KeyPatch LSASS บน DC ให้รับ Master Password ใดๆ ก็ได้ (Backdoor)Credential Guard, Monitoring DC Integrity, ATA/Defender for Identity