forked from laazyboy13/linux-csgo-external
-
Notifications
You must be signed in to change notification settings - Fork 11
/
hack.cpp
161 lines (125 loc) · 5.23 KB
/
hack.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include "hack.h"
struct iovec g_remote[1024], g_local[1024];
struct hack::GlowObjectDefinition_t g_glow[1024];
int count = 0;
unsigned char spotted = 1;
void NoFlash(remote::Handle* csgo, remote::MapModuleMemoryRegion* client, unsigned long localPlayer) {
float fFlashAlpha = 70.0f;
float fFlashAlphaFull = 255.0f;
float fFlashAlphaFromGame = 0.0f;
csgo->Read((void*) (localPlayer+0xABE4), &fFlashAlphaFromGame, sizeof(float));
if ((fFlashAlphaFromGame > fFlashAlpha) && (csgo->m_bShouldNoFlash))
csgo->Write((void*) (localPlayer+0xABE4), &fFlashAlpha, sizeof(float));
else if ((fFlashAlphaFromGame < fFlashAlphaFull) && (!csgo->m_bShouldNoFlash))
csgo->Write((void*) (localPlayer+0xABE4), &fFlashAlphaFull, sizeof(float));
}
void hack::Bhop(remote::Handle* csgo, remote::MapModuleMemoryRegion* client, Display* display) {
if (!csgo || !client)
return;
unsigned long localPlayer = 0;
csgo->Read((void*) csgo->m_addressOfLocalPlayer, &localPlayer, sizeof(long));
unsigned int onGround = 0;
csgo->Read((void*) (localPlayer+0x134+0x4), &onGround, sizeof(int));
onGround = onGround & (1 << 0);
if (onGround == 1 && csgo->m_bShouldBHop && csgo->m_bBhopEnabled) {
unsigned int jump = 5;
csgo->Write((void*) (csgo->m_oAddressOfForceJump), &jump, sizeof(int));
this_thread::sleep_for(chrono::milliseconds(2));
jump = 4;
csgo->Write((void*) (csgo->m_oAddressOfForceJump), &jump, sizeof(int));
}
}
void hack::Glow(double colors[12], remote::Handle* csgo, remote::MapModuleMemoryRegion* client) {
if (!csgo || !client)
return;
// Reset
bzero(g_remote, sizeof(g_remote));
bzero(g_local, sizeof(g_local));
bzero(g_glow, sizeof(g_glow));
hack::CGlowObjectManager manager;
if (!csgo->Read((void*) csgo->m_addressOfGlowPointer, &manager, sizeof(hack::CGlowObjectManager))) {
Logger::error ("Failed to read glowClassAddress");
throw 1;
return;
}
size_t count = manager.m_GlowObjectDefinitions.Count;
void* data_ptr = (void*) manager.m_GlowObjectDefinitions.DataPtr;
if (!csgo->Read(data_ptr, g_glow, sizeof(hack::GlowObjectDefinition_t) * count)) {
Logger::error ("Failed to read m_GlowObjectDefinitions");
throw 1;
return;
}
size_t writeCount = 0;
unsigned long localPlayer = 0;
unsigned int teamNumber = 0;
csgo->Read((void*) csgo->m_addressOfLocalPlayer, &localPlayer, sizeof(long));
if (localPlayer != 0) {
csgo->Read((void*) (localPlayer+0x128), &teamNumber, sizeof(int));
NoFlash(csgo, client, localPlayer);
}
for (unsigned int i = 0; i < count; i++) {
if (g_glow[i].m_pEntity != NULL) {
Entity ent;
if (csgo->Read(g_glow[i].m_pEntity, &ent, sizeof(Entity))) {
if (ent.m_iTeamNum != 2 && ent.m_iTeamNum != 3) {
g_glow[i].m_bRenderWhenOccluded = 0;
g_glow[i].m_bRenderWhenUnoccluded = 0;
continue;
}
bool entityInCrossHair = false;
if (localPlayer != 0) {
if (ent.m_iTeamNum != teamNumber) {
unsigned int crossHairId = 0;
unsigned int entityId = 0;
unsigned int attack = 0x5;
unsigned int release = 0x4;
csgo->Read((void*) (localPlayer+0xBBB8), &crossHairId, sizeof(int));
csgo->Read((void*) ((uint8_t*)g_glow[i].m_pEntity + 0x94), &entityId, sizeof(int));
unsigned int iAlt1Status = 0 ;
csgo->Read((void*) (csgo->m_addressOfAlt1), &iAlt1Status, sizeof(int));
if (crossHairId == entityId) {
entityInCrossHair = true;
unsigned int shooting;
csgo->Read((void*) (csgo->m_addressOfForceAttack), &shooting, sizeof(int));
if (iAlt1Status == 0x5 && shooting != attack) {
usleep(100);
csgo->Write((void*) (csgo->m_addressOfForceAttack), &attack, sizeof(int));
usleep(100);
csgo->Write((void*) (csgo->m_addressOfForceAttack), &release, sizeof(int));
}
}
}
}
csgo->Write((void*) ((unsigned long) g_glow[i].m_pEntity + 0xECD), &spotted, sizeof(unsigned char));
if (g_glow[i].m_bRenderWhenOccluded == 1)
continue;
g_glow[i].m_bRenderWhenOccluded = 1;
g_glow[i].m_bRenderWhenUnoccluded = 0;
if (ent.m_iTeamNum == 2 || ent.m_iTeamNum == 3) {
if (teamNumber == ent.m_iTeamNum) {
g_glow[i].m_flGlowRed = colors[8];
g_glow[i].m_flGlowGreen = colors[9];
g_glow[i].m_flGlowBlue = colors[10];
g_glow[i].m_flGlowAlpha = colors[11];
} else {
g_glow[i].m_flGlowRed = entityInCrossHair ? colors[4] : colors[0];
g_glow[i].m_flGlowGreen = entityInCrossHair ? colors[5] : colors[1];
g_glow[i].m_flGlowBlue = entityInCrossHair ? colors[6] : colors[2];
g_glow[i].m_flGlowAlpha = entityInCrossHair ? colors[7] : colors[3];
}
}
}
}
if (csgo->m_bShouldGlow) {
size_t bytesToCutOffEnd = sizeof(hack::GlowObjectDefinition_t) - g_glow[i].writeEnd();
size_t bytesToCutOffBegin = (size_t) g_glow[i].writeStart();
size_t totalWriteSize = (sizeof(hack::GlowObjectDefinition_t) - (bytesToCutOffBegin + bytesToCutOffEnd));
g_remote[writeCount].iov_base =
((uint8_t*) data_ptr + (sizeof(hack::GlowObjectDefinition_t) * i)) + bytesToCutOffBegin;
g_local[writeCount].iov_base = ((uint8_t*) &g_glow[i]) + bytesToCutOffBegin;
g_remote[writeCount].iov_len = g_local[writeCount].iov_len = totalWriteSize;
writeCount++;
}
}
process_vm_writev(csgo->GetPid(), g_local, writeCount, g_remote, writeCount, 0);
}