> 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-vulnerabilities/race-condition-attack/race-condition-rce-pentesting-web.md).

# RCE par condition de concurrence

Voici l’interface où nous **nous entrons** notre nom :

<figure><img src="/files/b422b369a6dd5ab0fdb23f280e8eda30920656ce" alt=""><figcaption></figcaption></figure>

Ce nom **apparaît dans l’URL** en GET avec le format ci-dessous :

<figure><img src="/files/3de62d8bfc4170218d1528b1c01ec54137061c5c" alt=""><figcaption></figcaption></figure>

Voici le code que nous allons essayer de compromettre. Il crée un **hello.sh** fichier temporaire avec le nom fourni :

<figure><img src="/files/74ca150b26d010fdd6c3992e22a341fe8e93e74d" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/b9fe7a20ea114de63123ac76626c21ddc50878da" alt=""><figcaption></figcaption></figure>

Cela signifie que, puisque Bash est en cours d’exécution, nous pouvons **exécuter des commandes**, mais dans ce cas, une erreur se produit :

<figure><img src="/files/df9aa5743c11ef09282a4b640db36ffa4023c82c" alt=""><figcaption></figcaption></figure>

Le **erreur** se produit parce qu’il y a une petite validation des **caractères autorisés**. MAIS d’abord, la commande est exécutée, puis la validation a lieu :

<figure><img src="/files/37b1c6354d90ebca735fb8b5570b9c1f6bc9954b" alt=""><figcaption></figcaption></figure>

Nous profitons tous du fait qu’il y a quelques **millisecondes** avant que le script soit exécuté avant d’être validé en envoyant de nombreuses requêtes et en **réussissant à voir le contenu**:

```bash
whithe true; do cat hello.txt | grep -v "test"; done

```

<figure><img src="/files/b711cdd448e29354da6f55ac5f832425b86bbea2" alt=""><figcaption></figcaption></figure>

Dans un cas réel où nous n’aurions pas **aucun accès** au fichier "hello.txt", nous utilisons **curl** comme suit

1. nous nous fixons **en requêtes de l’écouteur** en filtrant par le champ qui nous intéresse :

```bash
whithe true; do curl -s -X GET 'http://localhost:5000/?action=run' | grep "Check this out" | html2text | xargs; done

```

2. Nous lançons une attaque par force brute **jusqu’à ce que la condition soit remplie**

```bash
whithe true; do curl -s -X GET 'http://localhost:5000/?person=`id`&action=validate'; done

```

<figure><img src="/files/e37c5d4cd1c16a96140524883303befb6cf08714" 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-vulnerabilities/race-condition-attack/race-condition-rce-pentesting-web.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.
