Source Code [ C ] AssaultCube External Aimbot & ESP

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

R41NY

Newbie
Full Member
Dec 25, 2017
45
363
2
How long you been coding/hacking?
On and off for 1 year
Coding Language
C
Yea, the title says it all :p.
Possible thanks to:
-titan059 and his Simple AC ESP project (i took the W2S Function, and the drawing functions from there).
-XdarionX for helping me with the EntityList loop.
-mambda for helping me with the distance check system



The ESP only works properly when playing the game in windowed mode and 1024 by 768


Features:
-Box ESP
-Aimbot
-Health ESP
-Name ESP

ESP.png

Code:
C:
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#include <gdiplus.h>
#include <math.h>
#define FLT_MAX     3.40282347E+38F
typedef struct
{
    float x, y, z, w;
} Vec4;
//2 Dimensional Vector(Screen)
typedef struct
{
    float x, y;
} Vec2;
//3 Dimensional Vector(Ingame)
typedef struct
{
    float x, y,z;
} Vec3;
typedef struct
{
    Vec3 Pos;
    Vec3 HeadPos;
    int Health,Team;
    char Name[20];
} Entities;
typedef struct
{
    Vec3 Pos;
    int Health,Team,Base;
} LocalPlayer;

DWORD LocalPlayerOffset=0x509B74;
DWORD RVSF_Team=0x32C;
DWORD Viewx=0x40;
DWORD Viewy=0x44;
DWORD EntityBaseOffset=0x50F4F8;
DWORD PlayerCountAddress=0x50F500;
DWORD xPosOffset=0x34;
DWORD yPosOffset=0x38;
DWORD zPosOffset=0x3c;
DWORD pistolMag=0x70;
DWORD RifleMag=0x128;
DWORD RifleAmmo=0x150;
DWORD GrenadeAmmount=0x158;
DWORD PlayerSpeed=0x80;
DWORD ViewMatrixAddress=0x501AE8;
DWORD Health=0xF8;
DWORD ForceAttack=0x224;

int handle;
int pid;
HDC hdcAC;
HWND hwndAC_Client;
void MemStart();
int ReadMem(LPCVOID Address,LPVOID ReadVar,int SizeDataType);
int WriteMem(LPCVOID Address,LPVOID WriteVar,int SizeDataType);
int WorldToScreen(Vec3 pos, Vec2 *screen, float matrix[16], int windowWidth, int windowHeight);
void DrawFilledRect(int x, int y, int w, int h,HBRUSH color);
void DrawBorderBox(int x, int y, int w, int h, int thickness);
void DrawHealthESP(int x, int y, int w, float h, int thickness,int Health);
void DrawString(int x, int y, COLORREF color, const char* text);
void ESP(Vec3 EnemyPosition,Vec3 enemyHeadPos,float Matrix[16],int PlayerHealth,char PlayerName[20]);
void ReadEntityInfo(int i,Entities *ent);
void ReadLocalPlayerInfo(LocalPlayer *local);
Vec2 CalcAngles(Vec3 CoordsToEnemy, float distance);
Vec2 vScreen, vHead;
HBRUSH color;
HBRUSH HealthESPColor;
COLORREF TextCOLOR;
HFONT Font;
int EntityBase;
int main()
{
    TextCOLOR = RGB(255, 255, 255);
    HealthESPColor=CreateSolidBrush(RGB(0,255,0));
    color=CreateSolidBrush(RGB(255,0,0));
    float hypo;
    float newDistance;
    int playercountread;
    //Finding the PID of the process via WindowName and getting permissions to read the addresses in this process
    MemStart();
    //if we cant get permissions
    while(handle==0)
    {
        printf("Start AssaultCube!\n");
        getchar();
        printf("Retrying...\n");
        MemStart();
    }
    Vec2 angle;
    while(1)
    {
        printf("\rThank you for using Rainy's Shitty Assault Cube Hack | https://github.com/RainyPT/ACHack");
        hypo=FLT_MAX;
        newDistance=0;
        ReadMem(PlayerCountAddress,&playercountread,sizeof(int));
        Entities entity[playercountread];
        LocalPlayer local;
        for(int i=4; i<(playercountread*4); i+=4)
        {
            ReadLocalPlayerInfo(&local);
            ReadEntityInfo(i,&entity[i/4]);
            int newammo=1337;
            WriteMem(local.Base+RifleAmmo,&newammo,sizeof(int));
            float viewMatrix[16];
            ReadMem(ViewMatrixAddress, &viewMatrix, sizeof(viewMatrix));
            if(local.Team!=entity[i/4].Team)
            {
                if(entity[i/4].Health>0)
                {
                    ESP(entity[i/4].Pos,entity[i/4].HeadPos,viewMatrix,entity[i/4].Health,entity[i/4].Name);
                    Vec3 CoordsToEnemy= {entity[i/4].Pos.x-local.Pos.x,entity[i/4].Pos.y-local.Pos.y,entity[i/4].Pos.z-local.Pos.z};
                    newDistance=sqrt((CoordsToEnemy.x*CoordsToEnemy.x)+(CoordsToEnemy.y*CoordsToEnemy.y)+(CoordsToEnemy.z*CoordsToEnemy.z));
                    if (newDistance < hypo)
                    {
                        hypo = newDistance;
                        angle=CalcAngles(CoordsToEnemy,newDistance);
                    }
                }
            }
        }
        if(GetAsyncKeyState(VK_LBUTTON))
        {
            WriteMem(local.Base+Viewx,&angle,sizeof(angle));
        }
    }
    CloseHandle(handle);
    return 0;
}
void ReadLocalPlayerInfo(LocalPlayer *local)
{
    ReadMem(LocalPlayerOffset,&local->Base,sizeof(int));
    ReadMem(local->Base+RVSF_Team,&local->Team,sizeof(int));
    ReadMem(local->Base+xPosOffset,&local->Pos,sizeof(local->Pos));
}
void ReadEntityInfo(int i,Entities *ent)
{
    ReadMem(EntityBaseOffset,&EntityBase,sizeof(int));
    ReadMem(EntityBase+i,&EntityBase,sizeof(int));
    if(EntityBase!=0)
    {
        ReadMem(EntityBase+RVSF_Team,&ent->Team,sizeof(int));
        ReadMem(EntityBase+xPosOffset, &ent->Pos, sizeof(ent->Pos));
        ReadMem(EntityBase+Health, &ent->Health, sizeof(int));
        ReadMem(EntityBase+0x225,&ent->Name,20);
        ReadMem(EntityBase+0x4, &ent->HeadPos, sizeof(ent->HeadPos));
    }

}
Vec2 CalcAngles(Vec3 CoordsToEnemy, float distance)
{
    Vec2 angle;
    angle.x = -atan2f(CoordsToEnemy.x, CoordsToEnemy.y) / M_PI * 180.0f + 180.0f;
    angle.y = asinf((CoordsToEnemy.z) / distance) * 180.0f / M_PI;
    return angle;
}
void ESP(Vec3 EnemyPosition,Vec3 enemyHeadPos,float Matrix[16],int PlayerHealth,char PlayerName[20])
{
    if(WorldToScreen(EnemyPosition,&vScreen,Matrix,1024,768))
    {
        if(WorldToScreen(enemyHeadPos,&vHead,Matrix,1024,768))
        {
            float height=vHead.y-vScreen.y;
            float width=height / 2.4f;
            DrawBorderBox(vScreen.x - (width / 2), vScreen.y, width, height, 2);
            DrawHealthESP(vScreen.x - (width / 2), vScreen.y, width, height, 3,PlayerHealth);
            DrawString(vScreen.x, vScreen.y, TextCOLOR, PlayerName);
        }
    }
}
int WorldToScreen(Vec3 pos, Vec2 *screen, float matrix[16], int windowWidth, int windowHeight) // 3D to 2D
{
    //Matrix-vector Product, multiplying world(eye) coordinates by projection matrix = clipCoords
    Vec4 clipCoords;
    clipCoords.x = pos.x*matrix[0] + pos.y*matrix[4] + pos.z*matrix[8] + matrix[12];
    clipCoords.y = pos.x*matrix[1] + pos.y*matrix[5] + pos.z*matrix[9] + matrix[13];
    clipCoords.z = pos.x*matrix[2] + pos.y*matrix[6] + pos.z*matrix[10] + matrix[14];
    clipCoords.w = pos.x*matrix[3] + pos.y*matrix[7] + pos.z*matrix[11] + matrix[15];

    if (clipCoords.w < 0.1f)
        return 0;

    //perspective division, dividing by clip.W = Normalized Device Coordinates
    Vec3 NDC;
    NDC.x = clipCoords.x / clipCoords.w;
    NDC.y = clipCoords.y / clipCoords.w;
    NDC.z = clipCoords.z / clipCoords.w;

    //Transform to window coordinates
    screen->x=(windowWidth / 2 * NDC.x) + (NDC.x + windowWidth / 2);
    screen->y=-(windowHeight / 2 * NDC.y) + (NDC.y + windowHeight / 2);
    return 1;
}
void DrawFilledRect(int x, int y, int w, int h,HBRUSH color)
{
    RECT rect = { x, y, x + w, y + h};
    FillRect(hdcAC, &rect, color);
}

void DrawBorderBox(int x, int y, int w, int h, int thickness)
{
    DrawFilledRect(x+2, y, w-2, thickness,color);
    DrawFilledRect(x, y, thickness, h,color);
    DrawFilledRect((x + w), y, thickness, h,color);
    DrawFilledRect(x, y + h, w + thickness, thickness,color);
}
void DrawHealthESP(int x, int y, int w, float h, int thickness,int health)
{
    h=h*((float)health/100);
    DrawFilledRect(x+5, y, thickness, h,HealthESPColor);
}
void DrawString(int x, int y, COLORREF color, const char* text)
{
    SetTextAlign(hdcAC, TA_CENTER | TA_NOUPDATECP);
    SetBkColor(hdcAC, RGB(0, 0, 0));
    SetBkMode(hdcAC, TRANSPARENT);
    SetTextColor(hdcAC, color);
    SelectObject(hdcAC, Font);
    TextOutA(hdcAC, x, y, text, strlen(text));
    DeleteObject(Font);
}
void MemStart()
{
    hwndAC_Client=FindWindow(0, "AssaultCube");
    hdcAC=GetDC(hwndAC_Client);
    GetWindowThreadProcessId(hwndAC_Client,&pid);
    handle=OpenProcess(PROCESS_ALL_ACCESS,0,pid);
}
int ReadMem(LPCVOID Address,LPVOID ReadVar,int SizeDataType)
{
    return ReadProcessMemory(handle,Address,ReadVar,SizeDataType,0);
}
int WriteMem(LPCVOID Address,LPVOID WriteVar,int SizeDataType)
{
    return WriteProcessMemory(handle,Address,WriteVar,SizeDataType,0);
}
 
Last edited:

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,153
78,998
2,396
Nice work, thanks for sharing with us, it's cool to watch people progress and see what they come up with
 
  • Like
Reactions: Ramen172 and R41NY

Ramen172

Full Member
Jul 28, 2018
10
173
1
Great work I love to took at other peoples approach and like you I'm trying to make an aimbot.

But i couldn't help but notice
C:
if(entity[i/4].Health>0)
Why not just check the entity state?
Entity + 338

if it is equal to 1 their dead

Here is a code snip from my internal:
C:
void ESP::draw(GL::Font& font)
{
    glGetIntegerv(GL_VIEWPORT, viewport);
    entList* entityList = *(entList**)0x50F4F8;

    if (entityList)
    {
        for (int i = 0; i < (*numOfPlayers); i++)
        {
           //                                                              \/ This is the state check
            if (isValidEnt(entityList->ents[i]) && entityList->ents[i]->state != 1)
            {
                ent* ent = entityList->ents[i];
                vec3 center = ent->headPos;
                center.z = center.z - EYE_HEIGHT + PLAYER_HEIGHT / 2;

                vec3 screenCoords;

                if (WorldToScreen(center, screenCoords, matrix, viewport[2], viewport[3]))
                {
                    drawESPBox(ent, screenCoords, font);
                }
            }
        }
    }
}
 
  • Like
Reactions: R41NY

R41NY

Newbie
Full Member
Dec 25, 2017
45
363
2
Great work I love to took at other peoples approach and like you I'm trying to make an aimbot.

But i couldn't help but notice
C:
if(entity[i/4].Health>0)
Why not just check the entity state?
Entity + 338

if it is equal to 1 their dead

Here is a code snip from my internal:
C:
void ESP::draw(GL::Font& font)
{
    glGetIntegerv(GL_VIEWPORT, viewport);
    entList* entityList = *(entList**)0x50F4F8;

    if (entityList)
    {
        for (int i = 0; i < (*numOfPlayers); i++)
        {
           //                                                              \/ This is the state check
            if (isValidEnt(entityList->ents[i]) && entityList->ents[i]->state != 1)
            {
                ent* ent = entityList->ents[i];
                vec3 center = ent->headPos;
                center.z = center.z - EYE_HEIGHT + PLAYER_HEIGHT / 2;

                vec3 screenCoords;

                if (WorldToScreen(center, screenCoords, matrix, viewport[2], viewport[3]))
                {
                    drawESPBox(ent, screenCoords, font);
                }
            }
        }
    }
}
im going to be honest, i didnt even notice that when i reversed the game xD !Thank you, i will implement this into my cheat :D
 
  • Like
Reactions: Ramen172

Ramen172

Full Member
Jul 28, 2018
10
173
1
im going to be honest, i didnt even notice that when i reversed the game xD !Thank you, i will implement this into my cheat :D
I didnt notice it untill watching the GH Fly hack tutorial and made some observations
 
  • Like
Reactions: R41NY

MasterfloorT

Speediest boi?¿?
Dank Tier Donator
Jul 25, 2018
2
254
0
Is there a check for IsVisible here, or does the Aimbot attempt to lock on through walls?
 

XdarionX

Dying Light Hacker
Dank Tier VIP
Dank Tier Donator
Mar 30, 2018
847
23,408
114
Is there a check for IsVisible here, or does the Aimbot attempt to lock on through walls?
yes there is, its called traceline
C++:
void TraceLine(vec from, vec to, CEntity* pTracer, bool CheckPlayers, traceresult_s* tr, bool SkipTags) {

    DWORD traceLine = 0x48A310;

    __asm
    {
        push SkipTags
        push CheckPlayers
        push pTracer
        push to.z
        push to.y
        push to.x
        push from.z
        push from.y
        push from.x
        mov eax,tr
        call traceLine
        add esp,0x24
    }
}

class CRageBot {
public:
    static void DoRageBot(bool);

    static bool CanHit(vec point) {

        auto local = CGame::GetInstance()->local;
        traceresult_s tr;

        TraceLine(local->GetHeadPosition(), point, local, false, &tr, false);

        return !tr.collided;
    }
}
 
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