This repository has been archived on 2023-09-02. You can view files and clone it, but cannot push or open issues or pull requests.
csh/main.py
2023-03-30 13:47:28 +02:00

182 lines
5.1 KiB
Python

from json import loads
from time import sleep
from pymem import Pymem
from requests import get
from win32api import GetAsyncKeyState
class Hack():
def __init__(self) -> None:
# Loading offsets
self.offsets = self._find_offsets()
self.pm = self._find_process(True)
self.wait_time = 0.01
self.timeout = self.wait_time * 50
def _find_offsets(self) -> dict[str, int]:
hazedumper_data = get(
"https://raw.githubusercontent.com/frk1/hazedumper/master/csgo.min.json")
serial_data = loads(hazedumper_data.text)
return serial_data["signatures"] | serial_data["netvars"]
def _find_process(self, verbose: bool = False) -> Pymem:
"""Find game process"""
process_found = False
print("Looking for process...") if verbose else None
pm = None
while not process_found:
try:
pm = Pymem("csgo.exe")
except:
# Timeout
sleep(.5)
else:
print("Process found!") if verbose else None
process_found = True
if pm:
return pm
exit(1)
def find_module(self, module: str):
"""Find module address"""
found = None
for internal_module in list(self.pm.list_modules()):
if internal_module.name == module + ".dll":
found = internal_module.lpBaseOfDll
if found:
return found
else:
raise MemoryError
def find_int(self, base, offset: int) -> int:
"""Find integer in memory"""
local_element = None
while not local_element:
local_element = self.pm.read_uint(base + offset)
sleep(self.timeout)
return local_element
class Cheat(Hack):
def __init__(self) -> None:
super().__init__()
self.cheats_list = [func for func in dir(self)
# Function
if callable(getattr(self, func))
# User defined
if not func.startswith("_")
# Utils
if not func.startswith("find_")]
def bhop(self) -> None:
# Aliases
mem = self.pm
offset = self.offsets
# Get client
client = self.find_module("client")
# Get player
local_player = self.find_int(client, offset["dwLocalPlayer"])
# Hack loop
while True:
# Reduce CPU usage
sleep(self.wait_time)
# Space bar detection
if not GetAsyncKeyState(ord(" ")):
continue
# Check if player is alive
if not mem.read_int(local_player + offset["m_iHealth"]):
continue
# Check if player on ground
if mem.read_uint(local_player + offset["m_fFlags"]) & (1 << 0):
mem.write_uint(client + offset["dwForceJump"], 5)
sleep(0.01) # maybe reduce ban rate?
mem.write_uint(client + offset["dwForceJump"], 4)
def radar_hack(self) -> None:
# Aliases
mem = self.pm
offset = self.offsets
# Get module address
client = self.find_module("client")
# Get local player
print("Looking for player...")
local_player = self.find_int(client, offset["dwLocalPlayer"])
# Get local team
print("Looking for team...")
local_team = self.find_int(local_player, offset["m_iTeamNum"])
print("Looking for entities...")
# idx 0 == world
ennemies = []
for i in range(1, 64):
entity = self.find_int(
client, offset["dwEntityList"] + i * 0x10)
# Ignore allies
print("Check entity team...", end=" ")
if self.find_int(entity, offset["m_iTeamNum"] == local_team):
print("ally found...")
continue
print("ennemy found...")
ennemies.append(entity)
# Hack loop
print("Running...")
while True:
# Reduce CPU usage
sleep(self.wait_time)
# Show ennemies
for ennemy in ennemies:
# Check if ennemy is alive
if not self.find_int(ennemy, offset["m_iHealth"]):
continue
mem.write_bool(ennemy + offset["m_bSpotted"], True)
if __name__ == "__main__":
# Cheat
c = Cheat()
# Cheat list
print("Enter 0 to exit.")
print("Available cheats:")
for idx, cheat in enumerate(c.cheats_list):
print(f"#{idx + 1} - {cheat}")
# Select cheat
c_id = None
while c_id == None:
try:
match int(input("Enter ID: #")):
case 0:
exit(0)
case i if i > len(c.cheats_list):
raise IndexError
case _ as i:
c_id = i - 1
except:
print("Invalid ID.")
pass
# Run cheat
getattr(c, c.cheats_list[c_id])()