Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <Tlhelp32.h>
- #include <string>
- #include <iostream>
- #pragma region Offsest
- #define TRIGGER_KEY 0x4C
- DWORD EntityList = 0x04A5C9C4;
- DWORD LocalPlayer = 0x00A6E444;
- DWORD LifeState = 0x0000025B;
- DWORD Team = 0x000000F0;
- DWORD CrossHairId = 0x0000A944;
- DWORD EntitySize = 0x00000010;
- struct Module
- {
- DWORD dwBase;
- DWORD dwSize;
- };
- class Debugger
- {
- private:
- HANDLE __process;
- DWORD __pId;
- public:
- bool Attach(char* ProcessName)
- {
- HANDLE PHANDLE = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
- PROCESSENTRY32 CSENTRY;
- CSENTRY.dwFlags = sizeof(CSENTRY);
- do {
- if (!strcmp(CSENTRY.szExeFile, ProcessName)) {
- __pId = CSENTRY.th32ProcessID;
- CloseHandle(PHANDLE);
- __process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, __pId);
- return true;
- }
- } while (Process32Next(PHANDLE, &CSENTRY));
- return false;
- }
- Module GetModule(char* ModuleName)
- {
- HANDLE module = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, __pId);
- MODULEENTRY32 ModEntry;
- ModEntry.dwSize = sizeof(ModEntry);
- do {
- if (!strcmp(ModEntry.szModule, (char*)ModuleName)) {
- CloseHandle(module);
- return { (DWORD)ModEntry.hModule, ModEntry.modBaseSize };
- }
- } while (Module32Next(module, &ModEntry));
- return{ (DWORD)NULL, (DWORD)NULL };
- }
- template <typename T> T read(DWORD Addr)
- {
- T __read;
- ReadProcessMemory(__process, (void*)Addr, &__read, sizeof(T), NULL);
- return __read;
- }
- };
- Debugger debugger;
- DWORD dwClient, dwEngine;
- class Entity
- {
- public:
- static DWORD GetBaseEntity(int PlayerNumber)
- {
- return debugger.read<DWORD>(dwClient + EntityList + (EntitySize * PlayerNumber));
- }
- static bool PlayerIsDead(int PlayerNumber)
- {
- DWORD BaseEntity = GetBaseEntity(PlayerNumber);
- if (BaseEntity) {
- return debugger.read<bool>(BaseEntity + LifeState);
- }
- }
- static int GetTeam(int PlayerNumber)
- {
- DWORD BaseEntity = GetBaseEntity(PlayerNumber);
- if (BaseEntity) {
- return debugger.read<int>(BaseEntity + Team);
- }
- }
- };
- class Game
- {
- public:
- static void GetPlayerBase(DWORD* retAddr)
- {
- (DWORD)*retAddr = debugger.read<DWORD>(dwClient + LocalPlayer);
- }
- static int GetTeam()
- {
- DWORD PlayerBase;
- GetPlayerBase(&PlayerBase);
- if (PlayerBase)
- return debugger.read<int>(PlayerBase + Team);
- }
- static void GetCrosshairId(int* retAddr)
- {
- DWORD PlayerBase;
- GetPlayerBase(&PlayerBase);
- (int)*retAddr = debugger.read<int>(PlayerBase + CrossHairId) - 1;
- }
- };
- void Click()
- {
- mouse_event(MOUSEEVENTF_LEFTDOWN, 0 , 0, 0, 0);
- Sleep(1);
- mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
- }
- DWORD WINAPI TriggerThread(LPVOID PARAMS)
- {
- while (1)
- {
- Sleep(1);
- if (GetAsyncKeyState(TRIGGER_KEY) < 0 && TRIGGER_KEY != 1)
- {
- int PlayerNumber = NULL;
- Game::GetCrosshairId(&PlayerNumber);
- if (PlayerNumber < 64 && PlayerNumber >= 0 && Entity::GetTeam(PlayerNumber) != Game::GetTeam() && Entity::PlayerIsDead(PlayerNumber) == false)
- {
- Click();
- }
- }
- }
- return 0;
- }
- int main()
- {
- Module Client, Engine;
- while (!debugger.Attach("csgo.exe")) {
- std::cout << ".";
- Sleep(500);
- }
- Client = debugger.GetModule("Client.dll");
- dwClient = Client.dwBase;
- Engine = debugger.GetModule("Engine.dll");
- dwEngine = Engine.dwBase;
- CreateThread(0, 0, &TriggerThread, 0, 0, 0);
- std::cout << "Trigger thread is running...";
- while (1)
- {
- if (GetAsyncKeyState(VK_F4)) {
- exit(0);
- }
- }
- }
- /* SRC: https://pastebin.com/xqhddab6 */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement