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

136 lines
3.7 KiB
Python
Raw Normal View History

from json import loads
2023-03-30 11:26:52 +02:00
from time import sleep
from pymem import Pymem
from requests import get
2023-03-30 11:26:52 +02:00
from win32api import GetAsyncKeyState
class Hack():
def __init__(self) -> None:
2023-03-30 13:03:32 +02:00
# Loading offsets
self.offsets = self._find_offsets()
2023-03-30 13:00:39 +02:00
self.pm = self._find_process(True)
2023-03-30 12:53:37 +02:00
2023-03-30 13:03:32 +02:00
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"]
2023-03-30 13:00:39 +02:00
def _find_process(self, verbose: bool = False) -> Pymem:
"""Find game process"""
process_found = False
print("Looking for process...") if verbose else None
2023-03-30 11:26:52 +02:00
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
2023-03-30 11:26:52 +02:00
if pm:
return pm
exit(1)
2023-03-30 11:26:52 +02:00
2023-03-30 13:00:39 +02:00
def find_module(self, module: str):
found = None
for internal_module in list(self.pm.list_modules()):
if internal_module.name == module + ".dll":
found = internal_module.lpBaseOfDll
2023-03-30 11:26:52 +02:00
2023-03-30 13:00:39 +02:00
if found:
return found
else:
raise MemoryError
2023-03-30 13:14:24 +02:00
class Cheat(Hack):
def __init__(self) -> None:
super().__init__()
self.wait_time = 0.01
self.timeout = self.wait_time * 50
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 find_local_player(self, client) -> int:
local_player = None
while not local_player:
local_player = self.pm.read_uint(
client + self.offsets["dwLocalPlayer"])
sleep(self.timeout)
return local_player
2023-03-30 13:00:39 +02:00
def bhop(self) -> None:
2023-03-30 13:03:32 +02:00
# Aliases
2023-03-30 13:00:39 +02:00
mem = self.pm
2023-03-30 13:03:32 +02:00
offset = self.offsets
2023-03-30 11:26:52 +02:00
# Get module address
2023-03-30 13:00:39 +02:00
client = self.find_module("client")
2023-03-30 11:26:52 +02:00
2023-03-30 13:14:24 +02:00
# Get local player
local_player = self.find_local_player(client)
# Hack loop
2023-03-30 13:00:39 +02:00
while True:
# Reduce CPU usage
2023-03-30 13:14:24 +02:00
sleep(self.wait_time)
# Space bar detection
if not GetAsyncKeyState(ord(" ")):
continue
# Check if player is alive
2023-03-30 13:00:39 +02:00
if not mem.read_int(local_player + offset["m_iHealth"]):
continue
# Check if player on ground
2023-03-30 13:00:39 +02:00
if mem.read_uint(local_player + offset["m_fFlags"]) & (1 << 0):
mem.write_uint(client + offset["dwForceJump"], 5)
2023-03-30 13:14:24 +02:00
sleep(0.01) # maybe reduce ban rate?
2023-03-30 13:00:39 +02:00
mem.write_uint(client + offset["dwForceJump"], 4)
2023-03-30 11:26:52 +02:00
if __name__ == "__main__":
# Cheat
2023-03-30 13:14:24 +02:00
c = Cheat()
2023-03-30 13:03:32 +02:00
# Cheat list
2023-03-30 12:53:37 +02:00
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])()