LawyerMorty

Assault Cube Memory Hacker

Dec 6th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3.  
  4. typedef struct pos {
  5.     int x;
  6.     int y;
  7.     int z;
  8. } pos;
  9.  
  10. char process_name[] = "AssaultCube";
  11. HWND hWnd;
  12. DWORD process_id;
  13. HANDLE handle;
  14.  
  15. int base_address = 0x400000;
  16. int local_offset = 0x10F4F4;
  17.  
  18. // Boolean Addresses
  19. int ENABLE = 1;
  20. int DISABLE = 0;
  21.  
  22. // Game Addresses
  23. int local_player; // IMPORTANT
  24. //
  25.  
  26. // Offsets
  27. int health_offset = 0x00F8;
  28. int armor_offset = 0x00FC;
  29. int x_offset = 0x0038;
  30. int y_offset = 0x003C;
  31. int z_offset = 0x0040;
  32. int magazine_offset = 0x0128;
  33. int clip_offset = 0x0150;
  34. int frag_offset = 0x0158;
  35.  
  36. int adminJack = 0x220;
  37. //
  38.  
  39. HWND hook() {
  40.     HWND hWnd = FindWindowA(NULL, process_name);
  41.  
  42.     return hWnd;
  43. }
  44.  
  45. int GetAddress(int offset) {
  46.     return (local_player + offset);
  47. }
  48.  
  49. void setup() {
  50.     // Retrieve the local player
  51.     ReadProcessMemory(handle, (LPVOID)(base_address + local_offset), &local_player, sizeof(int), 0);
  52.  
  53.     // Give the player admin access
  54.     WriteProcessMemory(handle, (LPVOID)GetAddress(adminJack), &ENABLE, sizeof(int), 0);
  55.  
  56.     // Controls
  57.     printf("\nControls\n");
  58.     printf("Press %s to add %s\n", "F1", "Health");
  59.     printf("Press %s to add %s\n", "F2", "Armor");
  60.     printf("Press %s to add %s\n", "F3", "Ammo");
  61.     printf("Press %s to add %s\n", "F4", "Frags");
  62.     printf("Press %s to add %s\n", "F5", "Magazines");
  63. }
  64.  
  65. // POSITION
  66. pos GetPosition() {
  67.     int x, y, z = 0;
  68.  
  69.     ReadProcessMemory(handle, (LPVOID)GetAddress(x_offset), &x, sizeof(int), 0);
  70.     ReadProcessMemory(handle, (LPVOID)GetAddress(y_offset), &y, sizeof(int), 0);
  71.     ReadProcessMemory(handle, (LPVOID)GetAddress(z_offset), &z, sizeof(int), 0);
  72.  
  73.     pos position;
  74.     position.x = x;
  75.     position.y = y;
  76.     position.z = z;
  77.  
  78.     return position;
  79. }
  80.  
  81. // ARMOR
  82. int GetArmor() {
  83.     int ap = 0;
  84.  
  85.     ReadProcessMemory(handle, (LPVOID)GetAddress(armor_offset), &ap, sizeof(int), 0);
  86.  
  87.     return ap;
  88. }
  89.  
  90. void SetArmor(int value = 100) {
  91.  
  92.     WriteProcessMemory(handle, (LPVOID)GetAddress(armor_offset), &value, sizeof(int), 0);
  93. }
  94.  
  95. void AddArmor(int amount) {
  96.     int ap = amount + GetArmor();
  97.  
  98.     SetArmor(ap);
  99. }
  100.  
  101. // HEALTH
  102. int GetHealth() {
  103.     int hp = 0;
  104.  
  105.     ReadProcessMemory(handle, (LPVOID)GetAddress(health_offset), &hp, sizeof(int), 0);
  106.  
  107.     return hp;
  108. }
  109.  
  110. void SetHealth(int value = 100) {
  111.  
  112.     WriteProcessMemory(handle, (LPVOID)GetAddress(health_offset), &value, sizeof(int), 0);
  113. }
  114.  
  115. void AddHealth(int amount) {
  116.     int hp = amount + GetHealth();
  117.  
  118.     SetHealth(hp);
  119. }
  120.  
  121. // AMMO
  122. int GetMagazines() {
  123.     int ammo = 0;
  124.  
  125.     ReadProcessMemory(handle, (LPVOID)GetAddress(magazine_offset), &ammo, sizeof(int), 0);
  126.  
  127.     return ammo;
  128. }
  129.  
  130. void SetMagazines(int value = 20) {
  131.     WriteProcessMemory(handle, (LPVOID)GetAddress(magazine_offset), &value, sizeof(int), 0);
  132. }
  133.  
  134. void AddMagazine() {
  135.     int ammo = 20 + GetMagazines();
  136.     SetMagazines(ammo);
  137. }
  138.  
  139. int GetAmmoInClip() {
  140.     int ammo = 0;
  141.  
  142.     ReadProcessMemory(handle, (LPVOID)GetAddress(clip_offset), &ammo, sizeof(int), 0);
  143.  
  144.     return ammo;
  145. }
  146.  
  147. void SetAmmoInClip(int value = 20) {
  148.     WriteProcessMemory(handle, (LPVOID)GetAddress(clip_offset), &value, sizeof(int), 0);
  149. }
  150.  
  151. void AddAmmoInClip(int amount) {
  152.     int clip = amount + GetAmmoInClip();
  153.  
  154.     SetAmmoInClip(clip);
  155. }
  156.  
  157. // Frags
  158. int GetFrags() {
  159.     int frags = 0;
  160.  
  161.     ReadProcessMemory(handle, (LPVOID)GetAddress(frag_offset), &frags, sizeof(int), 0);
  162.  
  163.     return frags;
  164. }
  165.  
  166. void SetFrags(int value = 20) {
  167.  
  168.     WriteProcessMemory(handle, (LPVOID)GetAddress(frag_offset), &value, sizeof(int), 0);
  169. }
  170.  
  171. void AddFrags(int amount) {
  172.     int clip = amount + GetFrags();
  173.  
  174.     SetFrags(clip);
  175. }
  176.  
  177. void stats() {
  178.     printf("\n Current Data: \n");
  179.     printf("Health: %d%%\n", GetHealth());
  180.     printf("Armor: %d%%\n", GetArmor());
  181.     printf("Magazines: %d\n", GetMagazines());
  182.     printf("Ammo In Clip: %d\n", GetAmmoInClip());
  183.  
  184.     pos position = GetPosition();
  185.     printf("Position: {%d, %d, %d}", position.x, position.y, position.z);
  186. }
  187.  
  188. void options() {
  189.     while (true) {
  190.         if (GetKeyState(VK_F1)) {
  191.             AddHealth(10);
  192.             break;
  193.         }
  194.  
  195.         if (GetKeyState(VK_F2)) {
  196.             AddArmor(100);
  197.             break;
  198.         }
  199.  
  200.         if (GetKeyState(VK_F3)) {
  201.             AddAmmoInClip(100);
  202.             break;
  203.         }
  204.  
  205.         if (GetKeyState(VK_F4)) {
  206.             AddFrags(1);
  207.             break;
  208.         }
  209.  
  210.         if (GetKeyState(VK_F5)) {
  211.             AddMagazine();
  212.             break;
  213.         }
  214.     }
  215.  
  216.     stats();
  217.  
  218.     Sleep(1000);
  219.     options();
  220. }
  221.  
  222. int main()
  223. {
  224.     printf("Welcome to the Assault Cube Console.\nThe console will help you gain an advantage when pressing function keys.\n", "");
  225.  
  226.     hWnd = hook();
  227.     if (hWnd == NULL) {
  228.         printf("Failed to find window named '%s'\n", process_name);
  229.         return -1;
  230.     }
  231.  
  232.     printf("Found window named '%s'! Attempting to open.\n", process_name);
  233.  
  234.     GetWindowThreadProcessId(hWnd, &process_id);
  235.     handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, process_id);
  236.  
  237.     if (handle == NULL) {
  238.         printf("Failed to hook into '%s'\n", process_name);
  239.         return -2;
  240.     }
  241.  
  242.     printf("Successfully opened the '%s' process.\n", process_name);
  243.  
  244.     setup();
  245.     stats();
  246.     options();
  247.  
  248.     // Remove admin access
  249.     WriteProcessMemory(handle, (LPVOID)GetAddress(adminJack), &DISABLE, sizeof(int), 0);
  250.  
  251.     return 0;
  252. }
Add Comment
Please, Sign In to add comment