> 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/xss-reflected-in-an-attribute-with-encoded-angle-brackets.md).

# 带编码尖括号的属性中反射型 XSS

### 带有 HTML 编码尖括号的属性反射型 XSS

此实验室在博客的搜索功能中包含一个反射型 XSS 漏洞：用户提供的内容会被注入到一个 `值` 属性中 `<input>`，并且 `<` 和 `>` 尖括号会在 HTML 中被编码（`&lt;`, `&gt;`）。目标是注入一个可触发 `alert()`.

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

#### 观察

* 输入的文本会出现在 `值` 输入框的属性中。
* 尝试插入 `">test` 会因尖括号被编码而失效，因此不能通过这种方式打开新标签。

```
">test
```

<figure><img src="/files/5c156e2c2dcb8735782a5e0abdd1ac08b8134f86" alt=""><figcaption></figcaption></figure>

不过，由于该值被引号包围，可以关闭 `值` 该值并向同一个 `<input>` 元素中注入包含结束引号的序列来添加一个新属性。

```javascript
hola" test="hello
```

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

1. 关闭 `值` 通过注入的双引号结束该值。
2. 添加一个新的事件属性（例如 `onmouseover`），其中包含对 `alert()`.

```javascript
test" onmouseover="alert(0)
```

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

* 有效载荷关闭 `值` 该属性并添加 `onmouseover="alert(0)"` 到 `<input>` 元素中。

<figure><img src="/files/100424e08f688383ba890fd3b8172295b982fcfd" 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/xss/xss-reflected-in-an-attribute-with-encoded-angle-brackets.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.
