Advertisement
waliedassar

ZwQueryObject (AntiDebug) - XP & 7

Aug 13th, 2012
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.21 KB | None | 0 0
  1. // http://waleedassar.blogspot.com - (@waleedassar)
  2. #include "stdafx.h"
  3. #include "windows.h"
  4. extern "C"
  5. {
  6.     int __stdcall ZwQueryObject(int,int,void*,int,int);
  7. }
  8.  
  9. int main(int argc, char* argv[])
  10. {
  11.     unsigned long pMem=0;
  12.     unsigned long size=0;
  13.         do
  14.     {
  15.                  size+=0x1000;
  16.                  pMem=(unsigned long)VirtualAlloc(0,size,MEM_COMMIT,PAGE_READWRITE);
  17.          if(pMem==0) return 0;
  18.                  if(ZwQueryObject(0,0x3,(void*)pMem,size,0) < 0)
  19.          {
  20.                     VirtualFree((void*)pMem,0,MEM_RELEASE);
  21.          }
  22.                 else break;
  23.     }while(1);
  24.  
  25.         unsigned long  count=*(unsigned long*)pMem;
  26.     pMem+=4;
  27.     do
  28.     {
  29.           unsigned long length=*(unsigned short*)pMem;
  30.           wchar_t* TypeName=*(wchar_t**)(pMem+0x4);
  31.           unsigned long objects_count=*(unsigned long*)(pMem+0xC);   //not handles count
  32.           if(length==0x16)
  33.           {
  34.               if(!wcsncmp(TypeName,L"DebugObject",length))
  35.               {
  36.                    if(objects_count)
  37.                    {
  38.                        MessageBox(0,"Debugger detected","waliedassar",0);
  39.                        return 0; //Exit process
  40.                    }
  41.                    break;
  42.               }
  43.           }
  44.           pMem=((unsigned long)TypeName+length+4);
  45.           pMem&=-4;
  46.     }while(9);
  47.     MessageBox(0,"Okay","waliedassar",0);
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement