马上注册,结交更多易友,享用更多功能,让你轻松玩转觅风论坛。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
- #pragma once
-
- #include <ntddk.h>
-
- //驱动卸载
- void UnloadDriver(PDRIVER_OBJECT pDriverObject);
- void HookIoAllocateMdl();
-
- typedef PMDL (__stdcall *pIoAllocateMdl)(
- _In_opt_ PVOID VirtualAddress,
- _In_ ULONG Length,
- _In_ BOOLEAN SecondaryBuffer,
- _In_ BOOLEAN ChargeQuota,
- _Inout_opt_ PIRP Irp
- );
-
- pIoAllocateMdl g_pIoAllocateMdl = NULL;
-
- //去掉页面保护
- void ErasePageProtect()
- {
- __asm
- {
- cli
- mov eax, cr0
- and eax, not 10000h
- mov cr0, eax
- }
- }
-
- //恢复页面保护
- void RenewPageProtect()
- {
- __asm
- {
- mov eax, cr0
- or eax, 10000h
- mov cr0, eax
- sti
- }
- }
-
- ULONG g_uOldIoAllocateMdlAddr = 0;
复制代码- #include "Pass_Debugger.h"
-
- //驱动加载
- NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pStrRegPath)
- {
- UNREFERENCED_PARAMETER(pDriverObject);
- UNREFERENCED_PARAMETER(pStrRegPath);
-
- KdEnableDebugger();
- KdPrint(("驱动加载成功!\n"));
- pDriverObject->DriverUnload = UnloadDriver;
- HookIoAllocateMdl();
-
- return STATUS_SUCCESS;
- }
-
- //驱动卸载
- void UnloadDriver(PDRIVER_OBJECT pDriverObject)
- {
- UNREFERENCED_PARAMETER(pDriverObject);
-
- UCHAR uOldBytes[5] = { 0x8B, 0xFF, 0x55, 0x8B, 0xEC };
-
- KIRQL irql = KeRaiseIrqlToDpcLevel();
-
- ErasePageProtect();
- RtlCopyMemory((PVOID)g_uOldIoAllocateMdlAddr, uOldBytes, 5);
- RenewPageProtect();
- KeLowerIrql(irql);
-
- KdPrint(("驱动卸载成功!\n"));
- if (g_pIoAllocateMdl != NULL)
- {
- ExFreePool(g_pIoAllocateMdl);
- g_pIoAllocateMdl = NULL;
- }
- }
-
- //获取KdEnteredDebugger地址 直接通过extern搜索 因为它是导出的全局变量
- extern ULONG KdEnteredDebugger;
-
- PMDL HookedIoAllocateMdl(
- _In_opt_ PVOID VirtualAddress,
- _In_ ULONG Length,
- _In_ BOOLEAN SecondaryBuffer,
- _In_ BOOLEAN ChargeQuota,
- _Inout_opt_ PIRP Irp
- )
- {
- //直接让他访问0 就完事
- if (VirtualAddress == (PVOID)KdEnteredDebugger)
- {
- VirtualAddress = (PVOID)(KdEnteredDebugger + 0x20);
- }
-
- return g_pIoAllocateMdl(VirtualAddress, Length, SecondaryBuffer, ChargeQuota, Irp);
- }
-
- void HookIoAllocateMdl()
- {
- //定位IoAllocateMdl
- UNICODE_STRING strIoAllocateMdl = RTL_CONSTANT_STRING(L"IoAllocateMdl");
- ULONG uIoAllcateMdlAddr = (ULONG)MmGetSystemRoutineAddress(&strIoAllocateMdl);
- if (uIoAllcateMdlAddr == 0)
- return;
- KdPrint(("uIoAllcateMdlAddr:%x\n", uIoAllcateMdlAddr));
-
- KdPrint(("KdEnteredDebugger:%x\n", KdEnteredDebugger));
-
- g_uOldIoAllocateMdlAddr = uIoAllcateMdlAddr;
- KIRQL irql = KeRaiseIrqlToDpcLevel();
-
- g_pIoAllocateMdl = ExAllocatePool(NonPagedPool, 0x20);
- RtlZeroMemory(g_pIoAllocateMdl, 0x20);
- //构造 g_pIoAllocateMdl
- RtlCopyMemory((PVOID)g_pIoAllocateMdl, (PVOID)uIoAllcateMdlAddr, 5);
- //构造 g_pIoAllocateMdl 回调跳转
- UCHAR uJmpCallBack[7] = { 0xEA, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00};
- *(PULONG)(uJmpCallBack + 1) = uIoAllcateMdlAddr + 5;
- RtlCopyMemory((PVOID)((ULONG)g_pIoAllocateMdl + 5), uJmpCallBack, 7);
-
- //我们使用jmpHook 不使用call call相对比较麻烦 还要首先pop返回地址
- UCHAR uJmpHook[5] = { 0xE9, 0x00, 0x00, 0x00, 0x00 };
- *(PULONG)(uJmpHook + 1) = (ULONG)HookedIoAllocateMdl - uIoAllcateMdlAddr - 5;
-
- ErasePageProtect();
- RtlCopyMemory((PVOID)uIoAllcateMdlAddr, uJmpHook, 5);
- RenewPageProtect();
- KeLowerIrql(irql);
- }
复制代码 这鬼东西是WeGame的登录断点 下硬件断点让他执行就行
Single step exception - code 80000004 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
3: kd> r
eax=00000003 ebx=00000000 ecx=00000001 edx=0000004d esi=0012eba8 edi=00000000
eip=65a3d2bf esp=0012e7f4 ebp=0012eb14 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
ba r1 65a3d2bf
g
bc *
代码嘛 抄抄改改就完事了 网上一堆
|
|