设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 手机 数据
当前位置: 首页 > 运营中心 > 建站资源 > 策划 > 正文

26种对付反调试的方法(7)

发布时间:2019-03-21 12:55 所属栏目:20 来源:luochicun
导读:在CheckRemoteDebuggerPresent的内部,调用NtQueryInformationProcess函数: 0:000ufkernelbase!CheckRemotedebuggerPresent KERNELBASE!CheckRemoteDebuggerPresent: ... 75207a246a00push0 75207a266a04push4 752

在CheckRemoteDebuggerPresent的内部,调用NtQueryInformationProcess函数:

  1. 0:000> uf kernelbase!CheckRemotedebuggerPresent 
  2. KERNELBASE!CheckRemoteDebuggerPresent: 
  3. ... 
  4. 75207a24 6a00            push    0 
  5. 75207a26 6a04            push    4 
  6. 75207a28 8d45fc          lea     eax,[ebp-4] 
  7. 75207a2b 50              push    eax 
  8. 75207a2c 6a07            push    7 
  9. 75207a2e ff7508          push    dword ptr [ebp+8] 
  10. 75207a31 ff151c602775    call    dword ptr [KERNELBASE!_imp__NtQueryInformationProcess (7527601c)] 
  11. 75207a37 85c0            test    eax,eax 
  12. 75207a39 0f88607e0100    js      KERNELBASE!CheckRemoteDebuggerPresent+0x2b (7521f89f) 
  13. ... 

如果我们来看看NtQueryInformationProcess文档,那么这个Assembler列表将向我们展示CheckRemoteDebuggerPresent函数获取DebugPort值,因为ProcessInformationClass参数值(第二个)为7,以下反调试代码就是基于调用NtQueryInformationProcess:

  1. typedef NTSTATUS(NTAPI *pfnNtQueryInformationProcess)( 
  2.     _In_      HANDLE           ProcessHandle, 
  3.     _In_      UINT             ProcessInformationClass, 
  4.     _Out_     PVOID            ProcessInformation, 
  5.     _In_      ULONG            ProcessInformationLength, 
  6.     _Out_opt_ PULONG           ReturnLength 
  7.     ); 
  8. const UINT ProcessDebugPort = 7; 
  9. int main(int argc, char *argv[]) 
  10.     pfnNtQueryInformationProcess NtQueryInformationProcess = NULL; 
  11.     NTSTATUS status; 
  12.     DWORD isDebuggerPresent = 0; 
  13.     HMODULE hNtDll = LoadLibrary(TEXT("ntdll.dll")); 
  14.      
  15.     if (NULL != hNtDll) 
  16.     { 
  17.         NtQueryInformationProcess = (pfnNtQueryInformationProcess)GetProcAddress(hNtDll, "NtQueryInformationProcess"); 
  18.         if (NULL != NtQueryInformationProcess) 
  19.         { 
  20.             status = NtQueryInformationProcess( 
  21.                 GetCurrentProcess(), 
  22.                 ProcessDebugPort, 
  23.                 &isDebuggerPresent, 
  24.                 sizeof(DWORD), 
  25.                 NULL); 
  26.             if (status == 0x00000000 && isDebuggerPresent != 0) 
  27.             { 
  28.                 std::cout << "Stop debugging program!" << std::endl; 
  29.                 exit(-1); 
  30.             } 
  31.         } 
  32.     } 
  33.     return 0; 

如何避开CheckRemoteDebuggerPresent和NtQueryInformationProcess

(编辑:ASP站长网)

网友评论
推荐文章
    热点阅读