import pymem
import re
from pynput import keyboard
from termcolor import colored
running = False
try: # checks if csgo is opened
pm = pymem.Pymem('csgo.exe')
def on_press(key): # starts key listener
try:
k = key.char # single-char keys
except:
k = key.name # other keys
if k in ['p']: # keys of interest
global running
if not running: # if cheat wasn't running, runs it
print(colored('Running...', 'green'))
running = True
elif running: # if cheat was running, stops it
print(colored('Not running...', 'red'))
running = False
# --------------------------- cheat himself -------------------------------------
pm = pymem.Pymem('csgo.exe')
client = pymem.process.module_from_name(pm.process_handle,
'client.dll')
clientModule = pm.read_bytes(client.lpBaseOfDll, client.SizeOfImage)
address = client.lpBaseOfDll + re.search(rb'\x80\xB9.{5}\x74\x12\x8B\x41\x08',
clientModule).start() + 6
pm.write_uchar(address, 0 if pm.read_uchar(address) != 0 else 2)
pm.close_process()
# ---------------------------- end of cheat -------------------------------------
listener = keyboard.Listener(on_press=on_press)
listener.start() # start to listen on a separate thread
listener.join() # remove if main thread is polling self.keys
except pymem.exception.ProcessNotFound: # if csgo isn't running,
# catches the error and prints something readable
print(colored("CS:GO isn't running...", 'red'))