Advertisement
tekkitak1

AC Code

May 29th, 2020
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 17.78 KB | None | 0 0
  1. //sorry for bad code it was mostly bonded together, and also didnt knew how to send the files soo i just pasted all .h files into this //one to be single file
  2.  
  3. // gameclasses.h
  4. struct Vector3 { float X, Y, Z; };
  5.  
  6. class Entity
  7. {
  8. public:
  9.     char pad_0000[4]; //0x0000
  10.     Vector3 HeadPos; //0x0004
  11.     Vector3 Velocity; //0x0010
  12.     int32_t X_speed; //0x001C
  13.     int32_t N000005BD; //0x0020
  14.     int32_t N000005BE; //0x0024
  15.     Vector3 MinusVelocity; //0x0028
  16.     Vector3 Pos; //0x0034
  17.     Vector3 angle; //0x0040
  18.     char pad_004C[4]; //0x004C
  19.     float JumpHeight; //0x0050
  20.     int32_t TicksInAir; //0x0054
  21.     float LocalHitBoxWidth; //0x0058
  22.     float PosZOfHeadFromBody; //0x005C
  23.     float PosZOfHeadFromBodyConst; //0x0060
  24.     float LocalHitBoxHeight; //0x0064
  25.     char pad_0068[1]; //0x0068
  26.     bool BonLand; //0x0069
  27.     char pad_006A[1]; //0x006A
  28.     bool Bjump; //0x006B
  29.     char pad_006C[2]; //0x006C
  30.     bool Bcrouched; //0x006E
  31.     char pad_006F[1]; //0x006F
  32.     bool BstandingStill; //0x0070
  33.     bool Bscoped; //0x0071
  34.     char pad_0072[14]; //0x0072
  35.     int8_t FrontBack; //0x0080
  36.     int8_t LeftRight; //0x0081
  37.     int8_t Spectator; //0x0082
  38.     bool BnotDrawBody; //0x0083
  39.     float CrouchSpeed; //0x0084
  40.     char pad_0088[4]; //0x0088
  41.     bool BleftBTN; //0x008C
  42.     bool BrightBTN; //0x008D
  43.     bool BfrontBTN; //0x008E
  44.     bool BbackBTN; //0x008F
  45.     char pad_0090[104]; //0x0090
  46.     int32_t Health; //0x00F8
  47.     int32_t Armor; //0x00FC
  48.     char pad_0100[4]; //0x0100
  49.     int32_t SelectedWeapon; //0x0104
  50.     char pad_0108[12]; //0x0108
  51.     int32_t PistolReloadAmmo; //0x0114
  52.     int32_t CarbineReloadAmmo; //0x0118
  53.     int32_t ShotgunReloadAmmo; //0x011C
  54.     int32_t AssaultReloadAmmo; //0x0120
  55.     int32_t SniperReloadAmmo; //0x0124
  56.     int32_t SubgunReloadAmmo; //0x0128
  57.     char pad_012C[4]; //0x012C
  58.     int32_t GrenadeReloadAmmo; //0x0130
  59.     int32_t CPistolReloadAmmo; //0x0134
  60.     char pad_0138[4]; //0x0138
  61.     int32_t PistolAmmo; //0x013C
  62.     int32_t CarbineAmmo; //0x0140
  63.     int32_t ShotgunAmmo; //0x0144
  64.     int32_t AssaultAmmo; //0x0148
  65.     int32_t SniperAmmo; //0x014C
  66.     int32_t SubgunAmmo; //0x0150
  67.     char pad_0154[4]; //0x0154
  68.     int32_t Grenades; //0x0158
  69.     int32_t CPistolAmmo; //0x015C
  70.     char pad_0160[40]; //0x0160
  71.     int32_t KnifeUsed; //0x0188
  72.     int32_t PistolShot; //0x018C
  73.     int32_t CarbineShot; //0x0190
  74.     int32_t ShotgunShot; //0x0194
  75.     int32_t AssaultShot; //0x0198
  76.     int32_t SniperShot; //0x019C
  77.     int32_t SubgunShot; //0x01A0
  78.     int32_t SomethingShot; //0x01A4
  79.     int32_t GrenadesUsed; //0x01A8
  80.     int32_t CPistolShot; //0x01AC
  81.     char pad_01B0[52]; //0x01B0
  82.     int32_t EntityID; //0x01E4
  83.     char pad_01E8[20]; //0x01E8
  84.     int32_t kills; //0x01FC
  85.     char pad_0200[4]; //0x0200
  86.     int32_t deaths; //0x0204
  87.     char pad_0208[4]; //0x0208
  88.     int32_t TeamKills; //0x020C
  89.     char pad_0210[20]; //0x0210
  90.     bool Bshoot; //0x0224
  91.     char Name[16]; //0x0225
  92.     char pad_0235[247]; //0x0235
  93.     int8_t team; //0x032C
  94.     char pad_032D[11]; //0x032D
  95.     int32_t Fly; //0x0338
  96.     int32_t N00000318; //0x033C
  97.     char pad_0340[8]; //0x0340
  98.     class WeaponStruct* KnifeWeaponStruct; //0x0348
  99.     class WeaponStruct* PistolWeaponStruct; //0x034C
  100.     class WeaponStruct* CarbineWeaponStruct; //0x0350
  101.     class WeaponStruct* ShotgunWeaponStruct; //0x0354
  102.     class WeaponStruct* SubgunWeaponStruct; //0x0358
  103.     class WeaponStruct* SniperWeaponStruct; //0x035C
  104.     class WeaponStruct* AssaultWeaponStruct; //0x0360
  105.     class WeaponStruct* CpistolWeaponStruct; //0x0364
  106.     class WeaponStruct* Grenade; //0x0368
  107.     class WeaponStruct* DualPistol; //0x036C
  108.     class WeaponStruct* LastWeaponSelected; //0x0370
  109.     class WeaponStruct* CurrentWeaponSelected; //0x0374
  110.     class WeaponStruct* CurrentWeaponSelected2; //0x0378
  111.     class WeaponStruct* CurrentWeaponSelected3; //0x037C
  112.     class WeaponStruct* CurrentWeaponSelected4; //0x0380
  113.     class WeaponStruct* CurrentWeaponSelected5; //0x0384
  114.     int32_t Tick; //0x0388
  115. }; //Size: 0x038C
  116. static_assert(sizeof(Entity) == 0x38C);
  117.  
  118. class EntityArray
  119. {
  120. public:
  121.     char pad_0000[4]; //0x0000
  122.     class Entity* EntityPtrArray[32]; //0x0004
  123. }; //Size: 0x0084
  124. static_assert(sizeof(EntityArray) == 0x84);
  125.  
  126. class WeaponStruct
  127. {
  128. public:
  129.     int8_t IconID; //0x0004
  130.     char pad_0005[3]; //0x0005
  131.     class Entity* EntityPtr; //0x0008
  132.     char* WeaponName; //0x000C
  133.     int32_t* Ammo; //0x0010
  134.     int32_t* AmmoInClip; //0x0014
  135.     uint8_t ID; //0x0018
  136.     uint8_t canShot; //0x0019
  137.     char pad_001A[2]; //0x001A
  138.     bool Bspraying; //0x001C
  139.     char pad_001D[11]; //0x001D
  140.     bool Bscoped; //0x0028
  141.     char pad_0029[11]; //0x0029
  142.  
  143.     virtual void Function0();
  144.     virtual void Function1();
  145.     virtual void Function2();
  146.     virtual void Function3();
  147.     virtual void Function4();
  148.     virtual void Function5();
  149.     virtual void Function6();
  150.     virtual void Function7();
  151.     virtual void Function8();
  152.     virtual void Function9();
  153.     virtual void Function10();
  154.     virtual void SomeFunction();
  155. }; //Size: 0x0034
  156. static_assert(sizeof(WeaponStruct) == 0x34);
  157.  
  158. class N00001CC6
  159. {
  160. public:
  161.     char pad_0000[4]; //0x0000
  162. }; //Size: 0x0004
  163. static_assert(sizeof(N00001CC6) == 0x4);
  164.  
  165. class N00001D0F
  166. {
  167. public:
  168.     char pad_0000[68]; //0x0000
  169. }; //Size: 0x0044
  170. static_assert(sizeof(N00001D0F) == 0x44);
  171.  
  172. class N00001D8D
  173. {
  174. public:
  175.     char pad_0000[68]; //0x0000
  176. }; //Size: 0x0044
  177. static_assert(sizeof(N00001D8D) == 0x44);
  178.  
  179. class N00001E2C
  180. {
  181. public:
  182.     char pad_0000[68]; //0x0000
  183. }; //Size: 0x0044
  184. static_assert(sizeof(N00001E2C) == 0x44);
  185.  
  186.  
  187. // dllmain.cpp
  188. #include "pch.h"
  189. #include <iostream>
  190. #include <windows.h>
  191. #include <TlHelp32.h>
  192. #include <vector>
  193. #include <thread>
  194. #include <random>
  195. #include <math.h>
  196.  
  197. double M_PI = 3.14159265358979323846;
  198. bool debug = false;
  199. bool run = true, CTRL = false, CTRLToggle = false;
  200. int SpecSet;
  201. EntityArray* Entities; uintptr_t baseAddrs;
  202.  
  203. //Functions______________________
  204. float YawFit(float value) {
  205.     if (value > 360) { return YawFit(value - 360); }
  206.     else if (value < 0) { return YawFit(value + 360); }
  207.     else { return value; };
  208. };
  209. float PitchFit(float value) {
  210.     if (value > 90) { return PitchFit(value - 90); }
  211.     else if (value < -90) { return PitchFit(value + -90); }
  212.     else { return value; };
  213. };
  214. double DegToRad(double angleDegrees) { return (angleDegrees)*M_PI/180.0; };
  215. double RadToDeg(double angleRadians) { return (angleRadians)*180.0/M_PI; };
  216. bool CheckEnts() {
  217.     if (Entities != NULL) {
  218.         return true;
  219.     }
  220.     else {
  221.         Entities = *(EntityArray**)(baseAddrs + 0x10F4F8);
  222.         return false;
  223.     }
  224. };
  225. float power(float num) { return num * num; };
  226. float Distance(Vector3 vec1, Vector3 vec2) {
  227.     return abs(sqrt(power(vec1.X - vec2.X) + power(vec1.Y - vec2.Y) + power(vec1.Z - vec2.Z)));
  228.     // return abs(sqrt(power(vec1.X)+power(vec1.Y)+power(vec1.Z)) - sqrt(power(vec2.X) + power(vec2.Y) + power(vec2.Z)));
  229. };
  230. std::string TeamName(unsigned int teamNum) {
  231.     if (teamNum % 2) {return "RVSF";} else {return "CLA";};
  232. };
  233. std::string Generate_random_string(std::size_t length) {
  234.     const std::string CHARACTERS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  235.  
  236.     std::random_device random_device;
  237.     std::mt19937 generator(random_device());
  238.     std::uniform_int_distribution<> distribution(0, CHARACTERS.size() - 1);
  239.  
  240.     std::string random_string;
  241.  
  242.     for (std::size_t i = 0; i < length; ++i)
  243.     {
  244.         random_string += CHARACTERS[distribution(generator)];
  245.     }
  246.  
  247.     return random_string;
  248. };
  249.  
  250. void memPatch(BYTE* addrs,SIZE_T size,BYTE* bytes) {
  251.     DWORD oldProtect;
  252.     VirtualProtect(addrs, size, PAGE_EXECUTE_READWRITE, &oldProtect);
  253.     memcpy(addrs, bytes, size);
  254.     VirtualProtect(addrs, size, oldProtect, &oldProtect);
  255. };
  256.  
  257. DWORD WINAPI MainThread(HMODULE hModule) {
  258.     //console allocation______________________________
  259.     AllocConsole();
  260.     FILE* f;
  261.     freopen_s(&f, "CONOUT$", "w", stdout);
  262.     SetConsoleTitle(L"AssaultCube hack");
  263.  
  264.     //finding base adress______________________________
  265.     baseAddrs = (uintptr_t)GetModuleHandle(L"ac_client.exe");
  266.  
  267.     //getting entity pointer______________________________
  268.     Entity* Player = *(Entity**)(baseAddrs + 0x109B74);
  269.     Entities = *(EntityArray**)(baseAddrs+0x10F4F8);
  270.     int *TotalPlayers = (int*)(baseAddrs + 0x10F500);
  271.  
  272.     //Defining game functions______________________________
  273.     typedef Entity* (_cdecl* _Traceline)();
  274.     _Traceline Traceline = (_Traceline)(baseAddrs + 0x607C0);
  275.     typedef void(_cdecl* _FullBright)();
  276.     _FullBright FullBright = (_FullBright)(baseAddrs + 0x4f040);
  277.  
  278.     //adresses specifiing if hack is ON/OFF______________________________
  279.     bool BNoRecoil = false, BHH = false, BAH = false, BGH = false, Bflyhack = false, BSpectate = false, BBHop = false, BdrawEnts = false, BTriggerBot = false, BFullBright = false, BAimBot = false;
  280.     bool* FBBool = (bool*)(baseAddrs + 0x1100A0), * EditMode = (bool*)(baseAddrs+0x10A1AB);
  281.  
  282.     std::cout.precision(4);
  283.     int n = 0;
  284.     while (run) {
  285.         if (n == 50000) {
  286.             system("cls");
  287.             std::cout << "TOGGLE CTRL + BUTTON NEXT TO THE NAME OF HACK\n";
  288.             std::cout << "if gamehack start with / then its single player\nsolo hacks are only visible in debug mode!\n";
  289.             if (BdrawEnts && *TotalPlayers>00000000) {
  290.                 if (CheckEnts()) {
  291.                     for (int t = 0; t < *TotalPlayers - 1; t++) {
  292.                         std::cout << std::endl << (const char*)(Entities->EntityPtrArray[t]->Name) << " is in: " << TeamName(Entities->EntityPtrArray[t]->team) << " | ID: " << Entities->EntityPtrArray[t]->EntityID;
  293.                     };
  294.                 } else {
  295.                     std::cout << "couldnt find entity array, please join multiplayer or game with bots!\n press [Num5] to get back!";
  296.                 };
  297.             }
  298.             else {
  299.                 if (debug) {
  300.                     std::cout << "__________________VALUE INFO__________________\n";
  301.                     std::cout << "X position: " << Player->HeadPos.X << ", Yawn is: " << Player->angle.X << "\n----------------------\n";
  302.                     std::cout << "Y position: " << Player->HeadPos.Y << ", Pitch is: " << Player->angle.Y << "\n----------------------\n";
  303.                     std::cout << "Z position: " << Player->HeadPos.Z << ", Roll is: " << Player->angle.Z << "\n----------------------\n";
  304.                     std::cout << "Your team is: " << TeamName(Player->team) << "\n----------------------\n";
  305.                     std::cout << "front/back speed: " << signed(Player->FrontBack) << " right/left speed: " << signed(Player->LeftRight) << "\n----------------------\n"; // for some reason causing error...
  306.                     std::cout << "Ammo value is: " << Player->CurrentWeaponSelected->Ammo << "\n----------------------\n";
  307.                     std::cout << "Health value is: " << Player->Health << "\n----------------------\n";
  308.                     std::cout << "Kill/Deaths: " << Player->kills << "/" << Player->deaths << "\n----------------------\n";
  309.                     std::cout << "Total players: " << *TotalPlayers << "\n----------------------\n";
  310.                 }
  311.                 std::cout << "__________________HACK INFO__________________\n" << std::boolalpha; //MP HACKS
  312.                 std::cout << "\n[C] No recoil ---> " << BNoRecoil;
  313.                 std::cout << "\n[Q] Flyhack ---> " << Bflyhack << "   detectable!";
  314.                 std::cout << "\n[E] Spectate --->" << BSpectate << "   detectable!";
  315.                 std::cout << "\n[X] Bunnyhop --->" << BBHop;
  316.                 std::cout << "\n[Y] TriggerBot --->" << BTriggerBot;
  317.                 std::cout << "\n[H] AimBot (Test) --->" << BAimBot;
  318.                 std::cout << "\n[K] FullBright --->" << BFullBright;
  319.  
  320.                 if (debug) { //SOLO HACKS
  321.                     std::cout << "\n[1] /Health hack ---> " << BHH;
  322.                     std::cout << "\n[2] /Ammo hack ---> " << BAH;
  323.                     std::cout << "\n[3] /Grenade hack ---> " << BGH;
  324.                 };
  325.             };
  326.             std::cout << "\n\n[9] Debuging mode---> " << debug << "   |   [END] exit";
  327.             std::cout << "\nCTRL toggle : " << CTRL << " | [0] auto CTRL --->" << CTRLToggle;
  328.             n = 0;
  329.         };
  330.         if (GetAsyncKeyState(VK_CONTROL) & 1) { CTRL = !CTRL; };
  331.         if (GetAsyncKeyState(VK_NUMPAD0) & 1) { CTRLToggle = !CTRLToggle; };
  332.         if (n % 200) {
  333.             if (GetAsyncKeyState(VK_END) & 1 && CTRL) {
  334.                 fclose(f);
  335.                 FreeConsole();
  336.                 FreeLibraryAndExitThread(hModule, 0);
  337.                 return 0;
  338.                 run = !run;
  339.                 return 1;
  340.             };
  341.             if (debug) { // single player hacks
  342.                 if (GetAsyncKeyState(VK_NUMPAD1) & 1 && CTRL) {
  343.                     BHH = !BHH;
  344.                     if (CTRLToggle) { CTRL = false; };
  345.                 };
  346.                 if (GetAsyncKeyState(VK_NUMPAD2) & 1 && CTRL) {
  347.                     BAH = !BAH;
  348.                     if (CTRLToggle) { CTRL = false; };
  349.                 };
  350.                 if (GetAsyncKeyState(VK_NUMPAD3) & 1 && CTRL) {
  351.                     BGH = !BGH;
  352.                     if (CTRLToggle) { CTRL = false; };
  353.                 };
  354.                 if (GetAsyncKeyState(VK_NUMPAD5) & 1 && CTRL) {
  355.                     BdrawEnts = !BdrawEnts;
  356.                 };
  357.             };
  358.             if (GetAsyncKeyState(0x43) & 1 && CTRL) {
  359.                 BNoRecoil = !BNoRecoil;
  360.                 if (BNoRecoil) {
  361.                     memPatch((BYTE*)baseAddrs + 0x5BAA2, 3, (BYTE*)"\x90\x90\x90");
  362.                     //replace asm code for recoil with nop
  363.                 }
  364.                 else {
  365.                     memPatch((BYTE*)baseAddrs + 0x5BAA2, 3, (BYTE*)"\xD8\x4B\x50");
  366.                     //replace nops back with the code
  367.                 };
  368.                 if (CTRLToggle) { CTRL = false; };
  369.             };
  370.             if (GetAsyncKeyState(0x51) & 1 && CTRL) {
  371.                 Bflyhack = !Bflyhack;
  372.                 if (Bflyhack) {
  373.                     Player->Fly = 5;
  374.                 }
  375.                 else {
  376.                     Player->Fly = 0;
  377.                 };
  378.                 if (CTRLToggle) { CTRL = false; };
  379.             };
  380.             if (GetAsyncKeyState(0x58) & 1 && CTRL) {
  381.                 BBHop = !BBHop;
  382.                 if (CTRLToggle) { CTRL = false; };
  383.             };
  384.             if (GetAsyncKeyState(VK_NUMPAD9) & 1 && CTRL) {
  385.                 debug = !debug;
  386.                 if (CTRLToggle) { CTRL = false; };
  387.             };
  388.             if (GetAsyncKeyState(0x59) & 1 && CTRL) {
  389.                 BTriggerBot = !BTriggerBot;
  390.                 if (CTRLToggle) { CTRL = false; };
  391.             };
  392.             if (GetAsyncKeyState(0x45) & 1 && CTRL) {
  393.                 BSpectate = !BSpectate;
  394.                 if (!BSpectate) {
  395.                     Player->Spectator = 0;
  396.                 }
  397.                 if (CTRLToggle) { CTRL = false; };
  398.             };
  399.             if (GetAsyncKeyState(0x4B) & 1 && CTRL) {
  400.                 BFullBright = !BFullBright;
  401.                 if (BFullBright) {
  402.                     *FBBool = true;
  403.                     *EditMode = true;
  404.                     FullBright();
  405.                     *EditMode = false;
  406.                 }
  407.                 else {
  408.                     *FBBool = false;
  409.                     FullBright();
  410.                 };
  411.                 if (CTRLToggle) { CTRL = false; };
  412.             };
  413.             if (GetAsyncKeyState(0x48) & 1 && CTRL) {
  414.                 BAimBot = !BAimBot;
  415.                 if (CTRLToggle) { CTRL = false; };
  416.             };
  417.  
  418.         };
  419.         if (BTriggerBot) {
  420.             Entity* aimed = Traceline();
  421.             if (aimed != 0) {
  422.                 if (aimed->team != Player->team) {
  423.                     Player->Bshoot = true;
  424.                 } else {
  425.                     Player->Bshoot = false;
  426.                 }
  427.             } else {
  428.                 Player->Bshoot = false;
  429.             };
  430.         };
  431.         if (BSpectate && Player->Spectator != 4) { Player->Spectator = 0x4; } else if (!BSpectate && SpecSet > 0) { Player->Spectator = 0x0; SpecSet--; };
  432.         if (BBHop) { Player->Bjump = true; };
  433.         if (BAimBot) {
  434.             if (CheckEnts()) {
  435.                 int BotID = NULL;
  436.                 float lowest = 9999;
  437.                 float dist = NULL;
  438.                 for (int t = 1; t < *TotalPlayers-1; t++) { //loops trought all entities!
  439.                     dist = Distance(Entities->EntityPtrArray[t]->HeadPos, Player->HeadPos);
  440.                     if ((dist < lowest) && dist < 200) {
  441.                         BotID = t;
  442.                         lowest = dist;
  443.                     };
  444.                 };
  445.                 if (BotID != NULL) {
  446.                     float DiffX = Player->HeadPos.X - Entities->EntityPtrArray[BotID]->HeadPos.X;
  447.                     float DiffY = Player->HeadPos.Y - Entities->EntityPtrArray[BotID]->HeadPos.Y;
  448.                     float DiffZ = Player->HeadPos.Z - Entities->EntityPtrArray[BotID]->HeadPos.Z;
  449.                     Player->angle.X = YawFit(180.0+RadToDeg(asin(DiffX/sqrt(power(DiffX)+power(DiffY)))));
  450.                     Player->angle.Y = PitchFit(2+RadToDeg(acos(sqrt(power(DiffZ)+(power(DiffX)+power(DiffY)))/sqrt(power(DiffX) + power(DiffY)))));
  451.                 };
  452.             };
  453.         };
  454.         if (debug) {
  455.             if (BHH) { Player->Health = 666; };
  456.             if (BAH) { *Player->CurrentWeaponSelected->Ammo = 666; };
  457.             if (BGH) { Player->Grenades = 5; };
  458.         };
  459.         n++;
  460.     };
  461.     fclose(f);
  462.     FreeConsole();
  463.     FreeLibraryAndExitThread(hModule, 0);
  464.     return 0;
  465.     return 1;
  466. };
  467.  
  468. BOOL APIENTRY DllMain( HMODULE hModule,
  469.                        DWORD  ul_reason_for_call,
  470.                        LPVOID lpReserved
  471.                      )
  472. {
  473.     switch (ul_reason_for_call)
  474.     {
  475.     case DLL_PROCESS_ATTACH:
  476.         CloseHandle(CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)MainThread, hModule, 0, nullptr));
  477.     case DLL_THREAD_ATTACH:
  478.     case DLL_THREAD_DETACH:
  479.     case DLL_PROCESS_DETACH:
  480.         break;
  481.     }
  482.     return TRUE;
  483. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement