# DOM Invader

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>

## DOM Invader

DOM Invader是安装在Burp内置浏览器中的浏览器工具。它通过各种来源和汇聚点（包括Web消息和原型污染）帮助**检测DOM XSS漏洞**。该工具作为扩展预安装。

DOM Invader集成了浏览器的DevTools面板中的一个选项卡，实现以下功能：

1. 用于DOM XSS测试的网页上**可控汇聚点的识别**，提供上下文和清理细节。
2. 通过`postMessage()`方法**记录、编辑和重新发送**发送的Web消息，用于DOM XSS测试。DOM Invader还可以使用特制的Web消息自动检测漏洞。
3. 检测**客户端原型污染**源并扫描发送到风险汇聚点的可控小工具。
4. 识别**DOM覆盖漏洞**。

### 启用

在Burp的内置浏览器中转到**Burp扩展**并启用它：

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

现在刷新页面，在**Dev Tools**中您将找到**DOM Invader选项卡**：

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

### 注入一个Canary

在上图中，您可以看到一个**随机字符组，即Canary**。现在，您应该开始在网页的不同部分（参数、表单、URL等）**注入**它，并每次单击搜索。DOM Invader将检查**Canary是否出现在任何有趣的汇聚点**中，这些汇聚点可能会被利用。

此外，选项**注入URL参数**和**注入表单**将自动打开一个**新标签页**，在其中**注入Canary**到它找到的每个**URL**参数和**表单**中。

### 注入一个空Canary

如果您只想查找页面可能具有的潜在汇聚点，即使它们不可利用，您可以**搜索一个空Canary**。

### 发送消息

DOM Invader允许使用Web消息进行DOM XSS测试，具有以下功能：

1. **记录**通过`postMessage()`发送的Web消息，类似于Burp Proxy的HTTP请求/响应历史记录。
2. **修改**和**重新发出**Web消息以手动测试DOM XSS，类似于Burp Repeater的功能。
3. 用于探测DOM XSS的**自动更改**和发送Web消息。

#### 消息详情

单击消息后，可以查看有关每条消息的详细信息，包括客户端JavaScript是否访问消息的`origin`、`data`或`source`属性。

* **`origin`**：如果消息的**来源信息未经检查**，您可能能够从**任意外部域**向事件处理程序发送跨源消息。但如果已检查，则仍可能存在不安全性。
* **`data`**：这是发送有效载荷的地方。如果未使用此数据，则汇聚点无效。
* **`source`**：评估源属性是否已验证，通常引用一个iframe，而不是来源。即使已检查，也不能保证验证不会被绕过。

#### 回复消息

1. 从**消息**视图中，单击任何消息以打开消息详细信息对话框。
2. 根据需要编辑**数据**字段。
3. 单击**发送**。

### 原型污染

DOM Invader还可以搜索**原型污染漏洞**。首先，您需要启用它：

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

然后，它将**搜索源**，使您能够向\*\*`Object.prototype`\*\*添加任意属性。

如果找到任何内容，将出现一个**测试**按钮以**测试找到的源**。单击它，将出现一个新标签页，在控制台中创建一个对象并检查`testproperty`是否存在：

```javascript
let b = {}
b.testproperty
```

一旦找到源，您可以**扫描小工具**：

1. 单击**DOM**视图中任何已识别的原型污染源旁边的**扫描小工具**按钮时，DOM Invader会打开一个新标签页，扫描适合的小工具随即开始。
2. 与此同时，在同一标签页中，**DOM Invader**标签应该在DevTools面板中打开。扫描完成后，通过已识别的小工具可访问的任何漏洞都会显示在**DOM**视图中。例如，将传递给`innerHTML`漏洞的名为`html`的小工具属性在下面的示例中显示。

## DOM淹没

在上一张图片中，可以看到可以打开DOM淹没扫描。完成后，**DOM Invader将开始搜索DOM淹没漏洞**。

## 参考资料

* <https://portswigger.net/burp/documentation/desktop/tools/dom-invader>
* <https://portswigger.net/burp/documentation/desktop/tools/dom-invader/enabling>
* <https://portswigger.net/burp/documentation/desktop/tools/dom-invader/dom-xss>
* <https://portswigger.net/burp/documentation/desktop/tools/dom-invader/web-messages>
* <https://portswigger.net/burp/documentation/desktop/tools/dom-invader/prototype-pollution>
* <https://portswigger.net/burp/documentation/desktop/tools/dom-invader/dom-clobbering>


---

# Agent Instructions: 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:

```
GET https://hacktricks.xsx.tw/pentesting-web/xss-cross-site-scripting/dom-invader.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
