Source Code Multihack source

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Liduen

Hacker
Dank Tier VIP
May 19, 2013
702
8,478
33
Hi guys,

just finished my multihack- what do you think?
What should I do better next time, how can I improve the code?
Please let me know. This is an external multihack.


And for those who haven't done a hack before, you're welcome. Feel free to use the code.
(You still have to get the addresses for your own game by yourself)


Known issues:
- Aimbot will flicker a lot, because it checks if you can hit a player (if he is visible) by switching through all enemys really fast and reading the crosshair value.
- I found no way to check if a player is still alive or not, so it checks this fact by comparing the position from the run before and the run now
(aimbot won't aim on campers, which is the reason why I binded the aimbot on c, to switch it off fast and to kill them too :D ).


Source code:
C++:
// INCLUDES
#include <iostream>
#include <windows.h>
#include <sstream>
#include <conio.h>
#include <cmath>
#include <math.h>
#include <ctime> 


using namespace::std;


// METHODS
void CheckProcess();
void GetAllPointers();
void CheckKeys();
void Graphics();
void WriteToMemory();
void AimbotFunc();
void LeftClick();
DWORD FindFinalAddy(int PointerLevel, DWORD Offsets[], DWORD BaseAddress);	// Thanks to Fleep for this wonderful function!


// VARIABLES
DWORD dwProcId;					    // Process ID
HWND window;					    // Window
HANDLE hProcess;					// Handle to process
string sWindowTitle = "mygame";		// same as GameName
LPCSTR GameName = "mygame";
const float pi = 3.14159265;
bool GameAvailable = false;
bool InitialPointers = true;
bool SthChanged = true;
bool Wallhack = false;
bool Health = false;
bool Stamina = false;
bool NoRecoil = false;
bool NoSpread = false;
bool Triggerbot = false;
bool Aimbot = false;
int adressen[32][4];		//[Player][x, y, z, Team]
float positions[32][3][2];	//[Player][x, y, z][before, after]
bool ismoving[32];			//[Player] -> Is Moving?
int team[32];				//[Player] -> Which Team?
float a, b, c;
float angleX, angleY;
float xPlayerView, yPlayerView;
float xPlayerViewWriteable, yPlayerViewWriteable;
int target = 0, oldtarget;
int playerNumber, playerHealth;
int nTriggerbot;
int nAimspot = 15; // 2 = Head, 15 = Torso, 25 = Groin
string sAimspot = "Torso";
int nPlayerCrouched, nPlayerCrouchedCompensation = 20;


// TEMPS
int nTemp[36];
float fTemp[100];




int main()
{
	// As long as the end-key wasn't pressed
	while(!GetAsyncKeyState(VK_END) &1)
	{
		// Don't waste CPU power (18 or 50 ms pause between each run)
		Sleep(18);
		// Is the game available?
		CheckProcess();
		if(GameAvailable)
		{
			// First get all the pointers
			if(InitialPointers) GetAllPointers();
			// Check if an important key was pressed (aka shortcut)
			CheckKeys();
			// Update the menu if necessary
			if(SthChanged) Graphics();
			// Execute all the memory stuff (read + write)
			WriteToMemory();
		}
	}
	CloseHandle(hProcess);
	return 0;
}




void CheckProcess()
{
	// Find the game window.
    if ((window = FindWindow(0, GameName)) == NULL) cout << "Cannot find "  + sWindowTitle + " window!\n";
	// Get the Process ID for use in OpenProcess
    if (!GetWindowThreadProcessId(window, &dwProcId)) cout << "Cannot retrieve process Id!\n";
    // Get a process handle to the game
	if ((hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcId)) == NULL)
	{
		cout << "Cannot open process!\n\n\n";
		GameAvailable = false;
		_getch();
	}
	else GameAvailable = true;
}


void CheckKeys()
{
	if(GetAsyncKeyState(VK_NUMPAD0) &1)
	{
		Wallhack = !Wallhack;
		SthChanged = true;
	}
	if(GetAsyncKeyState(VK_NUMPAD1) &1)
	{
		Health = !Health;
		SthChanged = true;
	}
	if(GetAsyncKeyState(VK_NUMPAD2) &1)
	{
		Stamina = !Stamina;
		SthChanged = true;
	}
	if(GetAsyncKeyState(VK_NUMPAD3) &1)
	{
		NoRecoil = !NoRecoil;
		SthChanged = true;
	}
	/*if(GetAsyncKeyState(VK_NUMPAD4) &1) // Still have to find the right address...
	{
		NoSpread = !NoSpread;
		SthChanged = true;
	}*/
	if(GetAsyncKeyState(VK_NUMPAD5) &1)
	{
		Triggerbot = !Triggerbot;
		if(Aimbot) Triggerbot = true;
		SthChanged = true;
	}
	// Binded on c for faster switching but normally it's binded on VK_NUMPAD6
	if(GetAsyncKeyState(0x43) &1)
	{
		Aimbot = !Aimbot;
		if(Aimbot) Triggerbot = true;
		else Triggerbot = false;
		SthChanged = true;
	}
	if(GetAsyncKeyState(VK_NUMPAD7) &1)
	{
		if(nAimspot == 2)
		{
			nAimspot = 15;
			sAimspot = "Torso";
		}
		else if(nAimspot == 15)
		{
			nAimspot = 25;
			sAimspot = "Groin";
		}
		else if(nAimspot == 25)
		{
			nAimspot = 2;
			sAimspot = "Head";
		}
		SthChanged = true;
	}
}


void Graphics()
{
	// Just the main menu, nothing special here...
	cout << "_______________				        Multihack by Liduen\n"
		<< "Hack Status:\n\n"
		<< "(0) Wallhack:		"		<< Wallhack			<< "\n"
		<< "(1) Unlimited Health:	"	<< Health			    << "\n"
		<< "(2) Unlimited Stamina:	"<< Stamina			<< "\n"
		<< "(3) NoRecoil:		"		<< NoRecoil			<< "\n"
		<< "(4) NoSpread:		"		<< NoSpread			<< "\n"
		<< "(5) Triggerbot:		"	<< Triggerbot		    << "\n"
		<< "(6) Aimbot:		"		<< Aimbot			    << "\n"
		<< "(7) - Aimspot:		"	<< sAimspot			<< "\n"
		<< "\n\n\n\n\n\n\n\n\n\n\n\n\n";
}

void GetAllPointers()
{
	afWall		  = FindFinalAddy(1, oWall, abWall);
	afHealth	  = FindFinalAddy(1, oHealth, GameBase);
	afStamina	  = FindFinalAddy(1, oStamina, GameBase);
	afRecoil	  = FindFinalAddy(1, oRecoil, GameBase);
	afTriggerbot  = FindFinalAddy(1, oTriggerbot, GameBase);
	afXPlayerView = FindFinalAddy(1, oXPlayerView, GameBase);
	afYPlayerView = FindFinalAddy(1, oYPlayerView, GameBase);
	afTeam		  = FindFinalAddy(1, oTeam, GameBase);

	for (int i = 0; i <= 31; i++)
	{
		adressen[i][0] = afPositionX + (gapPosition * i);
		adressen[i][1] = afPositionZ + (gapPosition * i);
		adressen[i][2] = afPositionY + (gapPosition * i);
		adressen[i][3] = afTeam + (gapTeam * i);
	}

	// Only do this once
	InitialPointers = false;
}


DWORD FindFinalAddy(int PointerLevel, DWORD Offsets[], DWORD BaseAddress)
{
	// Thanks to Fleep!
	DWORD pTemp, pointerAddr;
	for(int i = 0; i < PointerLevel; i ++)
	{
			if(i == 0) ReadProcessMemory(hProcess, (LPCVOID)BaseAddress, &pTemp, 4, NULL);
			pointerAddr = pTemp + Offsets[i];												//add first offset to that address
			ReadProcessMemory(hProcess, (LPCVOID)pointerAddr, &pTemp, 4, NULL);				//Read memory one more time and exit the loop
	}
	return pointerAddr;
}


void WriteToMemory()
{
	// Get all the information from each player
	for (int i = 0; i <= 31; i++)
	{
		// Old positions
		positions[i][0][2] = positions[i][0][1];
		positions[i][1][2] = positions[i][1][1];
		positions[i][2][2] = positions[i][2][1];

		// New positions
		ReadProcessMemory(hProcess, (LPCVOID)adressen[i][0], &fTemp[i], sizeof(float), NULL);
		positions[i][0][1] = fTemp[i];
		ReadProcessMemory(hProcess, (LPCVOID)adressen[i][1], &fTemp[i+1], sizeof(float), NULL);
		positions[i][1][1] = fTemp[i+1];
		ReadProcessMemory(hProcess, (LPCVOID)adressen[i][2], &fTemp[i+2], sizeof(float), NULL);
		positions[i][2][1] = fTemp[i+2];

		// Which player is moving? (not dead)
		ismoving[i] = (positions[i][0][1] != positions[i][0][2] || positions[i][1][1] != positions[i][1][2] || positions[i][2][1] != positions[i][2][2]); 

		// Which player is in which team?
		ReadProcessMemory(hProcess, (LPCVOID)adressen[i][3], &nTemp[i], 4, NULL);
		team[i] = nTemp[i];   
	}

	// Own slotnumber
	ReadProcessMemory(hProcess, (LPCVOID)afPlayerNumber, &nTemp[33], 4, NULL);
	playerNumber = nTemp[33];

	// Own health
	ReadProcessMemory(hProcess, (LPCVOID)afPlayerHealth, &nTemp[34], 4, NULL);
	playerHealth = nTemp[34];

	// Reading crosshairvalue
	ReadProcessMemory(hProcess, (LPCVOID)afTriggerbot, &nTemp[35], 4, NULL);
	nTriggerbot = nTemp[35];

	// Are you crouched?
	ReadProcessMemory(hProcess, (LPCVOID)afPlayerCrouched, &nTemp[36], 4, NULL);
	nPlayerCrouched = nTemp[36];


	// Player view angles and those we can write
	ReadProcessMemory(hProcess, (LPCVOID)afXPlayerView, &fTemp[97], sizeof(float), NULL);
	xPlayerView = fTemp[97];
	ReadProcessMemory(hProcess, (LPCVOID)afYPlayerView, &fTemp[98], sizeof(float), NULL);
	yPlayerView = fTemp[98];
	ReadProcessMemory(hProcess, (LPCVOID)afXPlayerViewWriteable, &fTemp[99], sizeof(float), NULL);
	xPlayerViewWriteable = fTemp[99];
	ReadProcessMemory(hProcess, (LPCVOID)afYPlayerViewWriteable, &fTemp[100], sizeof(float), NULL);
	yPlayerViewWriteable = fTemp[100];

	// Write this to memory only once
	if(SthChanged)
	{
		if(Wallhack) vWall = 1;
		else vWall = 0;
		WriteProcessMemory( hProcess, (BYTE*)afWall, &vWall, sizeof(vWall), NULL);

		SthChanged = false;
	}

	if(Health) WriteProcessMemory( hProcess, (BYTE*)afHealth, &vHealth, sizeof(vHealth), NULL);
	if(Stamina) WriteProcessMemory( hProcess, (BYTE*)afStamina, &vStamina, sizeof(vStamina), NULL);
	if(NoRecoil) WriteProcessMemory( hProcess, (BYTE*)afRecoil, &vRecoil, sizeof(vRecoil), NULL);
	if(Triggerbot
		&& (nTriggerbot > -1 && nTriggerbot < 32)									// Valid playernumber?
		&& (team[nTriggerbot] != team[playerNumber]	|| team[playerNumber] == 0)		// Not in our team or free-for-all mode?
		&& (playerHealth > 0 && playerHealth < 101)								// Am I alive?
		&& (team[playerNumber] < 3 && team[playerNumber] > -1))					// Am I ingame or just spectator?
		LeftClick();															// Do the leftclick!
	if(Aimbot
		&& (playerHealth > 0 && playerHealth < 101)								// Am I alive?
		&& (team[playerNumber] < 3 && team[playerNumber] > -1))					// Am I ingame or just spectator? 
		AimbotFunc();															// Do the aimbotfunction!
}


void AimbotFunc()
{
	// Switching target, if the enemy is behind a wall
	if (nTriggerbot < 0 || nTriggerbot > 31)
    {
		// Remember which one was the old target
		oldtarget = target;
		for(int i = 0; i < 32; i++)
		{
			// Switch our target
			target++;
			// If the old target is dead and there is no other, the aimbot won't be executed
			if (target == oldtarget && !ismoving[target]) return;
			// If we went once through the list, start at the beginning
			if (target == 32) target = 0;
			// We just found our next target
			if (ismoving[target]												// Is the target moving (alive)?
				&& (team[target] != team[playerNumber] || team[target] == 0)	// Is the target in our team or is the mode free-for-all?
				&& target != playerNumber)										// We won't aim at ourself
				break;															// Do the aimbotfunction!
			// The aimbot won't be executed if we didn't find a valid target
			if (i == 31) return;
		}
    }

	// Aimbot execution
	a = positions[playerNumber][0][1] - positions[target][0][1];
    b = positions[playerNumber][1][1] - positions[target][1][1];
    angleX = atan(b / a) / pi * 180.0;
    if (a > 0) angleX = xPlayerViewWriteable - (xPlayerView - (angleX - 180));
	else angleX = xPlayerViewWriteable - (xPlayerView - angleX);
	// Write our new x-angle
	WriteProcessMemory(hProcess, (LPVOID) afXPlayerViewWriteable, &angleX, sizeof(float), NULL);

    c = sqrt(a*a + b*b);
    a = (positions[playerNumber][2][1] - (nPlayerCrouchedCompensation * nPlayerCrouched)) - (positions[target][2][1] - nAimspot);
    angleY = atan(a / c) / pi * 180.0;
	angleY = yPlayerViewWriteable - (yPlayerView - angleY);
	// Write our new y-angle
	WriteProcessMemory(hProcess, (LPVOID) afYPlayerViewWriteable, &angleY, sizeof(float), NULL);

	// Enemy just got owned :D
}


void LeftClick()
{  
	// Thanks to some guy from a forum on the internet who's name I've unfortunately forgotten long time ago :/
    INPUT input = {0};

    // left down 
    input.type      = INPUT_MOUSE;
    input.mi.dwFlags  = MOUSEEVENTF_LEFTDOWN;
    ::SendInput(1,&input,sizeof(INPUT));

    // left up
    ::ZeroMemory(&input,sizeof(INPUT));
    input.type      = INPUT_MOUSE;

    input.mi.dwFlags  = MOUSEEVENTF_LEFTUP;
    ::SendInput(1,&input,sizeof(INPUT));
}
Aaaaaand the outcome :D
Not perfect (recoil and spread is serversided) but useful.

https://www.youtube.com/watch?v=D_lx2qpvYIk

Have fun ;)
Liduen
 
Last edited:

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
19,938
76
Avoid global variables where you can, nicely structured code otherwise.

PS, I'd add a little sleep between mouse down and up, to be sure it gets registered, if you are hooking rendering functions next time, your sendinputs won't be noticed by the game.
 

Liduen

Hacker
Dank Tier VIP
May 19, 2013
702
8,478
33
Avoid global variables where you can, nicely structured code otherwise.

PS, I'd add a little sleep between mouse down and up, to be sure it gets registered, if you are hooking rendering functions next time, your sendinputs won't be noticed by the game.
I used them to not have to use so much parameters in the functions, as you can see most of them are void.
But I never thought about it in detail.
What are the advantages of not using global variables? Just keen to know :)

I noticed that when I set the sleep() function under 18 milliseconds, the baretta didn't shoot as fast as the M4 anymore. In fact it then shot very inconstantly.

Thanks for your feedback!
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods