-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
315 lines (230 loc) · 10.8 KB
/
Program.cs
File metadata and controls
315 lines (230 loc) · 10.8 KB
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
using AimBots;
using Swed64;
using System.Numerics;
using System.Runtime.InteropServices;
//https://www.youtube.com/watch?v=hO1WmAO0rDA
const string processName = "cs2";
Swed swed = new Swed(processName);
IntPtr client = swed.GetModuleBase("client.dll");
Renderer renderer = new Renderer();
renderer.Start().Wait();
List<Entity> entities = [];
Entity localPlayer = new();
while(true)
{
swed.Hack(localPlayer, renderer, client, entities);
}
void loop1()
{
while (true)
{
entities.Clear();
IntPtr entityList = swed.ReadPointer(client, client_dll.dwEntityList);
//first entry
IntPtr listEntry = swed.ReadPointer(entityList, 0x10);
localPlayer.PawnAddress = swed.ReadPointer(client, client_dll.dwLocalPlayerPawn);
localPlayer.Team = swed.ReadInt(localPlayer.PawnAddress, 0x3BF); //C_BaseEntity.m_iTeamNum
localPlayer.Origin = swed.ReadVec(localPlayer.PawnAddress, 0x1244); //C_BasePlayerPawn.m_vOldOrigin
localPlayer.View = swed.ReadVec(localPlayer.PawnAddress, 0xC48);//C_BaseModelEntity.m_vecViewOffset
for (int i = 0; i < 64; i++) // 64 Controllers
{
if (listEntry == IntPtr.Zero)
{
continue;
}
IntPtr currentController = swed.ReadPointer(listEntry, i * 0x78); // 0x78 = 120
if (currentController == IntPtr.Zero)
{
continue;
}
int pawnHandle = swed.ReadInt(currentController, 0x7EC); // CCSPlayerController.m_hPlayerPawn = 0x7EC
if (pawnHandle == 0)
{
continue;
}
//apply bitmask 0x7FFF and shift bits by 9
int pawnIndex = (pawnHandle & 0x7FFF) >> 9;
IntPtr listEntry2 = swed.ReadPointer(entityList, 0x8 * pawnIndex + 0x10);
//get the pawn address from the entity list with the pawn index and the list entry
IntPtr currentPawn = swed.ReadPointer(listEntry2, 0x78 * (pawnHandle & 0x1FF));
if (currentPawn == IntPtr.Zero)
{
continue;
}
int health = swed.ReadInt(currentPawn, 0x32C); // C_BaseEntity.m_iHealth
int team = swed.ReadInt(currentPawn, 0x3BF); // C_BaseEntity.m_iTeamNum
uint lifeState = swed.ReadUInt(currentPawn, 0x330); // C_BaseEntity.m_lifeState
if (lifeState != 256)
{
continue;
}
if (team == localPlayer.Team && !renderer.aimBotOnTeam)
{
continue;
}
Entity entity = new Entity()
{
PawnAddress = currentPawn,
ControllerAddress = currentController,
Health = health,
Team = team,
LifeState = lifeState,
Origin = swed.ReadVec(currentPawn, 0x1244), //C_BasePlayerPawn.m_vOldOrigin
View = swed.ReadVec(currentPawn, 0xC48),//C_BaseModelEntity.m_vecViewOffset
Distance = Vector3.Distance(swed.ReadVec(currentPawn, 0x1244), localPlayer.Origin)
};
entities.Add(entity);
Console.ForegroundColor = ConsoleColor.Green;
if (team != localPlayer.Team)
{
Console.ForegroundColor = ConsoleColor.Red;
}
Console.WriteLine($"Entity: {i} Health: {health} Team: {team} LifeState: {lifeState} Distance: {(int)entity.Distance / 100}m");
Console.ResetColor();
entities = [.. entities.OrderBy(x => x.Distance)];
if (entities.Count > 0 && GetAsyncKeyState(HOTKEY) < 0 && renderer.aimbot)
{
Vector3 playerView = Vector3.Add(localPlayer.Origin, localPlayer.View);
Vector3 entityView = Vector3.Add(entities[0].Origin, entities[0].View);
Vector2 vector2 = Math2.CalculateAngles(playerView, entityView);
Vector3 vector3 = new Vector3(vector2.X, vector2.Y, 0.0f);
swed.WriteVec(client, 0x1880DC0, vector3); //client_dll.dwViewAngles
}
Thread.Sleep(20);
}
}
}
static class SwedExtensions
{
//https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
const int HOTKEY = 0x06; // X2 mouse button
const int m_flDetectedByEnemySensorTime = 0x13E4; // time for some offsets
[DllImport(dllName: "user32.dll")]
public static extern short GetAsyncKeyState(int vKey);
public static void Hack(this Swed swed, Entity localPlayer, Renderer renderer, IntPtr client, List<Entity> entities)
{
entities.Clear(); // clean list of old ents
IntPtr entityList = swed.ReadPointer(client, Offsets.dwEntityList);
// first entry into entity list
IntPtr listEntry = swed.ReadPointer(entityList, 0x10); // we don't have an ID yet.
if (renderer.wallHack)
{
swed.WallHack(entityList, listEntry);
}
//Console.Clear();
localPlayer = swed.UpdateLocalPlayer(localPlayer, client);
entities = swed.GetEntities(localPlayer, entityList, listEntry, renderer);
// Aimbot stuff
if (renderer.aimbot)
{
swed.AimBot(entities, localPlayer, client);
}
Thread.Sleep(14); // change depending on your need.
}
public static void WallHack(this Swed swed, IntPtr entityList, IntPtr listEntry)
{
for (int i = 0; i < 64; i++) // 64 controllers
{
if (listEntry == IntPtr.Zero)
continue;
// get current controller
IntPtr currentController = swed.ReadPointer(listEntry, i * 0x78);
if (currentController == IntPtr.Zero)
continue;
// get current pawn
int pawnHandle = swed.ReadInt(currentController, Offsets.m_hPlayerPawn);
if (pawnHandle == 0)
continue;
// second entry
IntPtr listEntry2 = swed.ReadPointer(entityList, 0x8 * ((pawnHandle & 0x7FFF) >> 9) + 0x10);
IntPtr currentPawn = swed.ReadPointer(listEntry2, 0x78 * (pawnHandle & 0x1FF));
// now that we have the pawn we can force the glow
swed.WriteFloat(currentPawn, m_flDetectedByEnemySensorTime, 86400); // for some odd reason this is the value for glow.
// write pawn so that we can see that they're there.
Console.WriteLine($"{i}: {currentPawn}");
}
}
public static Entity UpdateLocalPlayer(this Swed swed, Entity localPlayer, IntPtr client)
{
IntPtr pawnAddress = swed.ReadPointer(client, Offsets.dwLocalPlayerPawn);
Entity newLocalPlayer = localPlayer with
{
PawnAddress = pawnAddress,
Team = swed.ReadInt(pawnAddress, 0x3BF), //C_BaseEntity.m_iTeamNum
Origin = swed.ReadVec(pawnAddress, 0x1244), //C_BasePlayerPawn.m_vOldOrigin
View = swed.ReadVec(pawnAddress, 0xC48)//C_BaseModelEntity.m_vecViewOffset
};
return newLocalPlayer;
}
public static List<Entity> GetEntities(this Swed swed, Entity localPlayer, IntPtr entityList, IntPtr listEntry, Renderer renderer)
{
List<Entity> entities = [];
for (int i = 0; i < 64; i++) // 64 controllers
{
if (listEntry == IntPtr.Zero) // skip if entry invalid
continue;
// get current controller
IntPtr currentController = swed.ReadPointer(listEntry, i * 0x78); // you might want to add a bitmask if you use higher a higher i.
if (currentController == IntPtr.Zero) // skip if controller invalid
continue;
// get pawn handle
int pawnHandle = swed.ReadInt(currentController, Offsets.m_hPlayerPawn);
if (pawnHandle == 0) // you get it by this point, the same.
continue;
// second entry, now we find the pawn!
// apply bitmask 0x7FFF and shift bits by 9.
IntPtr listEntry2 = swed.ReadPointer(entityList, 0x8 * ((pawnHandle & 0x7FFF) >> 9) + 0x10);
// read current pawn, apply bitmask to stay inside range
IntPtr currentPawn = swed.ReadPointer(listEntry2, 0x78 * (pawnHandle & 0x1FF));
if (currentPawn == localPlayer.PawnAddress)
continue;
// get scene node
IntPtr sceneNode = swed.ReadPointer(currentPawn, Offsets.m_pGameSceneNode);
// get bone array / bone matrix
IntPtr boneMatrix = swed.ReadPointer(sceneNode, Offsets.m_modelState + 0x80); // 0x80 is the dwBoneMatrix offset
// get pawn attributes
int health = swed.ReadInt(currentPawn, Offsets.m_iHealth);
int team = swed.ReadInt(currentPawn, Offsets.m_iTeamNum);
uint lifeState = swed.ReadUInt(currentPawn, Offsets.m_lifeState);
if (lifeState != 256)
continue;
if (team == localPlayer.Team && renderer.aimBotOnTeam == false)
continue;
Entity entity = new Entity()
{
PawnAddress = currentPawn,
ControllerAddress = currentController,
Health = health,
LifeState = lifeState,
Origin = swed.ReadVec(currentPawn, Offsets.m_vOldOrigin),
View = swed.ReadVec(currentPawn, Offsets.m_vecViewOffset),
Distance = Vector3.Distance(swed.ReadVec(currentPawn, Offsets.m_vOldOrigin), localPlayer.Origin),
Head = swed.ReadVec(boneMatrix, 6 * 32) // 6 = bone id, 32 = step between bone coordinates.
};
entities.Add(entity);
Console.ForegroundColor = ConsoleColor.Green; // Set text color to green
if (team != localPlayer.Team)
{
Console.ForegroundColor = ConsoleColor.Red; // Set text color to red
}
Console.WriteLine($"{entity.Health}hp, head coordinate {entity.Head}");
// Reset text color to the default after printing
Console.ResetColor();
}
return [.. entities.OrderBy(o => o.Distance)];
}
public static void AimBot(this Swed swed, List<Entity> entities, Entity localPlayer, IntPtr client)
{
if (entities.Count > 0 && GetAsyncKeyState(HOTKEY) < 0)
{
// get view values
Vector3 playerView = Vector3.Add(localPlayer.Origin, localPlayer.View);
Vector3 entityView = Vector3.Add(entities[0].Origin, entities[0].View);
// get angles
Vector2 newAngles = Math2.CalculateAngles(playerView, entities[0].Head);
Vector3 newAnglesVec3 = new Vector3(newAngles.Y, newAngles.X, 0.0f);
// set angles
swed.WriteVec(client, Offsets.dwViewAngles, newAnglesVec3);
}
}
}