> 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/xxe-via-malicious-image-upload.md).

# XXE через загрузку вредоносного изображения

### Эксплуатация XXE через загрузку файла изображения

Эксплуатация уязвимости XXE путём отправки вредоносного изображения (SVG), которое во время обработки библиотекой Apache Batik раскрывает содержимое локального файла. Задание требует загрузить SVG-аватар, отображающий `/etc/hostname` содержимое, а затем отправить имя хоста в качестве решения.

Сайт предлагает форму для добавления d的аватара для комментариев. Перехватив d

<figure><img src="/files/1d13ef9f0888a61d45e1ee243159cac07fa176a6" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/93328b835d42f9e085b660cfed3ee9b009c56734" alt=""><figcaption></figcaption></figure>

Создайте SVG-файл, содержащий `<!DOCTYPE>` декларацию, определяющую внешнюю сущность, указывающую на `file:///etc/hostname` а затем вставьте эту сущность в SVG-текст так, чтобы после отрисовки/обработки содержимое файла было внедрено в отображаемое изображение.

```svg
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/hostname" > ]>
<svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
   <text font-size="16" x="0" y="16">&xxe;</text>
</svg>
```

<figure><img src="/files/1174baad0d72a7fadc9c414263a2fc4bd175b285" alt=""><figcaption></figcaption></figure>

После загрузки отображение аватара в разделе комментариев показывает, что сервер интерпретировал SVG и вернул значение сущности — содержимое `/etc/hostname` появляется в изображении, что позволяет получить имя хоста и отправить решение.

<figure><img src="/files/885f51d6dfcce8ad511582613232252e4ded8291" 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/xxe-via-malicious-image-upload.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.
