> 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/basic-os-command-injection.md).

# Injection de commandes OS basique

### Injection de commandes du système d'exploitation

Ce laboratoire présente une vulnérabilité d'injection de commandes système dans l'outil de vérification de stock d'un produit. / L'application exécute une commande shell qui inclut les identifiants du produit et du magasin fournis par l'utilisateur, puis renvoie directement la sortie brute de cette commande dans la réponse.

L'objectif du laboratoire est d'exécuter la **whoami** commande pour identifier le nom de l'utilisateur actuel.

Nous constatons que, sous Linux, lorsque vous saisissez une commande comme :

```bash
pwd
```

il est possible d'enchaîner plusieurs commandes à l'aide d'un point-virgule :

```bash
pwd;whoami
```

<figure><img src="/files/149093dbd5877c6fca3ab0e55bb3570f28f5151c" alt="" width="563"><figcaption></figcaption></figure>

Dans ce cas, deux paramètres sont transmis.

<figure><img src="/files/a79d353a50cbc5618fd4f33f782f4c3645942bb9" alt="" width="563"><figcaption></figcaption></figure>

Si l'on insère un **;** dans l'un ou l'autre, on peut exécuter une commande arbitraire parce que le backend utilise une fonction du type **system**.

Exemple :

```bash
productId=1&storeId=1;ls -l
```

<figure><img src="/files/58df37974aafebca35966f1ad62bbaeb94b09b9b" 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/basic-os-command-injection.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.
