Advertisement
waliedassar

Detect OllyDbg v1.10

Aug 10th, 2012
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.71 KB | None | 0 0
  1. // http://waleedassar.blogspot.com (@waleedassar)
  2. #include "stdafx.h"
  3. #include "windows.h"
  4.  
  5. typedef struct _PROCESS_BASIC_INFORMATION {
  6.     unsigned long Reserved1;
  7.     unsigned long PebBaseAddress;
  8.     unsigned long Reserved2[2];
  9.     unsigned long UniqueProcessId;
  10.     unsigned long ParentProcessId;
  11. }PROCESS_BASIC_INFORMATION;
  12. extern "C"
  13. {
  14.     int __stdcall ZwQueryInformationProcess(HANDLE,int,PROCESS_BASIC_INFORMATION*,int,unsigned long*);
  15. }
  16.  
  17. int main(int argc, char* argv[])
  18. {
  19.     //---------------Get parent process's PID----------------------------------
  20.     PROCESS_BASIC_INFORMATION PBI={0};
  21.     ZwQueryInformationProcess(GetCurrentProcess(),0,&PBI,sizeof(PBI),0);
  22.     HANDLE h=OpenProcess(PROCESS_VM_READ,FALSE,PBI.ParentProcessId);
  23.     if(!h) return 0;
  24.     //----------------Get Info about parent------------------------------------
  25.     ZwQueryInformationProcess(h,0,&PBI,sizeof(PBI),0);
  26.     unsigned long parent_IB=0;
  27.     ReadProcessMemory(h,(void*)((PBI.PebBaseAddress)+0x8),&parent_IB,4,0);
  28.     //---------------Start reading from PE header of parent process------------
  29.     IMAGE_DOS_HEADER DOS={0};
  30.     ReadProcessMemory(h,(void*)parent_IB,&DOS,sizeof(DOS),0);
  31.     IMAGE_NT_HEADERS INH={0};
  32.     if(ReadProcessMemory(h,(void*)(parent_IB+DOS.e_lfanew),&INH,sizeof(INH),0))
  33.     {
  34.                 if((INH.OptionalHeader.DataDirectory[7].VirtualAddress)==0) return 0;
  35.         unsigned long addr=parent_IB+INH.OptionalHeader.DataDirectory[7].VirtualAddress; //copyright data directory
  36.         char* pStr=(char*)LocalAlloc(LMEM_ZEROINIT,100);
  37.  
  38.         if(ReadProcessMemory(h,(void*)addr,pStr,100,0))
  39.         {
  40.             if(!lstrcmp(pStr,"32-bit analysing debugger"))
  41.             {
  42.                 MessageBox(0,"OllyDbg detected","waliedassar",0);
  43.             }
  44.         }
  45.         LocalFree(pStr);
  46.     }
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement