OriHackingTutorials

game hacking choose you values

Sep 23rd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.56 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <Windows.h>
  4. #include <string>
  5. #include <cmath>
  6. #include <ctime>
  7.  
  8. using namespace std;
  9. DWORD FindDmaAddy(int PointerLevel, HANDLE handle, DWORD Offsets[], DWORD BaseAddress);
  10. void WriteToMemory(HANDLE handle);
  11.  
  12. std::string GameName = "AssaultCube";
  13. LPCSTR LGameWindow = "AssaultCube";
  14.  
  15. std::string GameStatus;
  16.  
  17. //ammo variables
  18. //BYTE AmmoValue[] = { 0xA3, 0x1C, 0x0, 0x0 };
  19. int AmmoValue;
  20. DWORD AmmoBaseAddress = { 0x509B74 };
  21. DWORD AmmoOffsets[] = { 0x374, 0x14, 0x0 };
  22.  
  23. //health variables
  24. //BYTE HealthValue[] = { 0x39, 0x5, 0x0, 0x0 };
  25. int HealthValue;
  26. DWORD HealthBaseAddress = { 0x50f4f4 };                // these are the variables to find our values.
  27. DWORD HealthOffsets[] = { 0xf8 };
  28.  
  29. //smoke variables
  30. //BYTE HealthValue[] = { 0x39, 0x5, 0x0, 0x0 };
  31. int SmokeValue;
  32. DWORD SmokeBaseAddress = { 0x50F4F4 };
  33. DWORD SmokeOffsets[] = { 0x368, 0x14, 0x0 };
  34.  
  35. int main() {
  36.     DWORD AddressToWrite;
  37.     string WantAgain;
  38.     system("title Hackermode");
  39.     HWND hwnd = FindWindowA(NULL, "AssaultCube");
  40.     if (hwnd == NULL) {
  41.         cout << "Cannot find window" << endl;
  42.         Sleep(3000);
  43.         exit(-1);
  44.     }
  45.     else {
  46.  
  47.         DWORD procID;
  48.         GetWindowThreadProcessId(hwnd, &procID);
  49.         HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);
  50.  
  51.         if (procID == NULL) {
  52.  
  53.             cout << "Cannot obtain process" << endl;
  54.             Sleep(3000);
  55.             exit(-1);
  56.         }
  57.         else {
  58.         gotome:
  59.             system("cls");
  60.             // health
  61.             cout << "How much health do you want? ";
  62.             cin >> HealthValue;
  63.             //ammo
  64.             cout << "How many bullets do you want to add? ";
  65.             cin >> AmmoValue;
  66.             //smoke
  67.             cout << "How many smokes do you want? ";
  68.             cin >> SmokeValue;
  69.             //shield (doesnt work)
  70.             WriteToMemory(handle);
  71.  
  72.             cout << "===========================================================" << endl;
  73.             cout << "|         You now have " << HealthValue << " health points" << endl;
  74.             cout << "|         You now have " << AmmoValue << " bullet" << endl;
  75.             cout << "|         You now have " << SmokeValue << " smokes" << endl;
  76.             cout << "===========================================================" << endl;
  77.             cout << "writed to memory successfully." << endl << endl;
  78.  
  79.             cout << "Do you want again? (yes/no): ";
  80.             cin >> WantAgain;
  81.  
  82.             if (WantAgain == "yes" || WantAgain == "y") {
  83.                 goto gotome;
  84.             }
  85.             else if (WantAgain == "no" || WantAgain == "n") {
  86.                 return false;
  87.             }
  88.             else {
  89.                 goto gotome;
  90.             }
  91.         } // end if advanced
  92.  
  93.     } //end else
  94.     system("pause >nul");
  95. }
  96.    
  97. //finds the address using our variables
  98. DWORD FindDmaAddy(int PointerLevel, HANDLE handle, DWORD Offsets[], DWORD BaseAddress) {
  99.     DWORD pointer = BaseAddress;
  100.     DWORD pTemp;
  101.     DWORD pointerAddr;
  102.  
  103.     for (int c = 0; c < PointerLevel; c++) {
  104.         if (c == 0) {
  105.             ReadProcessMemory(handle, (LPCVOID)pointer, &pTemp, sizeof(pTemp), NULL);
  106.         }
  107.         pointerAddr = pTemp + Offsets[c];
  108.         ReadProcessMemory(handle, (LPCVOID)pointerAddr, &pTemp, sizeof(pTemp), NULL);
  109.  
  110.     }
  111.     return pointerAddr;
  112. }
  113. // writes to memory
  114. void WriteToMemory(HANDLE handle) {
  115.     DWORD AddressToWrite;
  116.         AddressToWrite = FindDmaAddy(3, handle, AmmoOffsets, AmmoBaseAddress);
  117.         WriteProcessMemory(handle, (BYTE*)AddressToWrite, &AmmoValue, sizeof(AmmoValue), NULL);
  118.  
  119.         AddressToWrite = FindDmaAddy(1, handle, HealthOffsets, HealthBaseAddress);
  120.         WriteProcessMemory(handle, (BYTE*)AddressToWrite, &HealthValue, sizeof(HealthValue), NULL);
  121.  
  122.         AddressToWrite = FindDmaAddy(3, handle, SmokeOffsets, SmokeBaseAddress);
  123.         WriteProcessMemory(handle, (BYTE*)AddressToWrite, &SmokeValue, sizeof(SmokeValue), NULL);
  124.  
  125. }
Add Comment
Please, Sign In to add comment