> 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/race-conditions/exploitation-of-time-sensitive-vulnerabilities.md).

# استغلال الثغرات الحساسة للوقت

### استغلال الثغرات الحساسة للوقت

### سياق المختبر

يوفر الموقع ميزة **إعادة تعيين كلمة المرور** عبر رابط يُرسل بالبريد الإلكتروني. / لا توجد حالة تنافس حقيقية على جانب منطق التطبيق، لكن إنشاء **الرموز المميزة** هو **مبنيّ**: فهو يعتمد على **قيمة يمكن التنبؤ بها** (الوقت)، مما يسمح بتزوير رمز صالح لمستخدم آخر عبر إرسال الطلبات \*\* في الوقت نفسه\*\*.

<figure><img src="/files/64b616dabde7405480cceafda19aa893b58b027c" alt=""><figcaption></figcaption></figure>

### ملاحظات أولية

1. نستخدم **نسيت كلمة المرور** مع المستخدم `wiener`.

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

* رسالة بريد إلكتروني تحتوي على رابط من النوع:
* `/forgot-password?user=wiener&token=<token>`

{% code overflow="wrap" %}

```bash
مرحبًا!

يرجى اتباع الرابط أدناه لإعادة تعيين كلمة المرور الخاصة بك.

https://0a1300c9040343bf810b7f2a00e60085.web-security-academy.net/forgot-password?user=wiener&token=3930dc6d3d076151204ad4147326f81a5e1609a8
```

{% endcode %}

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

* يبدو الرمز المميز كأنه **SHA1** (40 حرفًا سداسيًا عشريًا).

`forgot-password?user=wiener&token=3930dc6d3d076151204ad4147326f81a5e1609a8`

<figure><img src="/files/1c16f95001513d989c4a0f107d21cada95f4b6a6" alt=""><figcaption></figcaption></figure>

* يبدو الرمز المميز كأنه **SHA1** (40 حرفًا سداسيًا عشريًا).

```bash
hashid '3930dc6d3d076151204ad4147326f81a5e1609a8'
```

<figure><img src="/files/86a65034d54376eae08a433454ba39e1880d84a6" alt=""><figcaption></figcaption></figure>

1. من خلال إنشاء عدة رموز مميزة

الافتراض: الرمز المميز مشتق أساسًا من **طابع زمني** (أو قيمة تعتمد على الوقت)، بدلًا من سر قوي.

<figure><img src="/files/0a51e93bca7f4687913e089820c89045efd8f538" alt="" width="563"><figcaption></figcaption></figure>

### الفكرة الرئيسية: إجبار طلبين على الحدوث في نفس الملي ثانية

إذا استطعنا تشغيل **إعادة تعيينين** في الوقت نفسه، وكان الرمز المميز يعتمد فقط على التوقيت، فإن **الرمزين المميزين سيكونان متطابقين**.

<figure><img src="/files/25e3a332bf8fb4fa600a19e872e102ff1a799484" alt=""><figcaption></figcaption></figure>

المشكلة: يتجنب الخادم (PHP) أحيانًا التعارضات مع نفس الجلسة / CSRF. / الحل: احصل على **جلستين منفصلتين**.

<figure><img src="/files/3527542e9c9716873eac0374026ab9131e6442e9" alt=""><figcaption></figcaption></figure>

### التحضير: الحصول على زوجين من الجلسة + CSRF

يتم إرسال طلبين منفصلين إلى:

* `GET /forgot-password`

```http
GET /forgot-password HTTP/2
Host: 0a1300c9040343bf810b7f2a00e60085.web-security-academy.net
Cookie:
```

كل إجابة تمنح زوجًا جديدًا:

* `PHPSESSID=<...>`
* رمز CSRF جديد (القيمة مخفية في النموذج)

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

هناك **طلبان جاهزان**، وكل منهما يحتوي على:

* خاصته `PHPSESSID` ملف تعريف الارتباط
* حقل CSRF المرتبط به

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

### المُشغِّل: الإرسال بالتوازي

ثم نرسل **بالتوازي** طلبَي POST لإعادة التعيين (نفس نقطة النهاية)، في Burp (تجميع + إرسال بالتوازي)، بحيث يصلا **في نفس النافذة الزمنية**.

<figure><img src="/files/98cb9e2a160d69f8ae13f6b7cafd802f3da7771c" alt=""><figcaption></figcaption></figure>

النتيجة الملاحظة: تحتوي رسالتا البريد المستلمتان على \*\* نفس الرمز المميز تمامًا\*\*:

```bash
933ccbd314dc37df95887cd914b07e330517f7bb
933ccbd314dc37df95887cd914b07e330517f7bb
```

<figure><img src="/files/03faecb755c119b720dcbd06ddca5d948c222a33" alt=""><figcaption></figcaption></figure>

الخلاصة: يعتمد الرمز المميز أساسًا على **طابع زمني**، وليس على سر واحد لكل مستخدم.

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

### العملية: إعادة تعيين كارلوس باستخدام رمز وينر

الهدف: رمز صالح لـ `carlos`.

الطريقة:

1. أطلق عمليتي إعادة تعيين بالتوازي:

* واحدة لـ `wiener`
* واحدة لـ `carlos`

```bash
forgot-password?user=wiener&token=da1d6e3ed67bef3efa9fe74fcfbf7603120ea744
forgot-password?user=carlos&token=da1d6e3ed67bef3efa9fe74fcfbf7603120ea744
```

بما أن الرموز المميزة متطابقة، فإن الرمز المستلم (مثلًا عبر `wiener` البريد الإلكتروني) سيكون صالحًا أيضًا لـ `carlos`.

إذا قبل الموقع هذا الرابط، فيمكنك **تعيين كلمة مرور جديدة** لـ `carlos`.

<figure><img src="/files/76e65dc5714e0532c755022a2aacb541c5f5e18e" alt=""><figcaption></figcaption></figure>

### إكمال المختبر

1. تسجيل الدخول باسم `carlos` باستخدام كلمة المرور الجديدة.
2. الوصول إلى \*\*تسجيل دخول المسؤول\*\*.
3. إزالة `carlos` المستخدم للتحقق من المختبر.

<figure><img src="/files/ed53b70158b58bc5d424582b218e60fc9dbcbbf1" 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/race-conditions/exploitation-of-time-sensitive-vulnerabilities.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.
