123456

 

反调试功能<IsDebuggerPresent>

依赖于API的反调试

这个函数会看PEB中的BeingDebugged是否为0,不为0就表示无调试器,否则表示有调试器.注意的是以前代码都会对这个函数首字节是否为0x64作判断,但在win7下,需要对应kernelBase中的IsDebuggerPresent,而不是kernel32中的IsDebuggerPresent

//使用IsDebuggerPresent函数检测
DbgToolType AntiDebugged::AD_IsDebuggerPresent()
{
	HMODULE hKernelBaseDll = ::LoadLibrary(TEXT("kernelBase.dll"));
	if (NULL != hKernelBaseDll)
	{
		// 不要使用kernel32,kernel32中IsDebuggerPresent第一条指令并非0x64
		FARPROC pIsDebuggerPresent = ::GetProcAddress(hKernelBaseDll, "IsDebuggerPresent");
		if (!pIsDebuggerPresent)
		{
			::FreeLibrary(hKernelBaseDll);
			return DGBTOOL_NO;
		}


		if ((*(BYTE *)pIsDebuggerPresent == 0xCC)
			||(*(BYTE *)pIsDebuggerPresent != 0x64)
			|| pIsDebuggerPresent()
			)
		{
			::FreeLibrary(hKernelBaseDll);
			return DBGTOOL_CUSTOM;
		}
		else
		{
			::FreeLibrary(hKernelBaseDll);
			return DGBTOOL_NO;
		}

	}

	return DGBTOOL_NO;
}


这个过掉的方式比较简单:只需要把PEB中的BeingDebugged置为0.

比如直接在OD命令中输入:d fs:[30]+2把它改为1即可过掉:

 

posted on 2012-09-19 15:14  hgy413  阅读(335)  评论(0编辑  收藏  举报

导航