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

# Race-Condition-RCE

Hier ist die Schnittstelle, wo wir **eintreten** unseren Namen:

<figure><img src="/files/9be24f80c65c63f7be0233e3187ee0c9f22586f1" alt=""><figcaption></figcaption></figure>

Dieser Name **erscheint in der URL** in GET im folgenden Format:

<figure><img src="/files/424c96987514f95bfe955e676a21b4ecd85cb0aa" alt=""><figcaption></figcaption></figure>

Hier ist der Code, den wir zu kompromittieren versuchen werden. Er erstellt eine temporäre **hello.sh** Datei mit dem angegebenen Namen:

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

<figure><img src="/files/0ba32672255e23e65a84468257962008d600ff05" alt=""><figcaption></figcaption></figure>

Das bedeutet, dass wir, da Bash läuft, **Befehle ausführen**aber in diesem Fall tritt ein Fehler auf:

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

Das **Fehler** tritt auf, weil es eine kleine Validierung von **zulässigen Zeichen**. ABER zuerst wird der Befehl ausgeführt, dann findet die Validierung statt:

<figure><img src="/files/40d0e7d94bec76b6976aeaef8cdf4d325c6e4515" alt=""><figcaption></figcaption></figure>

Wir nutzen alle die Tatsache aus, dass es ein paar **Millisekunden** bevor das Skript ausgeführt wird, bevor es validiert wird, und beim Senden vieler Anfragen und beim **es schaffen, den Inhalt einzusehen**:

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

```

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

In einem realen Fall, in dem wir nicht hätten **keinen Zugriff** auf die Datei "hello.txt" haben, verwenden wir **curl** wie folgt

1. wir setzen **einen Listener für Anfragen** und filtern nach dem Feld, das uns interessiert:

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

```

2. Wir starten einen Brute-Force-Angriff **bis die Bedingung erfüllt ist**

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

```

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