[VC] 过掉双机调试TP 蓝屏

[复制链接]

微信扫一扫 分享朋友圈

微笑…天使 发表于 2020-6-7 13:55:42 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

马上注册,结交更多易友,享用更多功能,让你轻松玩转觅风论坛。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
  1. #pragma once

  2. #include <ntddk.h>

  3. //驱动卸载
  4. void UnloadDriver(PDRIVER_OBJECT pDriverObject);
  5. void HookIoAllocateMdl();

  6. typedef PMDL (__stdcall *pIoAllocateMdl)(
  7.         _In_opt_    PVOID   VirtualAddress,
  8.         _In_        ULONG   Length,
  9.         _In_        BOOLEAN SecondaryBuffer,
  10.         _In_        BOOLEAN ChargeQuota,
  11.         _Inout_opt_ PIRP    Irp
  12. );

  13. pIoAllocateMdl g_pIoAllocateMdl = NULL;

  14. //去掉页面保护
  15. void ErasePageProtect()
  16. {
  17.         __asm
  18.         {
  19.                 cli
  20.                 mov eax, cr0
  21.                 and eax, not 10000h
  22.                 mov cr0, eax
  23.         }
  24. }

  25. //恢复页面保护
  26. void RenewPageProtect()
  27. {
  28.         __asm
  29.         {
  30.                 mov eax, cr0
  31.                 or eax, 10000h
  32.                 mov cr0, eax
  33.                 sti
  34.         }
  35. }

  36. ULONG g_uOldIoAllocateMdlAddr = 0;
复制代码
  1. #include "Pass_Debugger.h"

  2. //驱动加载
  3. NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pStrRegPath)
  4. {
  5.         UNREFERENCED_PARAMETER(pDriverObject);
  6.         UNREFERENCED_PARAMETER(pStrRegPath);

  7.         KdEnableDebugger();
  8.         KdPrint(("驱动加载成功!\n"));
  9.         pDriverObject->DriverUnload = UnloadDriver;
  10.         HookIoAllocateMdl();
  11.          
  12.         return STATUS_SUCCESS;
  13. }

  14. //驱动卸载
  15. void UnloadDriver(PDRIVER_OBJECT pDriverObject)
  16. {
  17.         UNREFERENCED_PARAMETER(pDriverObject);

  18.         UCHAR uOldBytes[5] = { 0x8B, 0xFF, 0x55, 0x8B, 0xEC };

  19.         KIRQL irql = KeRaiseIrqlToDpcLevel();

  20.         ErasePageProtect();
  21.         RtlCopyMemory((PVOID)g_uOldIoAllocateMdlAddr, uOldBytes, 5);
  22.         RenewPageProtect();
  23.         KeLowerIrql(irql);

  24.         KdPrint(("驱动卸载成功!\n"));
  25.         if (g_pIoAllocateMdl != NULL)
  26.         {
  27.                 ExFreePool(g_pIoAllocateMdl);
  28.                 g_pIoAllocateMdl = NULL;
  29.         }
  30. }

  31. //获取KdEnteredDebugger地址 直接通过extern搜索 因为它是导出的全局变量
  32. extern ULONG KdEnteredDebugger;

  33. PMDL HookedIoAllocateMdl(
  34.         _In_opt_    PVOID   VirtualAddress,
  35.         _In_        ULONG   Length,
  36.         _In_        BOOLEAN SecondaryBuffer,
  37.         _In_        BOOLEAN ChargeQuota,
  38.         _Inout_opt_ PIRP    Irp
  39. )
  40. {
  41.         //直接让他访问0 就完事
  42.         if (VirtualAddress == (PVOID)KdEnteredDebugger)
  43.         {
  44.                 VirtualAddress = (PVOID)(KdEnteredDebugger + 0x20);
  45.         }

  46.         return g_pIoAllocateMdl(VirtualAddress, Length, SecondaryBuffer, ChargeQuota, Irp);
  47. }

  48. void HookIoAllocateMdl()
  49. {
  50.         //定位IoAllocateMdl
  51.         UNICODE_STRING strIoAllocateMdl = RTL_CONSTANT_STRING(L"IoAllocateMdl");
  52.         ULONG uIoAllcateMdlAddr = (ULONG)MmGetSystemRoutineAddress(&strIoAllocateMdl);
  53.         if (uIoAllcateMdlAddr == 0)
  54.                 return;
  55.         KdPrint(("uIoAllcateMdlAddr:%x\n", uIoAllcateMdlAddr));
  56.          
  57.         KdPrint(("KdEnteredDebugger:%x\n", KdEnteredDebugger));

  58.         g_uOldIoAllocateMdlAddr = uIoAllcateMdlAddr;
  59.         KIRQL irql = KeRaiseIrqlToDpcLevel();
  60.          
  61.         g_pIoAllocateMdl = ExAllocatePool(NonPagedPool, 0x20);
  62.         RtlZeroMemory(g_pIoAllocateMdl, 0x20);
  63.         //构造 g_pIoAllocateMdl
  64.         RtlCopyMemory((PVOID)g_pIoAllocateMdl, (PVOID)uIoAllcateMdlAddr, 5);
  65.         //构造 g_pIoAllocateMdl 回调跳转
  66.         UCHAR uJmpCallBack[7] = { 0xEA, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00};
  67.         *(PULONG)(uJmpCallBack + 1) = uIoAllcateMdlAddr + 5;
  68.         RtlCopyMemory((PVOID)((ULONG)g_pIoAllocateMdl + 5), uJmpCallBack, 7);

  69.         //我们使用jmpHook 不使用call  call相对比较麻烦 还要首先pop返回地址
  70.         UCHAR uJmpHook[5] = { 0xE9, 0x00, 0x00, 0x00, 0x00 };
  71.         *(PULONG)(uJmpHook + 1) = (ULONG)HookedIoAllocateMdl - uIoAllcateMdlAddr - 5;

  72.         ErasePageProtect();
  73.         RtlCopyMemory((PVOID)uIoAllcateMdlAddr, uJmpHook, 5);
  74.         RenewPageProtect();
  75.         KeLowerIrql(irql);
  76. }
复制代码
这鬼东西是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 *
代码嘛 抄抄改改就完事了 网上一堆
回复

使用道具 举报

精彩评论1

fshen 发表于 2021-11-17 22:40:17 | 显示全部楼层
抄抄改改就完事了 网上一堆
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注我们:觅风论坛与你快乐分享

官方QQ

服务客服QQ:

466-352-670

客服QQ:466352670

Email:466352670@qq.com

Powered by WWW.EYYBA.COM X3.4© 2001-2023 Inc.   版权所有   

觅风论坛  沪ICP备15020893号-1