Advertisement
cloverleafswag3

VAC shiz mate

May 4th, 2016
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //  ModuleDumper
  2. //  Inject into SteamService.exe or Steam.exe (depends on permissions)
  3. //  Steam version 3.17.73.86
  4.  
  5. // this shit is straight fucked up
  6. // straight up shit this is mate
  7.  
  8. #include "stdafx.h"
  9. #include "SteamService.h"
  10.  
  11. DWORD dwDumpedHashes[14] = {
  12.     0x04D37270, 0xAB5BABB4,
  13.     0x2B74FA80, 0xBC5AD655,
  14.     0x04FD4065, 0xD765CC47,
  15.     0xB9C6D0C9, 0x5478D4A2,
  16.     0x697BE547, 0xD1B9323E,
  17.     0x309303AA, 0x22FF30F5,
  18.     0x74C3D180, 0x08ACF517
  19. };
  20. BOOL AlreadyHaveModule(DWORD dwModuleHash) {
  21.     for (DWORD i = 0; i < 14; i++) {
  22.         if (dwModuleHash == dwDumpedHashes[i])
  23.             return TRUE;
  24.     }
  25.  
  26.     return FALSE;
  27. }
  28.  
  29. DWORD GetModuleHash(CModule *pModule) {
  30.     PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)pModule->m_pbBuffer;
  31.     PIMAGE_NT_HEADERS pNtHeaders = (PIMAGE_NT_HEADERS)(pModule->m_pbBuffer + pDosHeader->e_lfanew);
  32.     if (pNtHeaders->Signature != IMAGE_NT_SIGNATURE) {
  33.         LogFile("pNtHeaders signature is wrong!");
  34.         return 0;
  35.     }
  36.  
  37.     // first section is usually .text
  38.     PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pNtHeaders);
  39.     PBYTE pbSection = pModule->m_pbBuffer + pSection->PointerToRawData;
  40.     if (IsBadReadPtr(pbSection, pSection->SizeOfRawData)) {
  41.         LogFile("bad pbSection raw data!");
  42.         return 0;
  43.     }
  44.  
  45.     return CalculateCRC32(pbSection, pSection->SizeOfRawData);
  46. }
  47. VOID DumpModule(CModule *pModule, DWORD dwModuleHash) {
  48.     CHAR szBuffer[MAX_PATH];
  49.     sprintf_s(szBuffer, "C:\\Users\\imGol2den\\Desktop\\vac3 %08X.dll", dwModuleHash);
  50.     DumpFile(szBuffer, pModule->m_pbBuffer, pModule->m_cbBuffer);
  51.     LogFile("vac3 module 0x%08X dumped!", dwModuleHash);
  52. }
  53. VOID __fastcall LoadModuleHookInternal(CModule *pModule) {
  54.     // hash the .text section
  55.     DWORD dwModuleHash = GetModuleHash(pModule);
  56.  
  57.     // take a dump if we dont have this module yet
  58.     // make sure its not already loaded and we dont have the module yet
  59.     if (pModule->m_pbBuffer && !AlreadyHaveModule(dwModuleHash)) {
  60.         DumpModule(pModule, dwModuleHash);
  61.     }
  62.  
  63.     // notify that the module is scanning
  64.     LogFile("vac3 module 0x%08X is scanning!", dwModuleHash);
  65. }
  66.  
  67. // currently this crashes after a little
  68.  
  69. DWORD dwLoadModuleReturn = NULL;
  70. bool __declspec(naked) LoadModuleHook(CModule *pModule, BYTE bFlags) {
  71.     __asm {
  72.         // save ebp and move esp
  73.         push ebp
  74.             mov ebp, esp
  75.  
  76.             // save registers
  77.             pushad
  78.  
  79.             // call our internal hook
  80.             // its a __fastcall
  81.             mov ecx, [ebp + 0x08]
  82.             call LoadModuleHookInternal
  83.  
  84.             // restore registers
  85.             popad
  86.             pop ebp
  87.  
  88.             // original instructions
  89.             push ebp
  90.             mov ebp, esp
  91.             push esi
  92.             mov esi, [ebp + 0x08]
  93.  
  94.             // return to original function
  95.             jmp[dwLoadModuleReturn]
  96.     }
  97. }
  98.  
  99. VOID ModuleDumperThread(LPVOID lpReserved) {
  100.     LogFile("module dumper loaded!");
  101.  
  102.     DWORD dwSteamService = (DWORD)GetModuleHandle("steamservice.dll");
  103.     LogFile("SteamService.dll 0x%X", dwSteamService);
  104.     if (dwSteamService) {
  105.         PBYTE pbLoadModule = (PBYTE)(dwSteamService + LOADMODULE_OFFSET);
  106.         if (*pbLoadModule == 0x55 /* push ebp */) {
  107.             WriteJMP(pbLoadModule, (PBYTE)LoadModuleHook);
  108.             dwLoadModuleReturn = (DWORD)pbLoadModule + 0x07;
  109.             LogFile("hooked LoadModule!");
  110.         }
  111.     }
  112. }
  113.  
  114. BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
  115.     switch (ul_reason_for_call) {
  116.     case DLL_PROCESS_ATTACH:
  117.         DisableThreadLibraryCalls(hModule);
  118.         CreateThread(NULL, 0x1000, (LPTHREAD_START_ROUTINE)ModuleDumperThread, lpReserved, NULL, NULL);
  119.         break;
  120.     case DLL_THREAD_ATTACH:
  121.     case DLL_THREAD_DETACH:
  122.     case DLL_PROCESS_DETACH:
  123.         break;
  124.     }
  125.  
  126.     return TRUE;
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement