> 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/xss.md).

# 跨站脚本攻击（XSS）

跨站脚本攻击、反射型 XSS、存储型 XSS、DOM XSS、CSP 绕过、AngularJS 沙箱逃逸、Cookie 窃取和凭据捕获。

用于 PortSwigger Web 安全学院实验的 XSS 笔记，侧重于实用测试步骤、Burp Suite 验证、载荷行为和利用流程。

## 测试流程

1. 识别存在漏洞的功能，以及相关的请求、参数、请求头、Cookie 或浏览器端 sink。
2. 在进一步发起攻击之前，先在 Burp Suite 中使用最小有效载荷复现该行为。
3. 使用清晰的概念验证来验证影响，例如账户访问、数据泄露、代码执行、SSRF 或状态变更。
4. 在记录利用路径时，保持有效载荷、URL、令牌和实验室凭据不变。

## 实验

<table><thead><tr><th data-type="content-ref"></th></tr></thead><tbody><tr><td><a href="/zh/web/xss/angularjs-sandbox-escape-with-csp.md">带 CSP 的 AngularJS 沙箱逃逸</a></td></tr><tr><td><a href="/zh/web/xss/angularjs-sandbox-escape-without-strings.md">不使用字符串的 AngularJS 沙箱逃逸</a></td></tr><tr><td><a href="/zh/web/xss/cookie-theft-via-xss.md">通过 XSS 窃取 Cookie</a></td></tr><tr><td><a href="/zh/web/xss/dom-xss-in-href-attribute-with-jquery-location-search.md">使用 jQuery 和 location.search 在 href 属性中的 DOM XSS</a></td></tr><tr><td><a href="/zh/web/xss/dom-xss-in-angularjs-with-encoded-angle-brackets-and-quotes.md">AngularJS 中的 DOM XSS，带编码的尖括号和引号</a></td></tr><tr><td><a href="/zh/web/xss/dom-xss-with-innerhtml-and-location-search.md">使用 innerHTML 和 location.search 的 DOM XSS</a></td></tr><tr><td><a href="/zh/web/xss/dom-xss-with-jquery-hashchange-event.md">使用 jQuery 和 hashchange 的 DOM XSS</a></td></tr><tr><td><a href="/zh/web/xss/password-capture-via-xss.md">通过 XSS 捕获密码</a></td></tr><tr><td><a href="/zh/web/xss/reflected-xss-in-a-javascript-string-with-html-encoded-angle-brackets.md">JavaScript 字符串中的反射型 XSS，带 HTML 编码的尖括号</a></td></tr><tr><td><a href="/zh/web/xss/reflected-xss-protected-by-strict-csp-with-dangling-markup.md">受非常严格 CSP 保护的反射型 XSS：通过悬挂标记进行攻击</a></td></tr><tr><td><a href="/zh/web/xss/reflected-xss-with-svg-tags-allowed.md">带允许 SVG 标签的反射型 XSS</a></td></tr><tr><td><a href="/zh/web/xss/stored-xss-in-anchor-href-with-encoded-quotes.md">锚点 href 中的存储型 XSS，带编码的引号</a></td></tr><tr><td><a href="/zh/web/xss/stored-xss-in-html-context-without-encoding.md">HTML 上下文中的存储型 XSS，未编码</a></td></tr><tr><td><a href="/zh/web/xss/stored-xss-in-onclick-with-full-encoding.md">onclick 中的存储型 XSS，完全编码</a></td></tr><tr><td><a href="/zh/web/xss/dom-xss-document-write-with-location-search.md">使用 location.search 的 XSS DOM document.write</a></td></tr><tr><td><a href="/zh/web/xss/reflected-dom-xss.md">XSS DOM 反射型</a></td></tr><tr><td><a href="/zh/web/xss/stored-dom-xss.md">XSS DOM 存储型</a></td></tr><tr><td><a href="/zh/web/xss/xss-dom-with-document-write-inside-a-select.md">在 Select 中使用 document.write 的 XSS DOM</a></td></tr><tr><td><a href="/zh/web/xss/xss-in-a-javascript-string-with-apostrophe-and-backslash-escaped.md">JavaScript 字符串中的 XSS，单引号和反斜杠已转义</a></td></tr><tr><td><a href="/zh/web/xss/xss-in-a-javascript-string-with-encoded-angle-brackets-encoded-double-quotes-and-escaped-apostrophe.md">JavaScript 字符串中的 XSS，带编码的尖括号、编码的双引号和已转义的单引号</a></td></tr><tr><td><a href="/zh/web/xss/xss-in-javascript-url-with-limited-characters.md">字符受限的 JavaScript URL 中的 XSS</a></td></tr><tr><td><a href="/zh/web/xss/xss-in-template-literal-with-escaped-unicode.md">带转义 Unicode 字符的字面模板中的 XSS</a></td></tr><tr><td><a href="/zh/web/xss/xss-reflected-in-an-attribute-with-encoded-angle-brackets.md">带编码尖括号的属性中反射型 XSS</a></td></tr><tr><td><a href="/zh/web/xss/reflected-xss-in-html-with-blocked-tags.md">带被阻止标签的 HTML 中反射型 XSS</a></td></tr><tr><td><a href="/zh/web/xss/reflected-xss-in-html-without-encoding.md">未编码的 HTML 中反射型 XSS</a></td></tr><tr><td><a href="/zh/web/xss/reflected-xss-in-canonical-link-tag.md">Canonical 标签中的反射型 XSS</a></td></tr><tr><td><a href="/zh/web/xss/reflected-xss-with-custom-tags-only.md">仅使用自定义标签的反射型 XSS</a></td></tr><tr><td><a href="/zh/web/xss/xss-to-bypass-csrf-defenses.md">用于绕过 CSRF 防御的 XSS</a></td></tr><tr><td><a href="/zh/web/xss/xss-with-blocked-events-and-href-attributes.md">带被阻止事件和 href 属性的 XSS</a></td></tr><tr><td><a href="/zh/web/xss/xss-with-csp-bypass.md">带 CSP 及绕过技术的 XSS</a></td></tr></tbody></table>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/zh/web/xss.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
