Advertisement
Guest User

Untitled

a guest
Jun 16th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.57 KB | None | 0 0
  1. void rpmInt(DWORD Pid,char* ExeName,HANDLE Console,char *wBuffer,DWORD Written)
  2. {
  3.  
  4.   HANDLE ThisProc = OpenProcess(PROCESS_ALL_ACCESS,true,Pid); //
  5.   if(ThisProc == INVALID_HANDLE_VALUE)
  6.   {
  7.      wsprintf(wBuffer,"%s\n","Invalid Handle");
  8.      WriteConsole(Console,wBuffer,strlen(wBuffer),&Written,0);
  9.   }
  10.   else
  11.   {
  12.      wsprintf(wBuffer,"%s\n","Valid Handle");
  13.      WriteConsole(Console,wBuffer,strlen(wBuffer),&Written,0);
  14.   }
  15.  
  16.   MEMORY_BASIC_INFORMATION mbi;
  17.  
  18.   char Buffer[64];
  19.     SYSTEM_INFO si;
  20.     GetSystemInfo(&si);
  21.     DWORD dwStart;
  22.     SIZE_T v;
  23.     char *p;
  24.     DWORD lpRead;
  25. const char* regionp;
  26.   //BYTE s = 't';
  27.   char *memchrp;
  28.   int memcmpr;
  29.   //const char findme[8] = "PRIVMSG";
  30.   HANDLE Term;
  31.  
  32.   int s = 5;
  33.  
  34.  
  35.  
  36.   int five = 5;
  37. char findme[sizeof(five)]; //4
  38.    //search for int with the value 5
  39.    memcpy(findme, &five, sizeof(five));
  40.  
  41.  while(dwStart < (DWORD)si.lpMaximumApplicationAddress)
  42.   {
  43.            
  44.        
  45.  
  46.      v = VirtualQueryEx(ThisProc,
  47.                  (void *)dwStart,
  48.                             &mbi,
  49. sizeof(MEMORY_BASIC_INFORMATION));
  50.  
  51.      if(v == 0)
  52.      {
  53.         wsprintf(wBuffer,"%s\n","breaking");
  54.         WriteConsole(Console,wBuffer,strlen(wBuffer),&Written,0);
  55.         break;
  56.      }
  57.      
  58.  
  59.      if(mbi.State == MEM_COMMIT)
  60.      {
  61.          wsprintf(wBuffer,"%s\n","memcommit");
  62.          WriteConsole(Console,wBuffer,strlen(wBuffer),&Written,0);
  63.          p = (char *)malloc(mbi.RegionSize);
  64.          
  65.        
  66.    
  67.  
  68.          wsprintf(wBuffer,"Memory at %02x, size %d\n",mbi.BaseAddress,mbi.RegionSize);
  69.          WriteConsole(Console,wBuffer,strlen(wBuffer),&Written,0);
  70.  
  71.          
  72.            
  73.          if(ReadProcessMemory(ThisProc,(void *)dwStart,p,mbi.RegionSize,&lpRead))
  74.          {
  75.                 const char* offset = p;
  76.                 regionp = p;
  77.                 while ((offset = (const char*)memchr(offset, findme[0], regionp+mbi.RegionSize-offset)) != 0)
  78.                 {
  79.                     if(&five > mbi.BaseAddress && &five <= ((int*)mbi.BaseAddress)+mbi.RegionSize)
  80.                      {
  81.                          MessageBox(NULL,"close","",0);
  82.                    
  83.                        if (memcmp(offset, findme, 4) == 0)
  84.                        {
  85.                            MessageBox(NULL,"found","",0);
  86.                             wsprintf(Buffer,"%p %p\n",findme,five);
  87.                             WriteConsole(Console,Buffer,strlen(Buffer),&Written,0);
  88.                            Sleep(5);
  89.                            break;
  90.                        }
  91.                 }
  92.                      ++offset;
  93.                
  94.                 }
  95.          }
  96.      }
  97.  
  98.      if(dwStart + mbi.RegionSize < dwStart)
  99.      {
  100. //      printf("%s\n","breaking");
  101.          break;
  102.      }
  103.        
  104.      if(mbi.RegionSize != lpRead)
  105.      {
  106.        // printf("Not enough bytes read %d != %d\n",mbi.RegionSize,lpRead);
  107.     }
  108.        
  109.      dwStart += mbi.RegionSize;
  110.  
  111.    
  112.  
  113.     Sleep(5);
  114.  
  115.   }
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement