Advertisement
Guest User

Untitled

a guest
Dec 28th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 KB | None | 0 0
  1. //DumpKeyToConsole.dll - extracts the key from keydat and prints it to the console.
  2.  
  3. #include <Windows.h>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. typedef char* (__cdecl* GetKeyFromDatFn)(char key[]);
  9. static GetKeyFromDatFn GetKeyFromDat;
  10.  
  11. typedef void (__cdecl *PrintfFn)(const char* format, ...);
  12. static PrintfFn PrintToConsole;
  13.  
  14. bool DataCmp(const BYTE* data, const BYTE* mask, const char* mask_char)
  15. {
  16.     for(; *mask_char; ++mask_char, ++data, ++mask)
  17.     {
  18.         if(*mask_char == 'x' && *data != *mask)
  19.         {
  20.             return false;
  21.         }
  22.     }
  23.     return (*mask_char) == NULL;
  24. }
  25.  
  26. DWORD FindPattern(DWORD Addr, DWORD Len, BYTE* mask, char* mask_char)
  27. {
  28.     for(DWORD i = NULL; i < Len; i++)
  29.     {
  30.         if(DataCmp((BYTE*)(Addr + i), mask, mask_char))
  31.         {
  32.             return (DWORD)(Addr + i);
  33.         }
  34.     }
  35.     return 0;
  36. }
  37.  
  38. DWORD BLSigScan(char* pattern, char* mask)
  39. {
  40.     static DWORD ClientBase = (DWORD)GetModuleHandleA("Blockland.exe");
  41.     if(ClientBase == NULL)
  42.     {
  43.         return -1;
  44.     }
  45.     return FindPattern(ClientBase, 0x640000, (PBYTE)pattern, mask);
  46. }
  47.  
  48. DWORD WINAPI Initialize(LPVOID Args)
  49. {
  50.     PrintToConsole = (PrintfFn)BLSigScan("\x8B\x4C\x24\x04\x8D\x44\x24\x08\x50\x6A\x00\x6A\x00\xE8\x00\x00\x00\x00\x83\xC4\x0C\xC3", "xxxxxxxxxxxxxx????xxxx");
  51.     GetKeyFromDat = (GetKeyFromDatFn)BLSigScan("\x55\x8B\xEC\x83\xE4\xF8\xB8\x00\x00\x00\x00\xE8\x00\x00\x00\x00\xA1\x00\x00\x00\x00\x8B\x0D\x00\x00\x00\x00\x33\xC5\x53\x89\x84\x24\x00\x00\x00\x00\xA1\x00\x00\x00\x00\x56\x8B\x75\x08", "xxxxxxx????x????x????xx????xxxxxx????x????xxxx");
  52.  
  53.     char buffer[17];
  54.  
  55.     GetKeyFromDat(buffer);
  56.  
  57.     PrintToConsole("Your key is: %s", buffer);
  58.  
  59.     return 0;
  60. }
  61.  
  62. int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  63. {
  64.     if(dwReason == DLL_PROCESS_ATTACH)
  65.     {
  66.         CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Initialize, NULL, 0, NULL);
  67.     }
  68.     return true;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement