Advertisement
BaSs_HaXoR

Csgo Cheat

Feb 25th, 2016
3,796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.54 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <Tlhelp32.h>
  3. #include <string>
  4. #include <iostream>
  5.  
  6.  
  7. #pragma region Offsest
  8.  
  9.  
  10. #define TRIGGER_KEY 0x4C
  11.  
  12.  
  13. DWORD EntityList = 0x04A5C9C4;
  14. DWORD LocalPlayer = 0x00A6E444;
  15. DWORD LifeState = 0x0000025B;
  16. DWORD Team = 0x000000F0;
  17. DWORD CrossHairId = 0x0000A944;
  18. DWORD EntitySize = 0x00000010;
  19.  
  20.  
  21. struct Module
  22. {
  23.     DWORD dwBase;
  24.     DWORD dwSize;
  25. };
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. class Debugger
  33. {
  34. private:
  35.     HANDLE __process;
  36.     DWORD __pId;
  37.  
  38. public:
  39.     bool Attach(char* ProcessName)
  40.     {
  41.         HANDLE PHANDLE = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
  42.         PROCESSENTRY32 CSENTRY;
  43.         CSENTRY.dwFlags = sizeof(CSENTRY);
  44.         do {
  45.             if (!strcmp(CSENTRY.szExeFile, ProcessName)) {
  46.                 __pId = CSENTRY.th32ProcessID;
  47.                 CloseHandle(PHANDLE);
  48.                 __process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, __pId);
  49.                 return true;
  50.             }
  51.         } while (Process32Next(PHANDLE, &CSENTRY));
  52.         return false;
  53.     }
  54.  
  55.     Module GetModule(char* ModuleName)
  56.     {
  57.         HANDLE module = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, __pId);
  58.         MODULEENTRY32 ModEntry;
  59.         ModEntry.dwSize = sizeof(ModEntry);
  60.         do {
  61.             if (!strcmp(ModEntry.szModule, (char*)ModuleName)) {
  62.                 CloseHandle(module);
  63.                 return { (DWORD)ModEntry.hModule, ModEntry.modBaseSize };
  64.             }
  65.         } while (Module32Next(module, &ModEntry));
  66.         return{ (DWORD)NULL, (DWORD)NULL };
  67.     }
  68.  
  69.     template <typename T> T read(DWORD Addr)
  70.     {
  71.         T __read;
  72.         ReadProcessMemory(__process, (void*)Addr, &__read, sizeof(T), NULL);
  73.         return __read;
  74.     }
  75. };
  76.  
  77.  
  78. Debugger debugger;
  79. DWORD dwClient, dwEngine;
  80.  
  81. class Entity
  82. {
  83. public:
  84.     static DWORD GetBaseEntity(int PlayerNumber)
  85.     {
  86.         return debugger.read<DWORD>(dwClient + EntityList + (EntitySize * PlayerNumber));
  87.     }
  88.  
  89.     static bool PlayerIsDead(int PlayerNumber)
  90.     {
  91.         DWORD BaseEntity = GetBaseEntity(PlayerNumber);
  92.         if (BaseEntity) {
  93.             return debugger.read<bool>(BaseEntity + LifeState);
  94.         }
  95.     }
  96.  
  97.     static int GetTeam(int PlayerNumber)
  98.     {
  99.         DWORD BaseEntity = GetBaseEntity(PlayerNumber);
  100.         if (BaseEntity) {
  101.             return debugger.read<int>(BaseEntity + Team);
  102.         }
  103.     }
  104. };
  105.  
  106. class Game
  107. {
  108. public:
  109.     static void GetPlayerBase(DWORD* retAddr)
  110.     {
  111.         (DWORD)*retAddr = debugger.read<DWORD>(dwClient + LocalPlayer);
  112.     }
  113.     static int GetTeam()
  114.     {
  115.         DWORD PlayerBase;
  116.         GetPlayerBase(&PlayerBase);
  117.         if (PlayerBase)
  118.             return debugger.read<int>(PlayerBase + Team);
  119.     }
  120.     static void GetCrosshairId(int* retAddr)
  121.     {
  122.         DWORD PlayerBase;
  123.         GetPlayerBase(&PlayerBase);
  124.         (int)*retAddr = debugger.read<int>(PlayerBase + CrossHairId) - 1;
  125.     }
  126. };
  127.  
  128. void Click()
  129. {
  130.     mouse_event(MOUSEEVENTF_LEFTDOWN, 0 , 0, 0, 0);
  131.     Sleep(1);
  132.     mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
  133. }
  134.  
  135. DWORD WINAPI TriggerThread(LPVOID PARAMS)
  136. {
  137.     while (1)
  138.     {
  139.         Sleep(1);
  140.         if (GetAsyncKeyState(TRIGGER_KEY) < 0 && TRIGGER_KEY != 1)
  141.         {
  142.             int PlayerNumber = NULL;
  143.             Game::GetCrosshairId(&PlayerNumber);
  144.             if (PlayerNumber < 64 && PlayerNumber >= 0 && Entity::GetTeam(PlayerNumber) != Game::GetTeam() && Entity::PlayerIsDead(PlayerNumber) == false)
  145.             {
  146.                 Click();
  147.             }
  148.         }
  149.    
  150.     }
  151.     return 0;
  152. }
  153.  
  154. int main()
  155. {
  156.     Module  Client, Engine;
  157.     while (!debugger.Attach("csgo.exe")) {
  158.         std::cout << ".";
  159.         Sleep(500);
  160.     }
  161.     Client = debugger.GetModule("Client.dll");
  162.     dwClient = Client.dwBase;
  163.     Engine = debugger.GetModule("Engine.dll");
  164.     dwEngine = Engine.dwBase;
  165.  
  166.     CreateThread(0, 0, &TriggerThread, 0, 0, 0);
  167.     std::cout << "Trigger thread is running...";
  168.  
  169.     while (1)
  170.     {
  171.         if (GetAsyncKeyState(VK_F4)) {
  172.             exit(0);
  173.  
  174.  
  175.         }
  176.     }
  177.  
  178.  
  179. }
  180. /* SRC: https://pastebin.com/xqhddab6 */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement