Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Commit

Permalink
Update - Aimbot
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomicBool committed Jul 9, 2024
1 parent b5faa17 commit 010a9c9
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 51 deletions.
119 changes: 100 additions & 19 deletions cs_dma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ typedef struct local_player{
};

typedef struct player{

std::vector<BonePos> bones;
};

Expand All @@ -36,27 +35,30 @@ ws::pointer web_socket;
std::string map_name;
json m_data{};

//aimbot
BonePos selected_bone;

/*
Cheat Settings
*/
//web-radar
bool radar = true;
bool radar = false;

//rcs
bool rcs = true;

//aimbot
bool aimbot = false;
Vector ray_end_pos; //test
bool aimbot = true;
uint32_t aim_key = VK_XBUTTON2;
uint32_t secondary_key = VK_XBUTTON1;
float aim_range = 70.0f;

void RCS(){
Vector2D prev_punchAngles = Vector2D{ 0 , 0 };

while(game_base && rcs){
std::this_thread::sleep_for(std::chrono::milliseconds(1));

PlayerPawn LocalPawn = getLocalPawn();

Vector2D viewAngles = local.viewAngles;
Vector2D punchAngles = local.punchAngles;

Expand All @@ -73,9 +75,6 @@ void RCS(){
}else{
prev_punchAngles.x = prev_punchAngles.y = 0.f;
}

//printf("rcs running\n");

}
}

Expand Down Expand Up @@ -143,7 +142,10 @@ void UpdatePlayers(){
for(int i = 0; i < 64; i++){
PlayerController PlayerController = getController(EntityListEntry, i);
PlayerPawn PlayerPawn = PlayerController.getPawn(EntityListEntry);

std::string player_name = PlayerController.getName();
bool is_dead = (PlayerPawn.getHealth() <= 0);

if(radar && !player_name.empty()){ //stupid way but works
json m_player_data{};
m_player_data["m_idx"] = i;
Expand All @@ -155,7 +157,7 @@ void UpdatePlayers(){
m_player_data["m_position"]["x"] = PlayerPawn.getPos().x;
m_player_data["m_position"]["y"] = PlayerPawn.getPos().y;
m_player_data["m_eye_angle"] = PlayerPawn.getViewAngles().y;
m_player_data["m_is_dead"] = (PlayerPawn.getHealth() <= 0);
m_player_data["m_is_dead"] = is_dead;
m_player_data["m_model_name"] = PlayerPawn.getModelName();
m_player_data["m_steam_id"] = PlayerController.getSteamID();
m_player_data["m_money"] = PlayerController.getCash();
Expand All @@ -177,23 +179,102 @@ void UpdatePlayers(){
m_data["m_players"].push_back(m_player_data);
}

if(PlayerPawn.ptr == LocalPawn.ptr){
//nothing
}
}
if (duration >= std::chrono::milliseconds(5) && radar)
{
//websocket
if (duration >= std::chrono::milliseconds(50) && radar)
{
start = now;
web_socket->send(m_data.dump());
}
if(radar) web_socket->poll();
//printf("%s\n\n\n\n", m_data.dump().c_str());
//printf("radar: %s\n", m_data.dump().c_str());
}
}

typedef struct aimPosList{
PlayerPawn pawn;
float dist;
int x = 0;
int y = 0;
}aimPosList;

void Aimbot(){
uint64_t last_target;

while(game_base && aimbot){
std::this_thread::sleep_for(std::chrono::milliseconds(1));
PlayerPawn LocalPawn = getLocalPawn();
Vector local_pos = LocalPawn.getPos();

uint64_t EntityListEntry = mem.Read<uint64_t>(mem.Read<uint64_t>(client_base + OFFSET_ENTITY_LIST) + 0x10);

std::vector<aimPosList> list;

for(int i = 0; i < 64; i++){
PlayerController PlayerController = getController(EntityListEntry, i);
PlayerPawn PlayerPawn = PlayerController.getPawn(EntityListEntry);

std::string player_name = PlayerController.getName();
bool is_dead = (PlayerPawn.getHealth() <= 0);

//aimbot
if(keyboard.IsKeyDown(aim_key)){
BonePos preferred_bone;
float arrange_distence = FLT_MAX; //arrange
if(player_name.empty()) continue;
players[i].bones = PlayerPawn.getBones();
//player not in screen
if(!players[i].bones[head].in_screen && !players[i].bones[leg_lower_L].in_screen && !players[i].bones[leg_lower_R].in_screen){
continue;
}else if(PlayerPawn.ptr == LocalPawn.ptr){
continue;
}else if (!is_dead)
{
bool has_target = false;
//select the cloest bone
for(BonePos bone: players[i].bones){
if(bone.in_screen){
float screen_dist = bone.ScreenPos.DistTo(Vector2D{960, 540});
if(screen_dist < arrange_distence && screen_dist <= aim_range && map.is_visible(local.CameraPos, bone.Pos)){
//if the dist is cloest and bone is visible
arrange_distence = screen_dist;
preferred_bone = bone;
has_target = true;
}
}
}
float screen_dist = players[i].bones[head].ScreenPos.DistTo(Vector2D{960, 540});

if(keyboard.IsKeyDown(secondary_key) && screen_dist <= aim_range && map.is_visible(local.CameraPos, players[i].bones[head].Pos)){
preferred_bone = players[i].bones[head];
}
selected_bone = preferred_bone;
Vector2D aimPos_screen = selected_bone.ScreenPos;
if(abs(aimPos_screen.x - 960) < 2 && abs(aimPos_screen.y - 960) < 2) continue;
aimPos_screen.x -= 960;
aimPos_screen.y -= 540;

if(has_target) list.push_back({PlayerPawn, PlayerPawn.getPos().DistTo(local_pos), (int)aimPos_screen.x, (int)aimPos_screen.y});

has_target = false;
}
}
}
//qmp.SmoothMove((int)aimPos_screen.x, (int)aimPos_screen.y);

aimPosList aimPos;
float minimum_dist = FLT_MAX;
for(auto pos: list){
aimPos = (minimum_dist > pos.dist) ? pos : aimPos;
if(pos.pawn.ptr == last_target){
aimPos = pos;
break;
}
}

if(abs(aimPos.dist) > 1){
qmp.SmoothMove(aimPos.x, aimPos.y);
last_target = aimPos.pawn.ptr;
}
}
}

Expand All @@ -204,7 +285,7 @@ int main(int argc, char *argv[]){
}std::cout << "[+] Memory API initialized!" << std::endl;

if(argc > 1){
std::cout << "[+] Loading meshes data from file" << argv[1] << ".tri" << std::endl;
std::cout << "[+] Loading meshes from file " << argv[1] << ".tri" << std::endl;
map.load_map(argv[1]);
}
else printf("[-] Please input map name\n");
Expand All @@ -231,7 +312,7 @@ int main(int argc, char *argv[]){
}
}

web_socket = ws::from_url("ws://127.0.0.1:22006/cs2_webradar");
web_socket = ws::from_url("ws://127.0.0.1:8081/cs2_webradar");
if (!web_socket)
{
std::cout << "[-] Failed to initialize WebSocket!" << std::endl;
Expand Down
19 changes: 12 additions & 7 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Vector PlayerPawn::getCameraPos(){
std::vector<BonePos> PlayerPawn::getBones(){
std::vector<BonePos> bones;
uint64_t GameSceneNode = mem.Read<uint64_t>(ptr + OFFSET_GAME_SCENE_NODE);
uint64_t BoneArrayAddress = mem.Read<uint64_t>(ptr + OFFSET_BONE_ARRAY);
uint64_t BoneArrayAddress = mem.Read<uint64_t>(GameSceneNode + OFFSET_BONE_ARRAY);
BoneJointData BoneData;
BonePos bones_tmp;
for (int i = 0; i < 30; i++){
Expand Down Expand Up @@ -257,19 +257,24 @@ uint64_t getEntityByClassName(std::string class_name)
// other funcs
bool WorldToScreen(const Vector& Pos, Vector2D& ToPos, VMatrix Matrix, int width, int height)
{
/*
printf("%f, %f, %f, %f\n", Matrix[0][1], Matrix[0][2], Matrix[0][3], Matrix[0][4]);
printf("%f, %f, %f, %f\n", Matrix[1][1], Matrix[1][2], Matrix[1][3], Matrix[1][4]);
printf("%f, %f, %f, %f\n", Matrix[2][1], Matrix[2][2], Matrix[2][3], Matrix[2][4]);
printf("%f, %f, %f, %f\n\n", Matrix[3][1], Matrix[3][2], Matrix[3][3], Matrix[3][4]);
*/
float View = 0.f;
float SightX = width / 2;
float SightY = height / 2;
float SightY = height / 2;

View = Matrix[3][0] * Pos.x + Matrix[3][1] * Pos.y + Matrix[3][2] * Pos.z + Matrix[3][3];

if (View <= 0.01)
return false;

if(View <= 0.01f) return false;

ToPos.x = SightX + (Matrix[0][0] * Pos.x + Matrix[0][1] * Pos.y + Matrix[0][2] * Pos.z + Matrix[0][3]) / View * SightX;
ToPos.y = SightY - (Matrix[1][0] * Pos.x + Matrix[1][1] * Pos.y + Matrix[1][2] * Pos.z + Matrix[1][3]) / View * SightY;
return true;

return true;
}

void setViewAngles(Vector2D angles){
Expand Down
3 changes: 2 additions & 1 deletion game.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
struct BoneJointData
{
Vector Pos;
char pad[0x14];
float Scale;
char pad[0x10];
};

struct BonePos
Expand Down
26 changes: 14 additions & 12 deletions offset.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
//https://github.com/a2x/cs2-dumper/blob/main/output/offsets.hpp
#define OFFSET_LOCAL_PAWN 0x181A9B8 //dwLocalPlayerPawn
#define OFFSET_LOCAL_CONTROLLER 0x1A04768 //dwLocalPlayerController
#define OFFSET_VIEW_ANGLES 0x1A23848 //dwViewAngles
#define OFFSET_SENSITIVITY 0x1A13248 //dwSensitivity
#define OFFSET_VIEW 0x1A16A60 //dwViewMatrix
#define OFFSET_ENTITY_LIST 0x19B49B8 //dwEntityList
#define OFFSET_GLOBAL_VARS 0x180E500 //dwGlobalVars
#define OFFSET_MAP_NAME 0x1A42E0 //dwGameTypes_mapName
#define OFFSET_C4 0x1A1B7A8 //dwPlantedC4
#define OFFSET_LOCAL_PAWN 0x1823A08 //dwLocalPlayerPawn
#define OFFSET_LOCAL_CONTROLLER 0x1A0D9A8 //dwLocalPlayerController
#define OFFSET_VIEW_ANGLES 0x1A2D248 //dwViewAngles
#define OFFSET_SENSITIVITY 0x1A1C338 //dwSensitivity
#define OFFSET_VIEW 0x1A1FCD0 //dwViewMatrix
#define OFFSET_ENTITY_LIST 0x19BDd78 //dwEntityList
#define OFFSET_GLOBAL_VARS 0x1817638 //dwGlobalVars
#define OFFSET_MAP_NAME 0x1A41C0 + 0x120 //dwGameTypes + dwGameTypes_mapName
#define OFFSET_C4 0x1A251A8 //dwPlantedC4

//https://github.com/a2x/cs2-dumper/blob/main/output/client.dll.hpp
#define OFFSET_SHOTS_FIRED 0x22A4 //m_iShotsFired
#define OFFSET_SHOTS_FIRED 0x22B4 //m_iShotsFired
#define OFFSET_EYE_ANGLE 0x1388 //m_angEyeAngles
#define OFFSET_AIM_PUNCH 0x14CC //m_aimPunchAngle
#define OFFSET_GAME_SCENE_NODE 0x308 //m_pGameSceneNode
#define OFFSET_BONE_ARRAY 0x170 + 0x88 //m_modelState + CGameSceneNode::m_vecOrigin
#define OFFSET_BONE_ARRAY 0x1f0 //m_modelState + ?
#define OFFSET_CAMERA_POS 0x12D4 //m_vecLastClipCameraPos
#define OFFSET_PLAYER_PAWN 0x7DC //m_hPlayerPawn
#define OFFSET_TEAM_NUM 0x3C3 //m_iTeamNum
#define OFFSET_HEALTH 0x324 //m_iHealth
#define OFFSET_ARMOR 0x22c0 //m_armorvalue
#define OFFSET_ARMOR 0x22D0 //m_armorvalue
#define OFFSET_WEAPON_SERVICE 0x10F8 //m_pweaponservices
#define OFFSET_ACTIVE_WEAPON 0x58 //m_hactiveweapon
#define OFFSET_SUBCLASS_ID 0x358 //m_nSubclassID
Expand Down Expand Up @@ -48,6 +48,8 @@

//keyboard
#define VK_F4 0x73
#define VK_XBUTTON1 0x05
#define VK_XBUTTON2 0x06

//bone
enum BONE: int
Expand Down
9 changes: 5 additions & 4 deletions radar/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions radar/react/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { MaskedIcon } from './MaskedIcon/MaskedIcon';
// if you want to share the radar, set this to '0', otherwise let it be '1'.
const USE_LOCALHOST = 0;

const PUBLIC_IP = "192.168.122.1";
const PORT = 22006;
const PUBLIC_IP = "103.71.69.61";
const PORT = 42051;

const App = () => {
const [averageLatency, setAverageLatency] = useState(0);
Expand Down
4 changes: 2 additions & 2 deletions radar/web_server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import http from "http";

console.log("web_server started")

const port = 22006;
const port = 8081;
const server = http.createServer();
const web_socket_server = new WebSocketServer(
{
Expand All @@ -30,4 +30,4 @@ web_socket_server.on("connection", (web_socket, request) => {
});

server.listen(port);
console.info(`listening on port '${port}'`);
console.info(`listening on port '${port}'`);
29 changes: 26 additions & 3 deletions sdk/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bool c_keys::InitKeyboard()
uintptr_t tmp = VMMDLL_ProcessGetModuleBaseU(mem.vHandle, pid, const_cast<LPSTR>("win32ksgd.sys"));
uintptr_t g_session_global_slots = tmp + 0x3110;
uintptr_t user_session_state = mem.ReadPID<uintptr_t>(mem.ReadPID<uintptr_t>(mem.ReadPID<uintptr_t>(g_session_global_slots, pid), pid), pid);
gafAsyncKeyStateExport = user_session_state + 0x3690;
gafAsyncKeyStateExport = user_session_state + 0x36a8;
if (gafAsyncKeyStateExport > 0x7FFFFFFFFFFF)
break;
}
Expand Down Expand Up @@ -200,7 +200,19 @@ void QMP::moveto(moves to){
if( abs(to.x) > 1 || abs(to.y) > 1){
while(true){
moves point_to_move = { 0 , 0 };
std::this_thread::sleep_for(std::chrono::milliseconds(1));

auto start = std::chrono::system_clock::now();
while(true){
const auto now = std::chrono::system_clock::now();

const auto duration = now - start;

if (duration >= std::chrono::milliseconds(1)){
break;
}
}

//std::this_thread::sleep_for(std::chrono::milliseconds(1));

if(to.x > 1){
to.x -= 1;
Expand All @@ -226,7 +238,18 @@ void QMP::moveto(moves to){
}
}
}else{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
//std::this_thread::sleep_for(std::chrono::nanoseconds(1000000));
auto start = std::chrono::system_clock::now();
while(true){
const auto now = std::chrono::system_clock::now();

const auto duration = now - start;

if (duration >= std::chrono::milliseconds(1)){
break;
}
}

MoveMouse(to.x, to.y);
}
}
Expand Down
Loading

0 comments on commit 010a9c9

Please sign in to comment.