看流星社区

 找回密码
 注册账号
查看: 1615|回复: 0

[持续更新]过SOD检测OD方法

[复制链接]

该用户从未签到

发表于 2017-6-1 12:52:16 | 显示全部楼层 |阅读模式
使用异常
Closehandle
如果给CloseHandle()函数一个无效句柄作为输入参数,在无调试器时,将会返回一个错误代码,而有调试器存在时,
将会触发一个EXCEPTION_INVALID_HANDLE (0xc0000008)的异常。
  1. bool getdebebugbyCloseHandle()//返回true说明有OD
  2. {
  3.         __try
  4.         {
  5.                 CloseHandle((HANDLE)0x00001234);
  6.                 return false;
  7.         }
  8.         __except(1)
  9.         {
  10.                 return true;
  11.         }
  12. }
复制代码


仅在进程初始化创建主线程时执行的代码
  1. //必须先于程序执行 TLS EPO 窗口回调等等
  2. void getdebugbyOEP()
  3. {
  4.         IMAGE_DOS_HEADER*dos_head=(IMAGE_DOS_HEADER*)GetModuleHandle(NULL);
  5.         PIMAGE_NT_HEADERS32         nt_head=(PIMAGE_NT_HEADERS32)((DWORD)dos_head+(DWORD)dos_head->e_lfanew);
  6.         BYTE*OEP=(BYTE*)(nt_head->OptionalHeader.AddressOfEntryPoint+(DWORD)dos_head);
  7.                 for(unsigned long index=0;index<200;index++)
  8.                 {
  9.                         if(OEP[index]==0xcc)
  10.                         {
  11.                                 ExitProcess(0);
  12.                         }
  13.                 }
  14. }
复制代码
GetWindowLongA 获取窗口样式
OD的窗口样式出卖了它
代码:
  1. // checkod.cpp : 定义控制台应用程序的入口点。
  2. //
  3. #include <stdio.h>
  4. #include <Windows.h>
  5. void CALLBACK HandleWinEvent(HWINEVENTHOOK hook, DWORD event, HWND hwnd,
  6.                                                          LONG idObject, LONG idChild,
  7.                                                          DWORD dwEventThread, DWORD dwmsEventTime)
  8. {
  9.         char name[MAX_PATH];
  10.         GetWindowTextA(hwnd,name,MAX_PATH);
  11.         LONG mStyle = GetWindowLongA(hwnd,GWL_STYLE);
  12.         LONG ExtStyle=GetWindowLongA(hwnd,GWL_EXSTYLE);
  13.         if(mStyle==0x57c70000&&ExtStyle==0x140)
  14.         {
  15.                 printf("find od 1 %08x %s\r\n",dwEventThread,name);
  16.         }
  17.         if (mStyle==0x56CF0000&&ExtStyle==0x140)
  18.         {
  19.                 printf("Find od 2 %08x %s\r\n",dwEventThread,name);
  20.         }
  21. }
  22. int main(int argc, char argv[])
  23. {
  24.         CoInitialize(NULL);
  25.         HWINEVENTHOOK hHook = SetWinEventHook( EVENT_MIN , EVENT_MAX , NULL, HandleWinEvent, 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
  26.         if (hHook)
  27.         {
  28.                 printf("set hook ok\r\n");
  29.         }
  30.         else
  31.         {
  32.                 printf("some hack in this os\r\n");
  33.                 exit(-1);
  34.         }
  35.         MSG msg;
  36.         while(GetMessage(&msg,NULL,0,0))
  37.         {
  38.                
  39.                 TranslateMessage(&msg);
  40.                 DispatchMessage(&msg);
  41.         }
  42.         return 0;
  43. }
复制代码


窗口名的检测
搜集了常见OD的窗口名特征
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <string.h>
  4. BOOL bFind = FALSE;
  5. BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
  6. {
  7.         if (hwnd == INVALID_HANDLE_VALUE)
  8.         {
  9.                 return FALSE;
  10.         }
  11.         char szbuf[MAX_PATH] = {0};
  12.         int ilens = 0;
  13.         ilens = GetWindowTextA(hwnd, szbuf, sizeof(szbuf)/sizeof(char));
  14.         if(ilens != 0)
  15.         {
  16.                 PCHAR pstr = NULL;
  17.                 pstr = strstr(szbuf, "LCG");
  18.                 if(pstr == NULL)
  19.                         pstr = strstr(szbuf,"- 主线程");
  20.                 if(pstr == NULL)
  21.                         pstr = strstr(szbuf,"模块 -");
  22.                 if(pstr == NULL)
  23.                         pstr = strstr(szbuf,"main thread");
  24.                 if(pstr == NULL)
  25.                         pstr = strstr(szbuf,",module");
  26.                 if(pstr == NULL)
  27.                         pstr = strstr(szbuf,",- Module;");
  28.                 if(pstr == NULL)
  29.                         pstr = strstr(szbuf,"- Thread");
  30.                 if(pstr == NULL)
  31.                         pstr = strstr(szbuf,"G.P.U");
  32.                 if(pstr == NULL)
  33.                         pstr = strstr(szbuf,"+ 主线程");
  34.                 if(pstr == NULL)
  35.                         pstr = strstr(szbuf,"主线程,");
  36.                 if(pstr == NULL)
  37.                         pstr = strstr(szbuf,",模块");
  38.                 if(pstr == NULL)
  39.                         pstr = strstr(szbuf,"模块 +");
  40.                 if(pstr == NULL)
  41.                         pstr = strstr(szbuf,"PYG");
  42.                 if(pstr == NULL)
  43.                         pstr = strstr(szbuf,"FCK");
  44.                 if(pstr == NULL)
  45.                         pstr = strstr(szbuf,"?块");
  46.                 if(pstr == NULL)
  47.                         pstr = strstr(szbuf,"主线程");
  48.                 if(pstr == NULL)
  49.                         pstr = strstr(szbuf,"BH");
  50.                 if(pstr == NULL)
  51.                         pstr = strstr(szbuf,"吾爱");
  52.                 if(pstr == NULL)
  53.                         pstr = strstr(szbuf,"破解");
  54.                 if(pstr == NULL)
  55.                 {
  56.                         pstr = strstr(szbuf,"[");
  57.                         if(pstr != NULL)
  58.                                 pstr = strstr(szbuf,"]");
  59.                         if(pstr != NULL)
  60.                                 goto END;
  61.                 }
  62. END:                       
  63.                 if(pstr != NULL)
  64.                 {
  65.                         bFind = TRUE;
  66.                         printf("Find Od!\r\n");
  67.                         return FALSE;
  68.                 }
  69.                        
  70.         }
  71.         return TRUE;
  72. }
  73. VOID EnumOD()
  74. {
  75.         EnumWindows(EnumWindowsProc, NULL);
  76. }
  77. int main(int argc, char* argv[])
  78. {
  79.         EnumOD();
  80.         if (bFind != TRUE)
  81.         {
  82.                 printf("Find nothind!\n");
  83.         }
  84.         getchar();
  85.         return 0;
  86. }
复制代码
点击按钮快速添加回复内容: 支持 高兴 激动 给力 加油 苦寻 生气 回帖 路过 感恩
您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

小黑屋|手机版|Archiver|看流星社区 |网站地图

GMT+8, 2024-3-19 14:02

Powered by Kanliuxing X3.4

© 2010-2019 kanliuxing.com

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