Getting triggerbot to work

Posts 1–10 of 10 · Page 1 of 1
Getting triggerbot to work
I am new with C++, done some scripting with AutoIt, but that is it. On YouTube, I saw a source code for a triggerbot, and tried to compile it with updated offsets (pretty sure they are right), but the trigger doesn't seem to work. Closest I came to was randomly shooting with the designated button. Two days of debugging, you're my last hope.

Code:
#include <Windows.h>
#include <TlHelp32.h>
#include <string>
#include <iostream>

#define TRIGGER_KEY 0x05
#define var template<typename T> T

DWORD EntityList = 0x4A99224;
DWORD LocalPlayer = 0xA7E4CC;
DWORD LifeState = 0x25B;
DWORD Team = 0xF0;
DWORD CrossHairId = 0xA958;
DWORD EntitySize = 0x10;

//new "datatype"
struct Module
{
	DWORD dwBase;
	DWORD dwSize;
};

//debugger class
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; //sets process' id
				CloseHandle(PHANDLE); //closes the opent handle
				__process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, __pId); //opens process for read/write
				return true; // operation was successful
			}
		} while (Process32Next(PHANDLE, &CSENTRY));
		return false; // operation failed (process was not found)
	}

	Module GetModule(char* ModuleName)
	{
		//same as in attach function, except for a dll in memory...
		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() //retrieves current team (ct/t)
	{
		DWORD PlayerBase;
		GetPlayerBase(&PlayerBase);
		if (PlayerBase)
			return debugger.read<int>(PlayerBase + Team);
	}
	static void GetCrosshairId(int* retAddr)
	{
		DWORD PlayerBase;
		GetPlayerBase(&PlayerBase);
		if (PlayerBase)
			(int)*retAddr = debugger.read<int>(PlayerBase + CrossHairId) - 1;
	}
};

void Click()
{
	mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
	Sleep(10);
	mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
	std::cout << "Pam";
}

DWORD WINAPI TriggerThread(LPVOID PARAMS)
{
	while (1)
	{
		Sleep(1);
		if (GetAsyncKeyState(TRIGGER_KEY) < 0 && TRIGGER_KEY != 1)  //if the V key is down....
		{
			int PlayerNumber = NULL;
			Game::GetCrosshairId(&PlayerNumber); //get the current player number
			if (PlayerNumber < 64 && PlayerNumber >= 0 && Entity::GetTeam(PlayerNumber) != Game::GetTeam() && Entity::PlayerIsDead(PlayerNumber) == false)
			{
				Click(); //click
			}
		}
	}
	return 0;
}

int main()
{
	Module Client, Engine;
	//try to attach to csgo
	while (!debugger.Attach("csgo.exe")) {
		std::cout << ".";
		Sleep(500);
	}
	//client.dll & engine.dll are the 2 modules where our data about players exist.
	Client = debugger.GetModule("client.dll"); //get executable module client.dll
	dwClient = Client.dwBase;
	Engine = debugger.GetModule("engine.dll"); //get executable module engine.dll
	dwEngine = Engine.dwBase;
	CreateThread(0, 0, &TriggerThread, 0, 0, 0); //create a thread for the trigger loop
	std::cout << "Trigger thread is running...";

	while (1)
	{
		if (GetAsyncKeyState(VK_F4)) {
			exit(0);
		}
	}

}
The offset is not 0xA958, its 0xA954.
The offset from Y3t1y3t's dumper has been wrong for atleast a month now.
RIP, off by 4 bytes :\/
Well, I got so far even with a wrong offset, now that I changed, it shoots randomly, again. So RIP, even with the correct offset.
Im not quite sure but you could try chaning
Code:
static DWORD GetBaseEntity(int PlayerNumber)
	{
		return debugger.read<DWORD>(dwClient + EntityList + (EntitySize * PlayerNumber));
	}
to

Code:
static DWORD GetBaseEntity(int PlayerNumber)
	{
		return debugger.read<DWORD>(dwClient + EntityList + (PlayerNumber - 1) * EntitySize);    //EntitySize = 16
	}
you should also try displaying your actual crosshairID to make sure its right
Quote Originally Posted by derkrasseboy View Post
Im not quite sure but you could try chaning
Code:
static DWORD GetBaseEntity(int PlayerNumber)
	{
		return debugger.read<DWORD>(dwClient + EntityList + (EntitySize * PlayerNumber));
	}
to

Code:
static DWORD GetBaseEntity(int PlayerNumber)
	{
		return debugger.read<DWORD>(dwClient + EntityList + (PlayerNumber - 1) * EntitySize);    //EntitySize = 16
	}
you should also try displaying your actual crosshairID to make sure its right
Nope, he's already subtracting the "world" entity in the GetCrosshairID function.
Deleting this line: "&& Entity::GetTeam(PlayerNumber) != Game::GetTeam()" or changing "!=" to "==" makes it shoot without any checks, if that's to any help.

- - - Updated - - -

Wrong EntityList offset, fixed.
You are using a completely wrong EntityList offset.

0x4A99224 is not the right offset.

Either use 0x4A9B464 or 0x4A9B454.

0x4A9B464 is the offset to access the very first player, 0x4A9B454 is the actual offset to the EntityList.

If you use 0x4A9B464 you'd have to subtract 1 from your CrosshairID, which you already do, if you use 0x4A9B454 you wouldn't have to do that.

In your case, use 0x4A9B464 to fix your problem. I didn't really look over your code, though it should fix your problem, if not, i'll take another look.
Fuck my life, I was using the same dumper and wasted like 2 hours trying to fix it
/Solved & closed.
Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us