Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 20th, 2010 | Syntax: None | Size: 1.72 KB | Hits: 134 | Expires: Never
Copy text to clipboard
  1. #include "stdafx.h"
  2. #include <windows.h>
  3. #include <stdio.h>
  4.  
  5.  
  6.  
  7. const char findme[8] = "PRIVMSG";
  8.  
  9. int _tmain(int argc, _TCHAR* argv[])
  10. {
  11.   HANDLE ThisProc = OpenProcess(PROCESS_ALL_ACCESS,true,GetCurrentProcessId());
  12.   MEMORY_BASIC_INFORMATION mbi;
  13.   SYSTEM_INFO si;
  14.   GetSystemInfo(&si);
  15.   DWORD dwStart = 0;
  16.   SIZE_T v;
  17.   char *p;
  18.   DWORD lpRead;
  19.   const char* regionp;
  20.   BYTE s = 't';
  21.   char *memchrp;
  22.   int memcmpr;
  23.   const char findme[8] = "PRIVMSG";
  24.   HANDLE Term;
  25.  
  26.  while(dwStart < (DWORD)si.lpMaximumApplicationAddress)
  27.   {
  28.                                                                
  29.      v = VirtualQueryEx(ThisProc,
  30.                  (void *)dwStart,
  31.                             &mbi,
  32. sizeof(MEMORY_BASIC_INFORMATION));
  33.  
  34.          if(v == 0)
  35.          {
  36.                 printf("%s\n","breaking");
  37.                 break;
  38.          }
  39.  
  40.          if(mbi.State == MEM_COMMIT)
  41.          {
  42.              printf("%s\n","mem_commit");
  43.                  p = (char *)malloc(mbi.RegionSize);
  44.  
  45.        
  46.  
  47.                  printf("Memory at %02x, size %d\n",
  48.                   mbi.BaseAddress,
  49.                    mbi.RegionSize);
  50.            
  51.                  if(ReadProcessMemory(ThisProc,(void *)dwStart,p,mbi.RegionSize,&lpRead))
  52.          {
  53.                                 const char* offset = regionp;
  54.                                 while ((offset = (const char*)memchr(offset, findme[0], regionp+mbi.RegionSize-offset)) != 0)
  55.                                 {
  56.                                            if (memcmp(offset, findme, 7) == 0)
  57.                                            {
  58.                                                    printf("%s\n","found");
  59.                                                Sleep(5000);
  60.                                                    break;
  61.                                            }
  62.                                            
  63.                                            ++offset;
  64.                                 }
  65.                  }
  66.          }
  67.  
  68.          if(dwStart + mbi.RegionSize < dwStart)
  69.          {
  70.                 printf("%s\n","breaking");
  71.                  break;
  72.          }
  73.            
  74.          if(mbi.RegionSize != lpRead)
  75.      {
  76.          printf("Not enough bytes read %d != %d\n",mbi.RegionSize,lpRead);
  77.      }
  78.        
  79.          dwStart += mbi.RegionSize;
  80.  
  81.        
  82.  
  83.         Sleep(5);
  84.  
  85.   }
  86.  
  87.  
  88.         return 0;
  89. }