• 🌙 Community Spirit

    Ramadan Mubarak! To honor this month, Crax has paused NSFW categories. Wishing you peace and growth!

[Tutorial] Basic Aimbot for csgo (1 Viewer)

Currently reading:
 [Tutorial] Basic Aimbot for csgo (1 Viewer)

Recently searched:

sirko

Member
LV
0
Joined
Apr 8, 2023
Threads
10
Likes
0
Awards
2
Credits
1,006©
Cash
0$
I've created an aimbot using what I've learned, and it took a long time to develop. I hope that by sharing this code, I can help other beginners understand the structure of how an aimbot works and what is required. Most tutorials I've seen are either outdated or overly complicated, with unnecessary code. So, I've created a simplified version in a single file. If you don't know how to create a Vector class, it's easy - just make a struct or class with three floats: x, y, and z. I highly recommend experimenting with the code to understand how everything works, and suggest that you first try to reverse-engineer the aimbot before using it in other games. Also there is a bug where the aimbot aims at the world center if it cannot find the closest enemy. I was too lazy to fix it, so you can do it yourself. If I were to use it, I would fix it myself but since it's just for learning purposes, I won't. Good luck!​
Code:
#include <iostream>
#include<Windows.h>
#include<TlHelp32.h>
#include"Vector3.h"
#include<math.h>
#include<cmath>

uintptr_t pid = 0;
HANDLE hproc = 0;
uintptr_t client = 0;
uintptr_t engine = 0;


DWORD Pid(const char* ProcessName)
{
    DWORD pid = 0;
    HANDLE hsnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (hsnap == INVALID_HANDLE_VALUE)
    {
        return 0;
    }
    PROCESSENTRY32 pe32;

    if (Process32First(hsnap, &pe32))
    {
        do
        {
            if (!strcmp(pe32.szExeFile, ProcessName))
            {
                pid = pe32.th32ProcessID;


            }


        } while (Process32Next(hsnap, &pe32));

    }
    CloseHandle(hsnap);
    return pid;
}


uintptr_t MBA(const char* ModuleName, DWORD pid)
{
    uintptr_t MA = 0;
    HANDLE hsnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, pid);
    if (hsnap != INVALID_HANDLE_VALUE)
    {
        MODULEENTRY32 mode32;
        mode32.dwSize = sizeof(mode32);

        if (Module32First(hsnap, &mode32))
        {
            do
            {
                if (strcmp(mode32.szModule, ModuleName) == 0)
                {
                    MA = (uintptr_t)mode32.modBaseAddr;
                    break;

                }


            } while (Module32Next(hsnap, &mode32));

        }
    }

    CloseHandle(hsnap);
    return MA;
}
template<typename T> T rpm(SIZE_T address)
{
    T buffer;
    ReadProcessMemory(hproc, (LPVOID)address, &buffer, sizeof(T), 0);
    return buffer;
}
template<typename T> void wpm(SIZE_T AddrToWrite, T ValueToWrite)
{
    T buffer = ValueToWrite;
    WriteProcessMemory(hproc, (LPVOID)AddrToWrite, &buffer, sizeof(T), 0);

}











uintptr_t LocalPlayer(uintptr_t client)
{
    return rpm<uintptr_t>(client + 0xDEA964);
}

Vector3 Origin(uintptr_t player)
{
    return rpm<Vector3>(player + 0x138);
}

uintptr_t Player(uintptr_t client,int playerIndex)
{
    return rpm<uintptr_t>(client + 0x4DFFFC4 + (playerIndex * 0x10));
}


int health(uintptr_t player)
{
    return rpm<int>(player + 0x100);
}

uintptr_t ClientState(uintptr_t engine)
{
    return rpm<uintptr_t>(engine + 0x59F19C);
}


Vector3 ViewAngles(uintptr_t clientstate)
{
    return rpm<Vector3>(clientstate + 0x4D90);
}


Vector3 ViewOffset(uintptr_t localplayer)
{
    return rpm<Vector3>(localplayer + 0x108);
}

int MyTeam(uintptr_t localplayer)
{
    return rpm<int>(localplayer + 0xF4);
}
int Team(uintptr_t player)
{
    return rpm<int>(player + 0xF4);
}

int GetClosest(uintptr_t client,uintptr_t localplayer)
{
    int index = 1;
    float closest = 9999;
    for (int i = 1; i < 32; ++i)
    {
        uintptr_t player = Player(client, i);
        Vector3 playerpos = Origin(player);
        Vector3 mypos = Origin(localplayer);
        float distance = sqrt(pow(playerpos.x - mypos.x, 2) + pow(playerpos.y - mypos.y, 2) + pow(playerpos.z - mypos.z, 2));
        int health = rpm<int>(player + 0x100);
        
        if (distance < closest && health > 0 && health < 101)
        {
            closest = distance;
            index = i;
        }
        
            
    }
    return index;
}
double PI = 3.1415;
void AimAt(uintptr_t engine,uintptr_t client,uintptr_t localplayer,int health)
{
    uintptr_t clientstate = rpm<uintptr_t>(engine + 0x59F19C);
    uintptr_t index = GetClosest(client, localplayer);
    if (GetAsyncKeyState(VK_XBUTTON1) && health > 0)
    {
        
        
        
        uintptr_t player = Player(client, index);
        uintptr_t boneMatrix = rpm<uintptr_t>(player + 0x26A8);
        Vector3 bonepos;
        bonepos.x = rpm<float>((boneMatrix + (0x30 * 8)) + 0x0C);
        bonepos.y = rpm<float>((boneMatrix + (0x30 * 8)) + 0x1C);
        bonepos.z = rpm<float>((boneMatrix + (0x30 * 8)) + 0x2C);
        
        int myteam = MyTeam(localplayer);
        int teams = Team(player);
        Vector3 myorigin = Origin(localplayer);
        Vector3 viewoffset = ViewOffset(localplayer);
        Vector3 m_myeyes = myorigin + viewoffset;
        Vector3* myeyes = &m_myeyes;

        Vector3 deltavec = { bonepos.x - myeyes->x,bonepos.y - myeyes->y,bonepos.z -myeyes->z };

        float hypotnuse = sqrt(deltavec.x * deltavec.x + deltavec.y * deltavec.y + deltavec.z * deltavec.z);

        float pitch = -asin(deltavec.z / hypotnuse) * (180 / PI);
        float yaw = atan2(deltavec.y, deltavec.x) * (180 / PI);
        
        if (pitch > 89)
            pitch = 89;
        if (pitch < -89)
            pitch = -89;
        if (yaw > 180)
            yaw = 180;
        if (yaw < -180)
            yaw = -180;
        

        if (teams != myteam)
        {


            wpm<float>(clientstate + 0x4D90, pitch);
            wpm<float>(clientstate + 0x4D94, yaw);
        }
        

    

        
            Sleep(1);
    }
}




int main()
{
    
    pid = Pid("csgo.exe");
    client = MBA("client.dll", pid);
    engine = MBA("engine.dll", pid);
    hproc = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
    
    
    while (true)
    {
        uintptr_t localplayer = LocalPlayer(client);
        int Health = health(localplayer);
        AimAt(engine,client,localplayer,Health);
        
        Sleep(1);
    }
    
    
    

    
}
Also how can I stop the tags from automatically changing? :coolmaninthetoilet:
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Tips
Recently searched:

Users who are viewing this thread

Top Bottom