2023-03-30 23:19:17 +02:00
|
|
|
from json import loads
|
|
|
|
from time import sleep
|
|
|
|
|
|
|
|
from pymem import Pymem
|
|
|
|
from requests import get
|
|
|
|
|
|
|
|
|
|
|
|
class Hack():
|
|
|
|
"""Base class for playing with CSGO memory"""
|
|
|
|
|
|
|
|
def __init__(self) -> None:
|
|
|
|
# Loading offsets
|
|
|
|
self.offsets = self._find_offsets()
|
2023-03-31 05:05:36 +02:00
|
|
|
self.vmap = self._find_keys()
|
2023-03-30 23:19:17 +02:00
|
|
|
|
|
|
|
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"] | {
|
|
|
|
"entity_size": 0x10,
|
|
|
|
"glow_obj_size": 0x38,
|
|
|
|
"glow_R": 0x8,
|
|
|
|
"glow_G": 0xC,
|
|
|
|
"glow_B": 0x10,
|
|
|
|
"glow_A": 0x14,
|
|
|
|
"GOM_wall": 0x27,
|
2023-03-30 23:44:52 +02:00
|
|
|
"GOM_visible": 0x28,
|
|
|
|
"render_R": 0x0,
|
|
|
|
"render_G": 0x1,
|
2023-03-31 00:58:44 +02:00
|
|
|
"render_B": 0x2,
|
|
|
|
"float": 0x4,
|
2023-03-31 04:08:09 +02:00
|
|
|
"head_idx": 0x30 * 8,
|
|
|
|
"head_x": 0x0C,
|
|
|
|
"head_y": 0x1C,
|
|
|
|
"head_z": 0x2C,
|
2023-03-30 23:19:17 +02:00
|
|
|
}
|
|
|
|
|
2023-03-31 05:05:36 +02:00
|
|
|
def _find_keys(self) -> dict[str, int]:
|
|
|
|
"""https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes"""
|
|
|
|
return {
|
|
|
|
"SPACE": 0x20,
|
|
|
|
"+": 0xBB,
|
|
|
|
"LBUTTON": 0x01,
|
|
|
|
}
|
|
|
|
|
2023-03-30 23:19:17 +02:00
|
|
|
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:
|
2023-03-31 05:04:14 +02:00
|
|
|
raise MemoryError("Maybe then game isn't fully loaded yet?")
|
2023-03-30 23:19:17 +02:00
|
|
|
|
|
|
|
def find_uint(self, base, offset: int) -> int:
|
2023-03-31 04:08:09 +02:00
|
|
|
"""Find unsigned integer in memory for sure"""
|
2023-03-30 23:19:17 +02:00
|
|
|
local_element = None
|
|
|
|
while not local_element:
|
|
|
|
local_element = self.pm.read_uint(base + offset)
|
|
|
|
|
|
|
|
sleep(self.timeout)
|
|
|
|
|
|
|
|
return local_element
|
|
|
|
|
|
|
|
def hack_loop(self, method):
|
|
|
|
"""Run the hack loop"""
|
|
|
|
while True:
|
|
|
|
# Reduce CPU usage
|
|
|
|
sleep(self.wait_time)
|
|
|
|
|
|
|
|
# Cheat
|
|
|
|
method()
|