首页
社区
课程
招聘
[原创](原创)Win7下过Hack*Shield的部分驱动保护
发表于: 2013-6-11 16:13 8440

[原创](原创)Win7下过Hack*Shield的部分驱动保护

2013-6-11 16:13
8440

在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层:
// 安装驱动的线程函数
UINT __cdecl CDriverProtectDlg::InstallDriverThread(LPVOID pParam)
{
	CDriverProtectDlg* pDlg = NULL;
	pDlg = (CDriverProtectDlg*)pParam;
	pDlg->UpdateData(TRUE);
	if (pDlg->strPath.IsEmpty())
	{
		AfxMessageBox(L"请选择驱动路径!");
		return 0;
	}
	if (pDlg->strrGamePath.IsEmpty())
	{
		AfxMessageBox(L"请选择游戏路径!");
		return 0;
	}
	if (!pDlg->LoadNTDriver(L"HelloDDK",pDlg->strPath.GetBuffer()))
	{
		pDlg->UnloadNTDriver(L"HelloDDK");
		pDlg->LoadNTDriver(L"HelloDDK",pDlg->strPath.GetBuffer());
	}
	HANDLE hDevice = 
		::CreateFileW(L"\\\\.\\HelloDDK",
		GENERIC_READ | GENERIC_WRITE,
		0,		// share mode none
		NULL,	// no security
		OPEN_EXISTING,
		FILE_ATTRIBUTE_NORMAL,
		NULL );		// no template
	if (hDevice == INVALID_HANDLE_VALUE)
	{
		pDlg->m_DriverINFORMATION.SetWindowTextW(L"打开驱动错误!");
		return 1;
	}
	DWORD Pid = pDlg->TransferProcessID(pDlg->strrGamePath.GetBuffer());
	int a = (int)Pid;
	UCHAR* InputBuffer = new UCHAR[a];
	UCHAR* OutputBuffer= new UCHAR[a];
	BOOL bRet;
	DWORD dwOutput;
	//输入缓冲区作为输入,输出缓冲区作为输出
	bRet = DeviceIoControl(hDevice, IOCTL_TEST1, InputBuffer, a, OutputBuffer, a, &dwOutput, NULL);
	if (bRet)
	{
		pDlg->m_DriverINFORMATION.SetWindowTextW(L"开启保护成功!");
	}
	CloseHandle(hDevice);
	delete []InputBuffer;
	delete []OutputBuffer;
	//AfxEndThread(0);
	ResumeThread(pDlg->ProcessMainThread);
	pDlg = NULL;
	return 0;
}
UINT __cdecl CDriverProtectDlg::UnInstallDriverThread(LPVOID pParam)
{
	CDriverProtectDlg* pDlg = NULL;
	pDlg = (CDriverProtectDlg*)pParam;
	pDlg->UpdateData(TRUE);
	if (pDlg->strPath.IsEmpty())
	{
		AfxMessageBox(L"请选择驱动路径!");
		return 0;
	}
	if (pDlg->strrGamePath.IsEmpty())
	{
		AfxMessageBox(L"请选择游戏路径!");
		return 0;
	}
	pDlg->UnloadNTDriver(L"HelloDDK");
	//AfxEndThread(0);
	pDlg = NULL;
	return 0;
}



Ring 0层的:
#include "HookNtOpenProcess.h"
#include "Function.h"

int nNtOpenProcessAddr;
int nHookNtOpenProcessAddr;
int nHookNtOpenPrpcessJmp;
int nHookNtOpenPrpcessOldJmp;
int nObOpenObjectByPointerAddr;
extern int GameProcessID;
static __declspec(naked) void MyNtOpenProcess()
{
	__asm
	{
		push dword ptr [ebp-4]
		push dword ptr [ebp-4]
		push dword ptr [ebp+0x0C]
		push dword ptr [ebp+8]
	}
	if (PanDuanProcessID()==GameProcessID)
	{
		__asm
		{
			jmp nHookNtOpenPrpcessOldJmp
			call nObOpenObjectByPointerAddr
			jmp nHookNtOpenPrpcessJmp
		}
	}
	else
	{
		__asm
		{
			call nObOpenObjectByPointerAddr
			jmp nHookNtOpenPrpcessJmp
		}
	}
}


void HookNtOpenProcess()
{
	
	//DbgPrint("要HOOK的进程ID为:%d",GameProcessID);
	nNtOpenProcessAddr=GetFunCtionAddr(L"NtOpenProcess");
	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};
	nHookNtOpenProcessAddr=SearchFeature(nNtOpenProcessAddr,code,13)-13;
	//DbgPrint("nHookNtOpenProcessAddr=%x\n",nHookNtOpenProcessAddr);
	nHookNtOpenPrpcessJmp=nHookNtOpenProcessAddr+17;
	nHookNtOpenPrpcessOldJmp=nHookNtOpenProcessAddr+12;
	//DbgPrint("nHookNtOpenPrpcessJmp=%x\n",nHookNtOpenPrpcessJmp);
	//DbgPrint("nHookNtOpenPrpcessOldJmp=%x\n",nHookNtOpenPrpcessOldJmp);
	nObOpenObjectByPointerAddr = GetCallAddr(nHookNtOpenPrpcessOldJmp+1);
	//DbgPrint("nObOpenObjectByPointerAddr=%x\n",nObOpenObjectByPointerAddr);
	InLineHookEngine(nHookNtOpenProcessAddr,(int)MyNtOpenProcess);
}


void UnHookNtOpenProcess()
{
	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};
	UnInLineHookEngine(nHookNtOpenProcessAddr,code,5);
}


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

然后这些代码就可以让CE正常打开进程扫描,修改游戏内存数据了!OD附加功能还在开放中。
如果有志同道合的朋友可以加我这个群一起交流:C/C++,汇编语言,驱动交流群:177822398、 177822108

DriverProtect.rar

driver.rar

[课程]Linux pwn 探索篇!

上传的附件:
收藏
免费 5
支持
分享
最新回复 (8)
雪    币: 19
活跃值: (88)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
本人顺便录制了一个教程去讲解代码:

http://pan.baidu.com/share/link?shareid=2793896342&uk=3155594444
2013-6-11 16:20
0
雪    币: 92
活跃值: (209)
能力值: ( LV6,RANK:95 )
在线值:
发帖
回帖
粉丝
3
能调试了???
2013-7-4 07:26
0
雪    币: 218
活跃值: (12)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
XP 下蓝屏。。改个XP 下的驱动来试试。
2013-7-4 13:28
0
雪    币: 115
活跃值: (46)
能力值: ( LV4,RANK:40 )
在线值:
发帖
回帖
粉丝
5
HS还有很多检测,像不断检测是否hook被还原,DPC被删掉;而中途启用内核调试会立刻重启。
至于R3下的hook我就无语了,用XT一看数不清的IAT,inline hook,完全不考虑游戏的效率。
2013-7-4 14:08
0
雪    币: 8865
活跃值: (2379)
能力值: ( LV12,RANK:760 )
在线值:
发帖
回帖
粉丝
6
r3是TMD壳的dll reload功能
2013-7-4 15:08
0
雪    币: 115
活跃值: (46)
能力值: ( LV4,RANK:40 )
在线值:
发帖
回帖
粉丝
7
貌似还会释放很多.tmp,好像把ntdll等重载了那样,而且属于IAT hook
2013-7-4 15:15
0
雪    币: 8865
活跃值: (2379)
能力值: ( LV12,RANK:760 )
在线值:
发帖
回帖
粉丝
8
tmp其实就是dll文件,都是Copyfile过去的~
2013-7-4 15:31
0
雪    币: 19
活跃值: (88)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
其实部分也可以用重载内核实现的!
2013-7-14 17:20
0
游客
登录 | 注册 方可回帖
返回
//