#include <iostream>
#include <thread>
#include <chrono>
#include <X11/extensions/XTest.h>
#include <sys/uio.h>
#include <math.h>
#include <unistd.h>
using namespace std;
class lpx{
public:
char _0x0000[0x94]; //0x00
float pos[3]; //0x94
char _0x009C[0x48];
int team; //0xE4
char _0x00E8[4]; //0xE8
int health; //0xF0
char _0x00F4[0xC];
float duck; //0x100
char _0x0104[0x2EDC];
float vpuns[3]; //2FE0
char _0x2FE8[0x7914];
int ch; //A920
};
class bids{
public:
char _0x0000[0x12C];
float x; //0x12C
char _0x0130[0xC];
float y; //0x13C
char _0x0140[0xC];
float z; //0x14C
};
class epx{
public:
char _0x0000[0x94]; //0x00
float pos[3]; //0x94
char _0x009C[0x48];
int team; //0xE4
char _0x00E8[4]; //0xE8
int health; //0xF0
char _0x00F4[0xC];
float duck; //0x100
char _0x0104[0x14B];
bool lst; //0x24F
char _0x0250[0x242C]; //2428
unsigned long bm; //0x267C
//268C
};
class cmd{
public:
Display * dpy;
lpx lp;
epx ep;
bids bid;
bool rcsaim;
unsigned long epadr;
unsigned long lpadr;
unsigned long engp;
bool isaiming;
uint32_t cdl;
uint32_t edl;
int button1, button2, loop;
float vang[2];
float fbone[2];
float aiang[2];
bool trigaim;
float rcsang[2];
float finall[2];
float fov[2];
float smoothvalue;
float smooth[2];
float smoothed[2];
bool smoot;
}c;
class mem{
private:
struct iovec loc[1];
struct iovec remo[1];
pid_t pid;
char buf[512];
char cmd[256];
FILE *maps;
FILE * mapss;
long unsigned int result = 0;
public:
int showpid()
{
if(pid != 0){
return pid;
}
else exit(0);
}
int checkroot()
{
if (getuid() != 0) {
exit(0);
}
else return true;
}
uint32_t getmodule(const char* modname)
{
snprintf(cmd, 256, "grep \"%s\" /proc/%i/maps | head -n 1 | cut -d \"-\" -f1", modname, pid);
mapss = popen(cmd, "r");
if(mapss) {
fscanf(maps, "%08lx", &result);
}
pclose(mapss);
return result;
}
uint32_t getpid(const char * name){
snprintf(buf, 512, "pidof -s %s", name);
maps = popen(buf, "r");
if(maps){
fgets(buf, 512, maps);
}
pid = strtoul(buf, NULL, 10);
pclose( maps );
return pid;
}
void read(void* adr, void* bb, size_t size) {
loc[0].iov_base = bb;
loc[0].iov_len = size;
remo[0].iov_base = adr;
remo[0].iov_len = size;
process_vm_readv(pid, loc, 1, remo, 1, 0) == size;
}
void write(void* adr, void* bb, size_t size) {
loc[0].iov_base = bb;
loc[0].iov_len = size;
remo[0].iov_base = adr;
remo[0].iov_len = size;
process_vm_writev(pid, loc, 1, remo, 1, 0) == size;
}
}m;
void calca( float *src, float *dst, float *angles )
{
double delta[3] = { (src[0]-dst[0]), (src[1]-dst[1]), (src[2]-dst[2]) };
double hyp = sqrt(delta[0]*delta[0] + delta[1]*delta[1]);
angles[0] = (float) (atan(delta[2]/hyp) * 57.295779513082f);
angles[1] = (float) (atan(delta[1]/delta[0]) * 57.295779513082f);
angles[2] = 0.0f;
if(delta[0] >= 0.0) { angles[1] += 180.0f; }
}
void setcursor( float * src, float * vang, Display * dpy)
{
if(c.smoot == false)
{
if( src[1] > 180 )src[1] -= 360;
if( src[1] < -180 )src[1] += 360;
if(src[0] > 89)src[0] = 89;
if(src[0] < -89)src[0] = -89;
c.finall[0] = (((vang[0] - src[0])* -1));
c.finall[1] = (((vang[1] - src[1])));
if(c.finall[1] > -c.fov[0] && c.finall[1] < c.fov[0] && c.finall[0] > -c.fov[1] && c.finall[0] < c.fov[1]){
c.isaiming = true;
m.write((void*)(c.engp + 0x4CF0), &src[0], sizeof(src[0]));
m.write((void*)(c.engp + 0x4CF4), &src[1], sizeof(src[1]));
//XTestFakeMotionEvent(c.dpy, 0, c.finall[1]*4, c.finall[0]*4, 0);
}
}
if(c.smoot == true)
{
if( src[1] > 180 )src[1] -= 360;
if( src[1] < -180 )src[1] += 360;
if(src[0] > 89)src[0] = 89;
if(src[0] < -89)src[0] = -89;
src[0] -= vang[0];
src[1] -= vang[1];
c.smoothed[0] = ((src[0]) / c.smoothvalue) + vang[0];
c.smoothed[1] = ((src[1]) / c.smoothvalue) + vang[1];
if( c.smoothed[1] > 180 )c.smoothed[1] -= 360;
if( c.smoothed[1] < -180 )c.smoothed[1] += 360;
if(c.smoothed[0] > 89)c.smoothed[0] = 89;
if(c.smoothed[0] < -89)c.smoothed[0] = -89;
c.finall[0] = (((vang[0] - c.smoothed[0])* -1));
c.finall[1] = (((vang[1] - c.smoothed[1])));
if(c.finall[1] > -c.fov[0]/c.smoothvalue && c.finall[1] < c.fov[0]/c.smoothvalue && c.finall[0] > -c.fov[1]/c.smoothvalue && c.finall[0] < c.fov[1]/c.smoothvalue){
c.isaiming = true;
m.write((void*)(c.engp + 0x4CF0), &c.smoothed[0], sizeof(c.smoothed[0]));
m.write((void*)(c.engp + 0x4CF4), &c.smoothed[1], sizeof(c.smoothed[1]));
}
}
}
struct locals{
void r()
{
m.read((void*)(c.cdl + 0x14D90D4), &c.lpadr, sizeof(c.lpadr));
m.read((void*)(c.lpadr), &c.lp, sizeof(c.lp));
m.read((void*)(c.cdl + 0x54D0970), &c.button1, sizeof(c.button1));
m.read((void*)(c.edl + 0xE992EC), &c.engp, sizeof(c.engp));
m.read((void*)(c.engp + 0x4CF0), &c.vang, sizeof(c.vang));
}
}locr;
struct enemyes{
void r(int i)
{
m.read((void*)(c.cdl + 0x5437894 + i * 0x10), &c.epadr, sizeof(c.epadr));
m.read((void*)(c.epadr), &c.ep, sizeof(c.ep));
m.read((void*)(c.ep.bm), &c.bid, sizeof(c.bid));
}
}enemyr[32];
void aimloop(){
for(;;){
this_thread::sleep_for(chrono::microseconds(500));
XFlush(c.dpy);
locr.r();
c.isaiming = false;
for(c.loop = 0; c.loop < 32; c.loop++){
enemyr[c.loop].r(c.loop);
c.fbone[0] = c.bid.x;
c.fbone[1] = c.bid.y;
c.fbone[2] = c.bid.z-c.lp.duck;
if(c.lp.team != c.ep.team && c.lp.health > 1 && c.ep.health > 1 && c.ep.lst == false)
{
if(c.rcsaim == false){
calca(c.lp.pos, c.fbone, c.aiang);
if(c.button1 == 5){
setcursor(c.aiang, c.vang, c.dpy);
}
}
else if(c.rcsaim == true){
calca(c.lp.pos, c.fbone, c.aiang);
c.rcsang[0] = c.aiang[0] - c.lp.vpuns[0] * 2.0f;
c.rcsang[1] = c.aiang[1] - c.lp.vpuns[1] * 2.0f;
if(c.button1 == 5){
setcursor(c.rcsang, c.vang, c.dpy);
}
}
}
}
}
XCloseDisplay(c.dpy);
}
void trigloop(){
this_thread::sleep_for(chrono::milliseconds(500));
for(;;){
this_thread::sleep_for(chrono::microseconds(500));
if(c.lp.ch > 0 && c.isaiming == true){
XTestFakeButtonEvent(c.dpy, Button1, true, 0);
this_thread::sleep_for(chrono::milliseconds(1));
XTestFakeButtonEvent(c.dpy, Button1, false, 0);
}
}
}
void checkloop(){
this_thread::sleep_for(chrono::milliseconds(500));
for(;;){
this_thread::sleep_for(chrono::seconds(5));
m.getpid("csgo_linux");
m.showpid();
}
}
int main()
{
m.checkroot();
int fovx, fovy, smooth;
int tenab, rcenab;
float rfovx, rfovy, rsmooth;
cout << "AFOV X: (15 = 1.5)" << endl;
cin >> fovx;
cout << "AFOV Y: (15 = 1.5)" << endl;
cin >> fovy;
cout << "SMOOTH: (15 = 1.5 & 0 = OFF)" << endl;
cin >> smooth;
cout << "RCSENABLED: (1 = ON, 0 = OFF)" << endl;
cin >> rcenab;
cout << "TRIGGERAIM: (1 = ON, 0 = 0FF)" << endl;
cin >> tenab;
if(fovx <= 0)fovx = 0;
if(fovy <= 0)fovx = 0;
if(rcenab > 1)rcenab = 1;
if(rcenab < 1)rcenab = 0;
if(tenab > 1)tenab = 1;
if(tenab < 1)tenab=0;
rfovx = fovx;
rfovy = fovy;
rsmooth = smooth;
c.fov[0] = rfovx/10;
c.fov[1] = rfovy/10;
c.trigaim = tenab;
c.rcsaim = rcenab;
c.smoot = true;
c.smoothvalue = rsmooth/10 * 10;
if(rsmooth <= 0)c.smoot = false;
m.getpid("csgo_linux");
m.showpid();
c.cdl = m.getmodule("csgo/bin/client_client.so");
c.edl = m.getmodule("bin/engine_client.so");
c.dpy = XOpenDisplay(NULL);
if(c.trigaim == true){
thread aloop(aimloop);
thread tloop(trigloop);
thread cloop(checkloop);
aloop.join();
}
else if(c.trigaim == false){
thread aloop(aimloop);
thread cloop(checkloop);
aloop.join();
}
return 0;
}