if (STATUS_SUCCESS != ZwQueryInformationProcess(GetCurrentProcess( ), (PROCESS_INFO_CLASS)0x0000001e, &ProcessInfo, sizeof(ProcessInfo), NULL)) return false; else
if(ProcessInfo.ObjectHandle) return true; else
return false;
2.10 FD_NtQueryInfoProc_DbgFlags();
同样的未公开的ProcessDebugFlags类,当调试器存在时,它会返回false。 HMODULE hModule = GetModuleHandle(\
ZW_QUERY_INFORMATION_PROCESS ZwQueryInformationProcess; ZwQueryInformationProcess = (ZW_QUERY_INFORMATION_PROCESS)GetProcAddress(hModule, \
if (ZwQueryInformationProcess == NULL) return false;
_PROCESS_DEBUG_FLAGS_INFO ProcessInfo;
if (STATUS_SUCCESS != ZwQueryInformationProcess(GetCurrentProcess( ), (PROCESS_INFO_CLASS)0x0000001f, &ProcessInfo, sizeof(ProcessInfo), NULL)) return false; else
if(ProcessInfo.Debugflags) return false; else
return true;
2.11 FD_NtQueryInfoProc_SysKrlDbgInfo()
这个方法估计对大家用处不大,SystemKernelDebuggerInformation类同样可以用来识别调试器,只是可惜在windows下无效,据称可以用在reactOS中。 HMODULE hModule = GetModuleHandle(\
ZW_QUERY_SYSTEM_INFORMATION ZwQuerySystemInformation;
ZwQuerySystemInformation = (ZW_QUERY_SYSTEM_INFORMATION)GetProcAddress(hModule, \
if (ZwQuerySystemInformation == NULL) return false;
SYSTEM_KERNEL_DEBUGGER_INFORMATION Info;
if (STATUS_SUCCESS == ZwQuerySystemInformation(SystemKernelDebuggerInformation, &Info, sizeof(Info), NULL)) {
if (Info.DebuggerEnabled) {
if (Info.DebuggerNotPresent) return false;
else
return true; } else
return false; } else
return true;
2.12 FD_SeDebugPrivilege()
当一个进程获得SeDebugPrivilege,它就获得了对CSRSS.EXE的完全控制,这种特权也会被子进程继承,也就是说一个被调试的程序如果获得了CSRSS.EXE的进程ID,它就可以使用openprocess操作CSRSS.EXE。获得其进程ID有很多中方法,如Process32Next,或NtQuerySystemInformation,在winxp下可以使用CsrGetProcessId。 hTmp=OpenProcess(PROCESS_ALL_ACCESS,false,PID_csrss); if(hTmp!=NULL) {
CloseHandle(hProcessSnap ); return true; }
2.13 FD_Parent_Process()
通常我们都直接在windows界面下运行应用程序,这样的结果就是它的父进程为\,这个反调试就是检测应用程序的父进程是否为\,如不是则判定为处于调试器中,这也不是百分百可靠,因为有的时候你的程序是在命令行提示符下运行的。
Yoda使用了这个反调试,它使用Process32Next检测父进程,目前很多插件已经通过使Process32Next始终返回false来越过这个反调试(比如HideOD)。不过可以对代码做些简单的修正来处理这个反反调试。
2.14 FD_DebugObject_NtQueryObject();
如前面所描述的,当一个调试活动开始,一个\object\被创建,同也相应产生了一个句柄。我们可以查询这个调试对象列表,并检查调试对象的数量,以实现调试器的检测。 HMODULE hModule = GetModuleHandle(\PNtQueryObject NtQueryObject;
NtQueryObject = (PNtQueryObject)GetProcAddress(hModule,\
if(NtQueryObject==NULL) return false;
unsigned char szdbgobj[25]=
\00\\x74\\x00\\x00\\x00\
unsigned char *psz=&szdbgobj[0]; __asm {
xor ebx,ebx; push ebx; push esp; push ebx; push ebx; push 3; push ebx;
Call dword ptr [NtQueryObject]; pop edi; push 4; push 1000h; push edi; push ebx;
call dword ptr [VirtualAlloc]; push ebx; push edi; push eax; push 3; push ebx; xchg esi,eax;
Call dword ptr [NtQueryObject]; lodsd;
xchg ecx,eax; lable1: lodsd; movzx edx,ax; lodsd;
xchg esi,eax; cmp edx,16h; jne label2; xchg ecx,edx; mov edi,psz; repe cmp**; xchg ecx,edx; jne label2;
cmp dword ptr [eax],edx jne rt_label;
lable2: add esi,edx and esi,-4; lodsd
loop label1; }
return false; rt_label: return true;
2.15 FD_Find_Debugger_Window();
通过列举运行的应用程序的窗口,并于常用调试相关工具比对的方法,应该很常用了,就不多说了。这个也是个可以自行增加项目的函数,你可以将一些常用的调试工具归入其中,比如OD,IDA,WindBG,SoftICE等,你也可以添加任何你需要的,比如\v1.6 FINAL (C) 2001-2003 MackT/uCF\,\Monitor - Sysinternals: www.sysinternals.com\等等。 //ollyice
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL) return true; //ollydbg v1.1
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL) return true;
//ollyice pe--diy
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL) return true; //ollydbg ?-°?
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL) return true; //ollydbg ?-°?
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL) return true; //windbg
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL) return true; //dede3.50
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL) return true; //IDA5.20
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL) return true; //others
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL)
return true;
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL) return true;
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL) return true;
hWnd=CWnd::FindWindow(_T(\if (hWnd!=NULL) return true; //PEiD v0.94
hWnd=CWnd::FindWindow(NULL,\if (hWnd!=NULL) return true; //RegMON
hWnd=CWnd::FindWindow(NULL,\Monitor - Sysinternals: www.sysinternals.com\if (hWnd!=NULL) return true; //File Monitor
hWnd=CWnd::FindWindow(NULL,\Monitor - Sysinternals: www.sysinternals.com\if (hWnd!=NULL) return true;
//Import Rec v1.6
hWnd=CWnd::FindWindow(NULL,\REConstructor v1.6 FINAL (C) 2001-2003 MackT/uCF\if (hWnd!=NULL) return true; return false;
2.16 FD_Find_Debugger_Process(); 与上面的方法类似,区别是这个反调试用通过查询进程名字与已知的常用调试器应用程序名字进行比对,以确定是否有调试器处于运行状态。 if(strcmp(pe32.szExeFile,\return true;
if(strcmp(pe32.szExeFile,\return true;
if(strcmp(pe32.szExeFile,\return true;
if(strcmp(pe32.szExeFile,\return true;
if(strcmp(pe32.szExeFile,\return true;
if(strcmp(pe32.szExeFile,\
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库OD反调试大全(2)在线全文阅读。
相关推荐: