开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 2196|回复: 3
收起左侧

[源码分享] 【原创】Win7下过盛*大的Hack*Shield的部分驱动保护

[复制链接]
发表于 2013-6-11 21:31:01 | 显示全部楼层 |阅读模式   广东省茂名市
在Win7下很多XP的驱动都不适用了!前几个月研究了一下盛*大游戏的泡泡*堂的Hack*Shield驱动保护发现Hook了十多个内核函数,Ring 3和 Ring 0的双重保护
现在暂时发现钩住了以下函数
hook NtOpenProcess

hook NtReadVirtualMemory

hook NtWriteVirtualMemory

Hook NtClose

Hook NtProtectVirtualMemory

Hook NtGetContextThread

其中HOOK NtGetContextThread中用了两个钩子,恢复起来有些麻烦,但还是给恢复了

Ring 3层的程序通过DeviceIoControl传递游戏进程ID给驱动,然后驱动就执行相关的动作!现在给出部分关键的代码!

Ring 3层:

  1. // 安装驱动的线程函数
  2. UINT __cdecl CDriverProtectDlg::InstallDriverThread(LPVOID pParam)
  3. {
  4.   CDriverProtectDlg* pDlg = NULL;
  5.   pDlg = (CDriverProtectDlg*)pParam;
  6.   pDlg->UpdateData(TRUE);
  7.   if (pDlg->strPath.IsEmpty())
  8.   {
  9.     AfxMessageBox(L"请选择驱动路径!");
  10.     return 0;
  11.   }
  12.   if (pDlg->strrGamePath.IsEmpty())
  13.   {
  14.     AfxMessageBox(L"请选择游戏路径!");
  15.     return 0;
  16.   }
  17.   if (!pDlg->LoadNTDriver(L"HelloDDK",pDlg->strPath.GetBuffer()))
  18.   {
  19.     pDlg->UnloadNTDriver(L"HelloDDK");
  20.     pDlg->LoadNTDriver(L"HelloDDK",pDlg->strPath.GetBuffer());
  21.   }
  22.   HANDLE hDevice =
  23.     ::CreateFileW(L"\\\\.\\HelloDDK",
  24.     GENERIC_READ | GENERIC_WRITE,
  25.     0,    // share mode none
  26.     NULL,  // no security
  27.     OPEN_EXISTING,
  28.     FILE_ATTRIBUTE_NORMAL,
  29.     NULL );    // no template
  30.   if (hDevice == INVALID_HANDLE_VALUE)
  31.   {
  32.     pDlg->m_DriverINFORMATION.SetWindowTextW(L"打开驱动错误!");
  33.     return 1;
  34.   }
  35.   DWORD Pid = pDlg->TransferProcessID(pDlg->strrGamePath.GetBuffer());
  36.   int a = (int)Pid;
  37.   UCHAR* InputBuffer = new UCHAR[a];
  38.   UCHAR* OutputBuffer= new UCHAR[a];
  39.   BOOL bRet;
  40.   DWORD dwOutput;
  41.   //输入缓冲区作为输入,输出缓冲区作为输出
  42.   bRet = DeviceIoControl(hDevice, IOCTL_TEST1, InputBuffer, a, OutputBuffer, a, &dwOutput, NULL);
  43.   if (bRet)
  44.   {
  45.     pDlg->m_DriverINFORMATION.SetWindowTextW(L"开启保护成功!");
  46.   }
  47.   CloseHandle(hDevice);
  48.   delete []InputBuffer;
  49.   delete []OutputBuffer;
  50.   //AfxEndThread(0);
  51.   ResumeThread(pDlg->ProcessMainThread);
  52.   pDlg = NULL;
  53.   return 0;
  54. }
  55. UINT __cdecl CDriverProtectDlg::UnInstallDriverThread(LPVOID pParam)
  56. {
  57.   CDriverProtectDlg* pDlg = NULL;
  58.   pDlg = (CDriverProtectDlg*)pParam;
  59.   pDlg->UpdateData(TRUE);
  60.   if (pDlg->strPath.IsEmpty())
  61.   {
  62.     AfxMessageBox(L"请选择驱动路径!");
  63.     return 0;
  64.   }
  65.   if (pDlg->strrGamePath.IsEmpty())
  66.   {
  67.     AfxMessageBox(L"请选择游戏路径!");
  68.     return 0;
  69.   }
  70.   pDlg->UnloadNTDriver(L"HelloDDK");
  71.   //AfxEndThread(0);
  72.   pDlg = NULL;
  73.   return 0;
  74. }

复制代码
Ring 0层的:

  1. #include "HookNtOpenProcess.h"
  2. #include "Function.h"

  3. int nNtOpenProcessAddr;
  4. int nHookNtOpenProcessAddr;
  5. int nHookNtOpenPrpcessJmp;
  6. int nHookNtOpenPrpcessOldJmp;
  7. int nObOpenObjectByPointerAddr;
  8. extern int GameProcessID;
  9. static __declspec(naked) void MyNtOpenProcess()
  10. {
  11.   __asm
  12.   {
  13.     push dword ptr [ebp-4]
  14.     push dword ptr [ebp-4]
  15.     push dword ptr [ebp+0x0C]
  16.     push dword ptr [ebp+8]
  17.   }
  18.   if (PanDuanProcessID()==GameProcessID)
  19.   {
  20.     __asm
  21.     {
  22.       jmp nHookNtOpenPrpcessOldJmp
  23.       call nObOpenObjectByPointerAddr
  24.       jmp nHookNtOpenPrpcessJmp
  25.     }
  26.   }
  27.   else
  28.   {
  29.     __asm
  30.     {
  31.       call nObOpenObjectByPointerAddr
  32.       jmp nHookNtOpenPrpcessJmp
  33.     }
  34.   }
  35. }


  36. void HookNtOpenProcess()
  37. {
  38.   
  39.   //DbgPrint("要HOOK的进程ID为:%d",GameProcessID);
  40.   nNtOpenProcessAddr=GetFunCtionAddr(L"NtOpenProcess");
  41.   char code[13] = {(char)0xFF,(char)0x75,(char)0xFC,(char)0xFF,(char)0x75,(char)0xFC,(char)0xFF,(char)0x75,(char)0x0C,(char)0xFF,(char)0x75,(char)0x08,(char)0xE8};
  42.   nHookNtOpenProcessAddr=SearchFeature(nNtOpenProcessAddr,code,13)-13;
  43.   //DbgPrint("nHookNtOpenProcessAddr=%x\n",nHookNtOpenProcessAddr);
  44.   nHookNtOpenPrpcessJmp=nHookNtOpenProcessAddr+17;
  45.   nHookNtOpenPrpcessOldJmp=nHookNtOpenProcessAddr+12;
  46.   //DbgPrint("nHookNtOpenPrpcessJmp=%x\n",nHookNtOpenPrpcessJmp);
  47.   //DbgPrint("nHookNtOpenPrpcessOldJmp=%x\n",nHookNtOpenPrpcessOldJmp);
  48.   nObOpenObjectByPointerAddr = GetCallAddr(nHookNtOpenPrpcessOldJmp+1);
  49.   //DbgPrint("nObOpenObjectByPointerAddr=%x\n",nObOpenObjectByPointerAddr);
  50.   InLineHookEngine(nHookNtOpenProcessAddr,(int)MyNtOpenProcess);
  51. }


  52. void UnHookNtOpenProcess()
  53. {
  54.   char code[13] = {(char)0xFF,(char)0x75,(char)0xFC,(char)0xFF,(char)0x75,(char)0xFC,(char)0xFF,(char)0x75,(char)0x0C,(char)0xFF,(char)0x75,(char)0x08,(char)0xE8};
  55.   UnInLineHookEngine(nHookNtOpenProcessAddr,code,5);
  56. }

复制代码
DriverProtect.rar 为Ring 3层的源码
driver.rar 为Ring 0层的驱动文件及调试用的PDB文件

然后这些代码就可以让CE正常打开进程扫描,修改游戏内存数据了!OD附加功能还在开放中。
如果有志同道合的朋友可以加我这个群一起交流:C/C++,汇编语言,驱动交流群:177822398、 177822108
本人顺便录制了一个教程去讲解代码:
http://pan.baidu.com/share/link? ... 2&uk=3155594444

driver.rar (44.48 KB, 下载次数: 7)
发表于 2013-11-3 12:43:26 | 显示全部楼层   湖北省武汉市
在64位win7下怎么会有Ring0hook??!??!?!!?
回复 支持 反对

使用道具 举报

结帖率:100% (7/7)
发表于 2013-7-1 23:21:39 | 显示全部楼层   湖南省益阳市
大神,能写个泡泡堂无敌出来么?
回复 支持 反对

使用道具 举报

结帖率:0% (0/1)
发表于 2013-6-11 21:34:51 | 显示全部楼层   广东省东莞市
来看看那
回复 支持 反对

使用道具 举报

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

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
网站简介:精易论坛成立于2009年,是一个程序设计学习交流技术论坛,隶属于揭阳市揭东区精易科技有限公司所有。
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表