use black as formatter

This commit is contained in:
Mylloon 2023-05-05 16:04:06 +02:00
parent bb7bd4e419
commit 271645a0d6
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
13 changed files with 323 additions and 198 deletions

View file

@ -1,28 +1,33 @@
from glob import glob from glob import glob
from hack import Hack
# Import all cheats # Import all cheats
backslash = "\\" backslash = "\\"
for file in glob("cheats/*.py"): for file in glob("cheats/*.py"):
exec(f"from {file.replace(backslash, '.')[:-3]} import *") exec(f"from {file.replace(backslash, '.')[:-3]} import *")
class Cheat(*[child for child in Hack.__subclasses__()]): # type: ignore class Cheat(*[child for child in Hack.__subclasses__()]):
"""All cheats are loaded in this class""" """All cheats are loaded in this class"""
def __init__(self, **kwargs) -> None: def __init__(self, **kwargs) -> None:
super().__init__(**kwargs) super().__init__(**kwargs)
self.cheats_list = [func for func in dir(self) self.cheats_list = [
# Function func
if callable(getattr(self, func)) for func in dir(self)
# User defined # Function
if not func.startswith("_") if callable(getattr(self, func))
# Hack loop # User defined
if not func == "hack_loop" if not func.startswith("_")
# Unloaders # Hack loop
if not func.endswith("_unload") if not func == "hack_loop"
# Utils # Unloaders
if not func.startswith("find_")] if not func.endswith("_unload")
# Utils
if not func.startswith("find_")
]
self.incompatible = dict.fromkeys(self.cheats_list, []) self.incompatible = dict.fromkeys(self.cheats_list, [])
@ -32,7 +37,8 @@ class Cheat(*[child for child in Hack.__subclasses__()]): # type: ignore
# Builds the implicit list # Builds the implicit list
for cheat, incompatible_cheat_list in self.incompatible.items(): for cheat, incompatible_cheat_list in self.incompatible.items():
for incompatible_cheat in incompatible_cheat_list: for incompatible_cheat in incompatible_cheat_list:
if not cheat in self.incompatible[incompatible_cheat]: if cheat not in self.incompatible[incompatible_cheat]:
# Propagate implicit cheat incompatibilities # Propagate implicit cheat incompatibilities
self.incompatible[incompatible_cheat] = self.incompatible[incompatible_cheat] + [ self.incompatible[incompatible_cheat] = self.incompatible[
cheat] incompatible_cheat
] + [cheat]

View file

@ -9,10 +9,10 @@ class Aimbot(Hack):
super().__init__(**kwargs) super().__init__(**kwargs)
# AimBot FOV, higher = more aggressive # AimBot FOV, higher = more aggressive
self.__fov_range = 4. self.__fov_range = 4.0
# Smoothing, more = less efficient # Smoothing, more = less efficient
self.__smoothing = 6. self.__smoothing = 6.0
def aimbot(self) -> None: def aimbot(self) -> None:
# Aliases # Aliases
@ -36,36 +36,60 @@ class Aimbot(Hack):
# Where are the eyes # Where are the eyes
local_eye_pos = Vec( local_eye_pos = Vec(
mem.read_float( float(mem.read_float(local_player + offset["m_vecOrigin"])),
local_player + offset["m_vecOrigin"]), float(
mem.read_float( mem.read_float(
local_player + offset["m_vecOrigin"] + offset["float"]), local_player + offset["m_vecOrigin"] + offset["float"]
mem.read_float( )
local_player + offset["m_vecOrigin"] + offset["float"] * 2) ),
).plus(Vec( float(
mem.read_float( mem.read_float(
local_player + offset["m_vecViewOffset"]), local_player + offset["m_vecOrigin"] + offset["float"] * 2
mem.read_float( )
local_player + offset["m_vecViewOffset"] + offset["float"]), ),
mem.read_float( ).plus(
local_player + offset["m_vecViewOffset"] + offset["float"] * 2) Vec(
)) float(mem.read_float(local_player + offset["m_vecViewOffset"])),
float(
mem.read_float(
local_player + offset["m_vecViewOffset"] + offset["float"]
)
),
float(
mem.read_float(
local_player
+ offset["m_vecViewOffset"]
+ offset["float"] * 2
)
),
)
)
# Where player is looking # Where player is looking
view_angles = Vec( view_angles = Vec(
mem.read_float( float(
client_state + offset["dwClientState_ViewAngles"]), mem.read_float(client_state + offset["dwClientState_ViewAngles"])
mem.read_float( ),
client_state + offset["dwClientState_ViewAngles"] + offset["float"]) float(
mem.read_float(
client_state
+ offset["dwClientState_ViewAngles"]
+ offset["float"]
)
),
) )
# How much the view is modified # How much the view is modified
aim_punch = Vec( aim_punch = Vec(
mem.read_float( float(mem.read_float(local_player + offset["m_aimPunchAngle"])),
local_player + offset["m_aimPunchAngle"]), float(
mem.read_float( mem.read_float(
local_player + offset["m_aimPunchAngle"] + offset["float"]) local_player + offset["m_aimPunchAngle"] + offset["float"]
).times(2.) # server multiple punch by 2 )
),
).times(
2.0
) # server multiple punch by 2
# Will hold info about the closest ennemy # Will hold info about the closest ennemy
best_distance = self.__fov_range best_distance = self.__fov_range
@ -73,8 +97,11 @@ class Aimbot(Hack):
# Loop all entities # Loop all entities
for i in range(1, 32): # 0 is world for i in range(1, 32): # 0 is world
entity = mem.read_uint( entity = int(
client + offset["dwEntityList"] + i * offset["entity_size"]) mem.read_uint(
client + offset["dwEntityList"] + i * offset["entity_size"]
)
)
# Ignore if entity doesn't exist # Ignore if entity doesn't exist
if not entity: if not entity:
@ -82,7 +109,8 @@ class Aimbot(Hack):
# Ignore allies # Ignore allies
if mem.read_int(entity + offset["m_iTeamNum"]) == ( if mem.read_int(entity + offset["m_iTeamNum"]) == (
mem.read_int(local_player + offset["m_iTeamNum"])): mem.read_int(local_player + offset["m_iTeamNum"])
):
continue continue
# Ignore dormant # Ignore dormant
@ -95,40 +123,55 @@ class Aimbot(Hack):
# Don't aim at ennemy behind a wall # Don't aim at ennemy behind a wall
if not ( if not (
mem.read_int(entity + offset["m_bSpottedByMask"]) int(mem.read_int(entity + offset["m_bSpottedByMask"]))
& & (
(1 << mem.read_int( 1
client_state + offset["dwClientState_GetLocalPlayer"])) << int(
mem.read_int(
client_state + offset["dwClientState_GetLocalPlayer"]
)
)
)
): ):
continue continue
# Find head # Find head
boneMatrix = mem.read_uint(entity + offset["m_dwBoneMatrix"]) boneMatrix = int(mem.read_uint(entity + offset["m_dwBoneMatrix"]))
ennemy_head = Vec( ennemy_head = Vec(
mem.read_float( float(
boneMatrix + offset["head_idx"] + offset["head_x"]), mem.read_float(
mem.read_float( boneMatrix + offset["head_idx"] + offset["head_x"]
boneMatrix + offset["head_idx"] + offset["head_y"]), )
mem.read_float( ),
boneMatrix + offset["head_idx"] + offset["head_z"]) float(
mem.read_float(
boneMatrix + offset["head_idx"] + offset["head_y"]
)
),
float(
mem.read_float(
boneMatrix + offset["head_idx"] + offset["head_z"]
)
),
) )
# Angle to ennemy's head # Angle to ennemy's head
angle = calculate_angle( angle = calculate_angle(
local_eye_pos, ennemy_head, view_angles.plus(aim_punch)) local_eye_pos, ennemy_head, view_angles.plus(aim_punch)
)
# Current FOV # Current FOV
distance = hypot(angle.x, angle.y) distance = hypot(angle.x, angle.y)
# If an ennemy is close # If an ennemy is close
if (distance < best_distance): if distance < best_distance:
best_distance = distance best_distance = distance
best_angle = angle best_angle = angle
# We found an ennemy to aim at # We found an ennemy to aim at
if not best_angle.is_zero(): if not best_angle.is_zero():
# Apply the smoothing if needed # Apply the smoothing if needed
if self.__smoothing > 0.: if self.__smoothing > 0.0:
best_angle = best_angle.div(self.__smoothing) best_angle = best_angle.div(self.__smoothing)
# Angle from player to ennemy's head # Angle from player to ennemy's head
@ -139,13 +182,16 @@ class Aimbot(Hack):
# Move player's view angle # Move player's view angle
mem.write_float( mem.write_float(
client_state + offset["dwClientState_ViewAngles"], final_angle.x) client_state + offset["dwClientState_ViewAngles"], final_angle.x
)
mem.write_float( mem.write_float(
client_state + offset["dwClientState_ViewAngles"] + offset["float"], final_angle.y) client_state + offset["dwClientState_ViewAngles"] + offset["float"],
final_angle.y,
)
self.hack_loop(cheat) self.hack_loop(cheat)
def calculate_angle(local_pos: Vec, ennemy_pos: Vec, angles: Vec) -> Vec: def calculate_angle(local_pos: Vec, ennemy_pos: Vec, angles: Vec) -> Vec:
"""Angle calculation for aimbot""" """Angle calculation for aimbot"""
return ((ennemy_pos.minus(local_pos).to_angle().minus(angles))) return ennemy_pos.minus(local_pos).to_angle().minus(angles)

View file

@ -28,7 +28,7 @@ class Bhop(Hack):
return return
# Check if player on ground # Check if player on ground
if mem.read_uint(local_player + offset["m_fFlags"]) & (1 << 0): if int(mem.read_uint(local_player + offset["m_fFlags"])) & (1 << 0):
mem.write_uint(client + offset["dwForceJump"], 5) mem.write_uint(client + offset["dwForceJump"], 5)
sleep(0.01) sleep(0.01)
mem.write_uint(client + offset["dwForceJump"], 4) mem.write_uint(client + offset["dwForceJump"], 4)

View file

@ -8,7 +8,7 @@ class Chams(Hack):
def __init__(self, **kwargs) -> None: def __init__(self, **kwargs) -> None:
super().__init__(**kwargs) super().__init__(**kwargs)
self.__color = (Color3i(255, 255, 0), 5.) self.__color = (Color3i(255, 255, 0), 5.0)
self.__default_color = None self.__default_color = None
def chams(self) -> None: def chams(self) -> None:
@ -30,51 +30,70 @@ class Chams(Hack):
def cheat(): def cheat():
# Loop all entities # Loop all entities
for i in range(1, 32): # 0 is world for i in range(1, 32): # 0 is world
entity = mem.read_uint( entity = int(
client + offset["dwEntityList"] + i * offset["entity_size"]) mem.read_uint(
client + offset["dwEntityList"] + i * offset["entity_size"]
)
)
# Ignore if entity doesn't exist # Ignore if entity doesn't exist
if not entity: if not entity:
continue continue
# Ignore allies # Ignore allies
if mem.read_int(entity + offset["m_iTeamNum"]) == mem.read_int(local_player + offset["m_iTeamNum"]): if mem.read_int(entity + offset["m_iTeamNum"]) == mem.read_int(
local_player + offset["m_iTeamNum"]
):
continue continue
# Space between values # Space between values
i = mem.read_int( i = (
entity + offset["m_iGlowIndex"]) * offset["glow_obj_size"] int(mem.read_int(entity + offset["m_iGlowIndex"]))
* offset["glow_obj_size"]
)
if not self.__default_color: if not self.__default_color:
self.__default_color = ( self.__default_color = (
Color3i( Color3i(
mem.read_uint( int(
entity + offset["m_clrRender"] + offset["render_R"]), mem.read_uint(
mem.read_uint( entity + offset["m_clrRender"] + offset["render_R"]
entity + offset["m_clrRender"] + offset["render_G"]), )
mem.read_uint( ),
entity + offset["m_clrRender"] + offset["render_B"]) int(
mem.read_uint(
entity + offset["m_clrRender"] + offset["render_G"]
)
),
int(
mem.read_uint(
entity + offset["m_clrRender"] + offset["render_B"]
)
),
), ),
mem.read_int(engine + offset["model_ambient_min"]) mem.read_int(engine + offset["model_ambient_min"]),
) )
# Change color # Change color
if color.r > 0: if color.r > 0:
mem.write_uint( mem.write_uint(
entity + offset["m_clrRender"] + offset["render_R"], color.r) entity + offset["m_clrRender"] + offset["render_R"], color.r
)
if color.g > 0: if color.g > 0:
mem.write_uint( mem.write_uint(
entity + offset["m_clrRender"] + offset["render_G"], color.g) entity + offset["m_clrRender"] + offset["render_G"], color.g
)
if color.b > 0: if color.b > 0:
mem.write_uint( mem.write_uint(
entity + offset["m_clrRender"] + offset["render_B"], color.b) entity + offset["m_clrRender"] + offset["render_B"], color.b
)
# Override the brightness of models by increasing # Override the brightness of models by increasing
# the minimal brightness value # the minimal brightness value
mem.write_int( mem.write_int(
engine + offset["model_ambient_min"], engine + offset["model_ambient_min"],
int.from_bytes(pack("f", brightness), byteorder='little') ^ ( int.from_bytes(pack("f", brightness), byteorder="little")
engine + offset["model_ambient_min"] - 0x2C) ^ (engine + offset["model_ambient_min"] - 0x2C),
) )
self.hack_loop(cheat) self.hack_loop(cheat)
@ -94,8 +113,11 @@ class Chams(Hack):
# Loop all entities # Loop all entities
for i in range(1, 32): # 0 is world for i in range(1, 32): # 0 is world
entity = mem.read_uint( entity = int(
client + offset["dwEntityList"] + i * offset["entity_size"]) mem.read_uint(
client + offset["dwEntityList"] + i * offset["entity_size"]
)
)
# Ignore if entity doesn't exist # Ignore if entity doesn't exist
if not entity: if not entity:
@ -104,12 +126,15 @@ class Chams(Hack):
# Reset to default value if needed # Reset to default value if needed
if color.r > 0: if color.r > 0:
mem.write_uint( mem.write_uint(
entity + offset["m_clrRender"] + offset["render_R"], color.r) entity + offset["m_clrRender"] + offset["render_R"], color.r
)
if color.g > 0: if color.g > 0:
mem.write_uint( mem.write_uint(
entity + offset["m_clrRender"] + offset["render_G"], color.g) entity + offset["m_clrRender"] + offset["render_G"], color.g
)
if color.b > 0: if color.b > 0:
mem.write_uint( mem.write_uint(
entity + offset["m_clrRender"] + offset["render_B"], color.b) entity + offset["m_clrRender"] + offset["render_B"], color.b
)
mem.write_int(engine + offset["model_ambient_min"], brightness) mem.write_int(engine + offset["model_ambient_min"], brightness)

View file

@ -28,7 +28,7 @@ class Fov(Hack):
self.__fov = self.find_uint(local_player, offset["m_iDefaultFOV"]) self.__fov = self.find_uint(local_player, offset["m_iDefaultFOV"])
def cheat(): def cheat():
if self.__fov == None: if self.__fov is None:
raise ValueError("FOV isn't defined.") raise ValueError("FOV isn't defined.")
fov = self.__fov fov = self.__fov
@ -47,8 +47,7 @@ class Fov(Hack):
# If modified # If modified
if fov != self.__fov: if fov != self.__fov:
# Override the FOV value # Override the FOV value
mem.write_int( mem.write_int(local_player + offset["m_iDefaultFOV"], self.__fov)
local_player + offset["m_iDefaultFOV"], self.__fov)
self.hack_loop(cheat) self.hack_loop(cheat)
@ -64,5 +63,4 @@ class Fov(Hack):
# Reset to default value if changed # Reset to default value if changed
if self.__fov not in [None, self.__default_fov]: if self.__fov not in [None, self.__default_fov]:
mem.write_int( mem.write_int(local_player + offset["m_iDefaultFOV"], self.__default_fov)
local_player + offset["m_iDefaultFOV"], self.__default_fov)

View file

@ -6,7 +6,7 @@ class Glow(Hack):
def __init__(self, **kwargs) -> None: def __init__(self, **kwargs) -> None:
super().__init__(**kwargs) super().__init__(**kwargs)
self.__color = Color4f(1., 0., 0., .8) self.__color = Color4f(1.0, 0.0, 0.0, 0.8)
def glow(self) -> None: def glow(self) -> None:
# Aliases # Aliases
@ -20,21 +20,25 @@ class Glow(Hack):
local_player = self.find_uint(client, offset["dwLocalPlayer"]) local_player = self.find_uint(client, offset["dwLocalPlayer"])
# Get glow object manager # Get glow object manager
glow_obj_manager = self.find_uint( glow_obj_manager = self.find_uint(client, offset["dwGlowObjectManager"])
client, offset["dwGlowObjectManager"])
def cheat(): def cheat():
# Loop all entities # Loop all entities
for i in range(1, 32): # 0 is world for i in range(1, 32): # 0 is world
entity = mem.read_uint( entity = int(
client + offset["dwEntityList"] + i * offset["entity_size"]) mem.read_uint(
client + offset["dwEntityList"] + i * offset["entity_size"]
)
)
# Ignore if entity doesn't exist # Ignore if entity doesn't exist
if not entity: if not entity:
continue continue
# Ignore allies # Ignore allies
if mem.read_int(entity + offset["m_iTeamNum"]) == mem.read_int(local_player + offset["m_iTeamNum"]): if mem.read_int(entity + offset["m_iTeamNum"]) == mem.read_int(
local_player + offset["m_iTeamNum"]
):
continue continue
# Ignore dormant # Ignore dormant
@ -46,28 +50,33 @@ class Glow(Hack):
continue continue
# Space between values # Space between values
i = mem.read_int( i = (
entity + offset["m_iGlowIndex"]) * offset["glow_obj_size"] int(mem.read_int(entity + offset["m_iGlowIndex"]))
* offset["glow_obj_size"]
)
# Change color glow # Change color glow
if self.__color.r > 0.: if self.__color.r > 0.0:
mem.write_float(glow_obj_manager + i + mem.write_float(
offset["glow_R"], self.__color.r) glow_obj_manager + i + offset["glow_R"], self.__color.r
if self.__color.g > 0.: )
mem.write_float(glow_obj_manager + i + if self.__color.g > 0.0:
offset["glow_G"], self.__color.g) mem.write_float(
if self.__color.b > 0.: glow_obj_manager + i + offset["glow_G"], self.__color.g
mem.write_float(glow_obj_manager + i + )
offset["glow_B"], self.__color.b) if self.__color.b > 0.0:
if self.__color.a > 0.: mem.write_float(
mem.write_float(glow_obj_manager + i + glow_obj_manager + i + offset["glow_B"], self.__color.b
offset["glow_A"], self.__color.a) )
if self.__color.a > 0.0:
mem.write_float(
glow_obj_manager + i + offset["glow_A"], self.__color.a
)
# Render when not visible # Render when not visible
mem.write_bool(glow_obj_manager + i + offset["GOM_wall"], True) mem.write_bool(glow_obj_manager + i + offset["GOM_wall"], True)
# Render when visible # Render when visible
mem.write_bool(glow_obj_manager + i + mem.write_bool(glow_obj_manager + i + offset["GOM_visible"], True)
offset["GOM_visible"], True)
self.hack_loop(cheat) self.hack_loop(cheat)

View file

@ -6,8 +6,8 @@ class Noflash(Hack):
def __init__(self, **kwargs) -> None: def __init__(self, **kwargs) -> None:
super().__init__(**kwargs) super().__init__(**kwargs)
self.__brightness = 30. self.__brightness = 30.0
self.__default_brightness = 255. self.__default_brightness = 255.0
def noflash(self) -> None: def noflash(self) -> None:
# Aliases # Aliases
@ -24,7 +24,8 @@ class Noflash(Hack):
def cheat(): def cheat():
# Override the brightness value # Override the brightness value
mem.write_float( mem.write_float(
local_player + offset["m_flFlashMaxAlpha"], self.__brightness) local_player + offset["m_flFlashMaxAlpha"], self.__brightness
)
# Value only overrided on first flash or when server fullupdate # Value only overrided on first flash or when server fullupdate
sleep(10) sleep(10)
@ -43,4 +44,5 @@ class Noflash(Hack):
# Reset to default value # Reset to default value
mem.write_float( mem.write_float(
local_player + offset["m_flFlashMaxAlpha"], self.__default_brightness) local_player + offset["m_flFlashMaxAlpha"], self.__default_brightness
)

View file

@ -22,37 +22,52 @@ class Norecoil(Hack):
local_player = self.find_uint(client, offset["dwLocalPlayer"]) local_player = self.find_uint(client, offset["dwLocalPlayer"])
# Get client state # Get client state
client_state = mem.read_uint(engine + offset["dwClientState"]) client_state = int(mem.read_uint(engine + offset["dwClientState"]))
def cheat(): def cheat():
# Check if player is shooting # Check if player is shooting
if mem.read_int(local_player + offset["m_iShotsFired"]): if mem.read_int(local_player + offset["m_iShotsFired"]):
# Where player is looking # Where player is looking
view_angles = Vec( view_angles = Vec(
mem.read_float( float(
client_state + offset["dwClientState_ViewAngles"]), mem.read_float(
mem.read_float( client_state + offset["dwClientState_ViewAngles"]
client_state + offset["dwClientState_ViewAngles"] + offset["float"]) )
),
float(
mem.read_float(
client_state
+ offset["dwClientState_ViewAngles"]
+ offset["float"]
)
),
) )
# Bullet shift # Bullet shift
aim_punch = Vec( aim_punch = Vec(
mem.read_float( float(mem.read_float(local_player + offset["m_aimPunchAngle"])),
local_player + offset["m_aimPunchAngle"]), float(
mem.read_float( mem.read_float(
local_player + offset["m_aimPunchAngle"] + offset["float"]) local_player + offset["m_aimPunchAngle"] + offset["float"]
).times(2.) # server multiple punch by 2 )
),
).times(
2.0
) # server multiple punch by 2
# New angles # New angles
new_angle = angle_normalizer(view_angles.plus( new_angle = angle_normalizer(
self.__old_punch).minus(aim_punch)) view_angles.plus(self.__old_punch).minus(aim_punch)
)
# Cancel recoil by moving the player view angle # Cancel recoil by moving the player view angle
mem.write_float( mem.write_float(
client_state + offset["dwClientState_ViewAngles"], new_angle.x) client_state + offset["dwClientState_ViewAngles"], new_angle.x
)
mem.write_float( mem.write_float(
client_state + offset["dwClientState_ViewAngles"] + offset["float"], new_angle.y) client_state + offset["dwClientState_ViewAngles"] + offset["float"],
new_angle.y,
)
# Save the current spray value for the next bullet # Save the current spray value for the next bullet
self.__old_punch = aim_punch self.__old_punch = aim_punch

View file

@ -19,15 +19,20 @@ class Radarhack(Hack):
def cheat(): def cheat():
# Loop all entities # Loop all entities
for i in range(1, 32): # 0 is world for i in range(1, 32): # 0 is world
entity = mem.read_uint( entity = int(
client + offset["dwEntityList"] + i * offset["entity_size"]) mem.read_uint(
client + offset["dwEntityList"] + i * offset["entity_size"]
)
)
# Ignore if entity doesn't exist # Ignore if entity doesn't exist
if not entity: if not entity:
continue continue
# Ignore allies # Ignore allies
if mem.read_int(entity + offset["m_iTeamNum"]) == mem.read_int(local_player + offset["m_iTeamNum"]): if mem.read_int(entity + offset["m_iTeamNum"]) == mem.read_int(
local_player + offset["m_iTeamNum"]
):
continue continue
# Ignore dormant # Ignore dormant

View file

@ -28,16 +28,20 @@ class Trigger(Hack):
return return
# Get crosshair info about what we aiming at # Get crosshair info about what we aiming at
crosshair_id = mem.read_int( crosshair_id = int(mem.read_int(local_player + offset["m_iCrosshairId"]))
local_player + offset["m_iCrosshairId"])
# 0 is wall, +64 isn't a player # 0 is wall, +64 isn't a player
if (crosshair_id == 0) or (crosshair_id > 64): if (crosshair_id == 0) or (crosshair_id > 64):
return return
# Get ennemy under crosshair # Get ennemy under crosshair
ennemy = mem.read_uint( ennemy = int(
client + offset["dwEntityList"] + (crosshair_id - 1) * offset["entity_size"]) mem.read_uint(
client
+ offset["dwEntityList"]
+ (crosshair_id - 1) * offset["entity_size"]
)
)
# Ignore dormant # Ignore dormant
if mem.read_bool(ennemy + offset["m_bDormant"]): if mem.read_bool(ennemy + offset["m_bDormant"]):
@ -48,7 +52,9 @@ class Trigger(Hack):
return return
# Ignore allies # Ignore allies
if mem.read_int(ennemy + offset["m_iTeamNum"]) == mem.read_int(local_player + offset["m_iTeamNum"]): if mem.read_int(ennemy + offset["m_iTeamNum"]) == mem.read_int(
local_player + offset["m_iTeamNum"]
):
return return
# Shoot # Shoot

57
hack.py
View file

@ -5,7 +5,7 @@ from pymem import Pymem
from requests import get from requests import get
class Hack(): class Hack:
"""Base class for playing with CSGO memory""" """Base class for playing with CSGO memory"""
def __init__(self, offline: bool = False) -> None: def __init__(self, offline: bool = False) -> None:
@ -29,27 +29,32 @@ class Hack():
serial_data = load(f) serial_data = load(f)
else: else:
hazedumper_data = get( hazedumper_data = get(
"https://raw.githubusercontent.com/frk1/hazedumper/master/csgo.min.json") "https://raw.githubusercontent.com/frk1/hazedumper/master/csgo.min.json"
)
serial_data = loads(hazedumper_data.text) serial_data = loads(hazedumper_data.text)
return serial_data["signatures"] | serial_data["netvars"] | { return (
"entity_size": 0x10, serial_data["signatures"]
"glow_obj_size": 0x38, | serial_data["netvars"]
"glow_R": 0x8, | {
"glow_G": 0xC, "entity_size": 0x10,
"glow_B": 0x10, "glow_obj_size": 0x38,
"glow_A": 0x14, "glow_R": 0x8,
"GOM_wall": 0x27, "glow_G": 0xC,
"GOM_visible": 0x28, "glow_B": 0x10,
"render_R": 0x0, "glow_A": 0x14,
"render_G": 0x1, "GOM_wall": 0x27,
"render_B": 0x2, "GOM_visible": 0x28,
"float": 0x4, "render_R": 0x0,
"head_idx": 0x30 * 8, "render_G": 0x1,
"head_x": 0x0C, "render_B": 0x2,
"head_y": 0x1C, "float": 0x4,
"head_z": 0x2C, "head_idx": 0x30 * 8,
} "head_x": 0x0C,
"head_y": 0x1C,
"head_z": 0x2C,
}
)
def _find_keys(self) -> dict[str, int]: def _find_keys(self) -> dict[str, int]:
"""https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes""" """https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes"""
@ -65,14 +70,13 @@ class Hack():
def _find_process(self, verbose: bool = False) -> Pymem: def _find_process(self, verbose: bool = False) -> Pymem:
"""Find game process""" """Find game process"""
process_found = False process_found = False
print("Looking for process... ", end="", print("Looking for process... ", end="", flush=True) if verbose else None
flush=True) if verbose else None
pm = None pm = None
while not process_found: while not process_found:
try: try:
pm = Pymem("csgo.exe") pm = Pymem("csgo.exe")
except: except: # noqa: E722
try: try:
sleep(self.timeout) sleep(self.timeout)
except KeyboardInterrupt: except KeyboardInterrupt:
@ -97,7 +101,8 @@ class Hack():
return found return found
else: else:
raise MemoryError( raise MemoryError(
"Maybe the game isn't fully loaded yet? Wait for menu screen") "Maybe the game isn't fully loaded yet? Wait for menu screen"
)
def find_uint(self, base, offset: int) -> int: def find_uint(self, base, offset: int) -> int:
"""Find unsigned integer in memory for sure""" """Find unsigned integer in memory for sure"""
@ -107,11 +112,11 @@ class Hack():
sleep(self.timeout) sleep(self.timeout)
return local_element return int(local_element)
def hack_loop(self, method, time: float | None = None): def hack_loop(self, method, time: float | None = None):
"""Run the hack loop""" """Run the hack loop"""
if time == None: if time is None:
time = self.wait_time time = self.wait_time
while True: while True:

17
main.py
View file

@ -22,15 +22,16 @@ if __name__ == "__main__":
args = {} args = {}
wanted_list = [] wanted_list = []
if (len(argv) > 1): if len(argv) > 1:
# User wanna use offline offsets # User wanna use offline offsets
if "--offline" in argv: if "--offline" in argv:
args["offline"] = True args["offline"] = True
# User gave a list of cheats # User gave a list of cheats
# Will bypass the interactive selection # Will bypass the interactive selection
wanted_list = [j for j in [i for i in argv if i.startswith( wanted_list = [
"--list=")][0][7:].split(",")] j for j in [i for i in argv if i.startswith("--list=")][0][7:].split(",")
]
# Load cheat class # Load cheat class
c = Cheat(**args) c = Cheat(**args)
@ -39,9 +40,11 @@ if __name__ == "__main__":
c_id = [c.cheats_list.index(cheat) for cheat in wanted_list] c_id = [c.cheats_list.index(cheat) for cheat in wanted_list]
# Interactive selection # Interactive selection
if (c_id == []): if c_id == []:
# Cheat list # Cheat list
print("You can run multiples cheat at once, separate your choices with a space.") print(
"You can run multiples cheat at once, separate your choices with a space."
)
print("Available cheats:") print("Available cheats:")
for idx, cheat in enumerate(c.cheats_list): for idx, cheat in enumerate(c.cheats_list):
print(f"#{idx + 1} - {cheat}") print(f"#{idx + 1} - {cheat}")
@ -50,13 +53,13 @@ if __name__ == "__main__":
try: try:
response = [int(i) for i in input("Enter ID: ").split(" ")] response = [int(i) for i in input("Enter ID: ").split(" ")]
for i in response: for i in response:
if (i > len(c.cheats_list) or i <= 0): if i > len(c.cheats_list) or i <= 0:
raise IndexError raise IndexError
c_id.append(i - 1) c_id.append(i - 1)
except KeyboardInterrupt: except KeyboardInterrupt:
print("Bye") print("Bye")
exit(1) exit(1)
except: except: # noqa: E722
c_id = [] c_id = []
print("Invalid ID.") print("Invalid ID.")

View file

@ -4,8 +4,13 @@ from math import atan2, hypot, pi
class Vec: class Vec:
"""Support : `Vec2i | Vec2f | Vec3i | Vec3f`""" """Support : `Vec2i | Vec2f | Vec3i | Vec3f`"""
def __init__(self, x: int | float | None = None, y: int | float | None = None, z: int | float | None = None) -> None: def __init__(
if x != None: self,
x: int | float | None = None,
y: int | float | None = None,
z: int | float | None = None,
) -> None:
if x is not None:
self.new(x, y, z) self.new(x, y, z)
else: else:
self.x = 0 self.x = 0
@ -14,7 +19,7 @@ class Vec:
def new(self, x: int | float, y: int | float | None, z: int | float | None) -> None: def new(self, x: int | float, y: int | float | None, z: int | float | None) -> None:
"""Change values of Vector""" """Change values of Vector"""
if y == None: if y is None:
raise TypeError raise TypeError
# Determine type of class # Determine type of class
@ -29,7 +34,7 @@ class Vec:
self.x = self.type(x) self.x = self.type(x)
self.y = self.type(y) self.y = self.type(y)
if z == None: if z is None:
self.z = None self.z = None
else: else:
self.z = self.type(z) self.z = self.type(z)
@ -39,84 +44,84 @@ class Vec:
x = round(self.x, max_precision) x = round(self.x, max_precision)
y = round(self.y, max_precision) y = round(self.y, max_precision)
z = None if self.z == None else round(self.z, max_precision) z = None if self.z is None else round(self.z, max_precision)
return f"{self.__class__.__name__}({x}, {y}{'' if z == None else f', {z}'})" return f"{self.__class__.__name__}({x}, {y}{'' if z is None else f', {z}'})"
def plus(self, other: 'Vec') -> 'Vec': def plus(self, other: "Vec") -> "Vec":
"""Add 2 vectors""" """Add 2 vectors"""
x = self.x + other.x x = self.x + other.x
y = self.y + other.y y = self.y + other.y
if self.z == None or other.z == None: if self.z is None or other.z is None:
return Vec(x, y) return Vec(x, y)
return Vec(x, y, self.z + other.z) return Vec(x, y, self.z + other.z)
def minus(self, other: 'Vec') -> 'Vec': def minus(self, other: "Vec") -> "Vec":
"""Subtracts 2 vectors""" """Subtracts 2 vectors"""
x = self.x - other.x x = self.x - other.x
y = self.y - other.y y = self.y - other.y
if self.z == None or other.z == None: if self.z is None or other.z is None:
return Vec(x, y) return Vec(x, y)
return Vec(x, y, self.z - other.z) return Vec(x, y, self.z - other.z)
def times(self, factor: float) -> 'Vec': def times(self, factor: float) -> "Vec":
"""Multiplies 2 vectors""" """Multiplies 2 vectors"""
x = self.x * factor x = self.x * factor
y = self.y * factor y = self.y * factor
if self.z == None: if self.z is None:
return Vec(x, y) return Vec(x, y)
return Vec(x, y, self.z * factor) return Vec(x, y, self.z * factor)
def div(self, factor: float) -> 'Vec': def div(self, factor: float) -> "Vec":
"""Divides 2 vectors""" """Divides 2 vectors"""
x = self.x / factor x = self.x / factor
y = self.y / factor y = self.y / factor
if self.z == None: if self.z is None:
return Vec(x, y) return Vec(x, y)
return Vec(x, y, self.z / factor) return Vec(x, y, self.z / factor)
def to_angle(self): def to_angle(self):
"""Transforms a Vec3 into a Vec2 angle""" """Transforms a Vec3 into a Vec2 angle"""
if self.z == None: if self.z is None:
raise TypeError raise TypeError
deg_to_rad = (180. / pi) deg_to_rad = 180.0 / pi
return Vec( return Vec(
atan2(-self.z, hypot(self.x, self.y)) * deg_to_rad, atan2(-self.z, hypot(self.x, self.y)) * deg_to_rad,
atan2(self.y, self.x) * deg_to_rad atan2(self.y, self.x) * deg_to_rad,
) )
def is_zero(self): def is_zero(self):
"""Check if the vector is zero""" """Check if the vector is zero"""
xy = (float(self.x) == 0.) and (float(self.y) == 0.) xy = (float(self.x) == 0.0) and (float(self.y) == 0.0)
if self.z == None: if self.z is None:
return xy return xy
return xy and float(self.z) == 0. return xy and float(self.z) == 0.0
def angle_normalizer(angle: Vec) -> Vec: def angle_normalizer(angle: Vec) -> Vec:
"""Force the angle to respect game limitation""" """Force the angle to respect game limitation"""
# Limit of pitch in game is ]-89; 180[ # Limit of pitch in game is ]-89; 180[
if angle.x > 89.: if angle.x > 89.0:
angle.x = 89. angle.x = 89.0
if angle.x < -89.: if angle.x < -89.0:
angle.x = -89 angle.x = -89
# Limit of yaw in game is ]-180; 360[ # Limit of yaw in game is ]-180; 360[
while (angle.y > 180.): while angle.y > 180.0:
angle.y -= 360. angle.y -= 360.0
while (angle.y < -180.): while angle.y < -180.0:
angle.y += 360. angle.y += 360.0
return angle return angle