作者:selph
前言
窥探Ring0漏洞世界:释放后重用漏洞
这也是个很有趣的漏洞类型,对象释放后没有清除对象指针,以至于可能在相同的位置出现假的对象,而让程序认为对象没有被释放是可用的状态,从而执行了假的对象行为。
实验环境:
•虚拟机:Windows 7 x86
•物理机:Windows 10 x64
•软件:IDA,Windbg,VS2022
漏洞分析
本例漏洞需要多个函数调用里,直接上源码来看吧
AllocateUaFObjectNonPagedPool:
///
/// Allocate the UaF object in NonPagedPool
///
/// NTSTATUS NTSTATUS AllocateUaFObjectNonPagedPool( VOID ) { NTSTATUS Status = STATUS_UNSUCCESSFUL; PUSE_AFTER_FREE_NON_PAGED_POOL UseAfterFree = NULL; PAGED_CODE(); __try { DbgPrint("[ ] Allocating UaF Objectn"); // // Allocate Pool chunk // UseAfterFree = (PUSE_AFTER_FREE_NON_PAGED_POOL)ExAllocatePoolWithTag( NonPagedPool, sizeof(USE_AFTER_FREE_NON_PAGED_POOL), (ULONG)POOL_TAG ); if (!UseAfterFree) { // // Unable to allocate Pool chunk // DbgPrint("[-] Unable to allocate Pool chunkn"); Status = STATUS_NO_MEMORY; return Status; } else { DbgPrint("[ ] Pool Tag: %sn", STRINGIFY(POOL_TAG)); DbgPrint("[ ] Pool Type: %sn", STRINGIFY(NonPagedPool)); DbgPrint("[ ] Pool Size: 0x%zXn", sizeof(USE_AFTER_FREE_NON_PAGED_POOL)); DbgPrint("[ ] Pool Chunk: 0x%pn", UseAfterFree); } // // Fill the buffer with ASCII 'A' // RtlFillMemory((PVOID)UseAfterFree->Buffer, sizeof(UseAfterFree->Buffer), 0x41); // // Null terminate the char buffer // UseAfterFree->Buffer[sizeof(UseAfterFree->Buffer) - 1] = '