TrialsRisingPatcher.py
@assf.art · 29d ago · python · 71 loc · raw · 0 comments
1# More details: https://www.kylemohr.com/Trials-Rising-EasyAntiCheat-Bypass-Analysis2import os3import shutil4import getpass56def modify_exe(input_path):7 steam_version_offset = 0x0178ACC08 ubisoft_connect_version_offset = 0x01789EE09 expected_bytes = bytes.fromhex("48 89 54 24 10 55 56 57 48 81 EC F0 00 00 00 48")10 replacement_bytes = bytes.fromhex("B0 01 C3 24 10 55 56 57 48 81 EC F0 00 00 00 48")11 expected_path_linux = '/home/' + getpass.getuser() + '/.local/share/Steam/steamapps/common/Trials Rising/datapack/trialsrising.exe'1213 if not os.path.exists(input_path):14 if os.path.exists(expected_path_linux):15 input_path = expected_path_linux16 else:17 print("Error: Could not find trialsrising.exe")18 return False1920 try:21 with open(input_path, 'rb') as infile:22 data = bytearray(infile.read())2324 def check_and_patch(offset):25 if offset + len(expected_bytes) > len(data):26 return False, "Offset exceeds file size"27 read_bytes = bytes(data[offset: offset + len(expected_bytes)])28 if read_bytes == expected_bytes:29 print(f"Bytes matched at offset: {hex(offset)}. Modifying...")30 for i, byte in enumerate(replacement_bytes):31 data[offset + i] = byte32 return True, None33 return False, "Bytes did not match"3435 modified, message = check_and_patch(steam_version_offset)3637 if not modified:38 print("This does not appear to be a Steam version of the game. Checking if it's Ubisoft Connect version...")39 modified, message = check_and_patch(ubisoft_connect_version_offset)40 if not modified:41 print("Error: could not find bytes to patch. Is it possible that the file is already patched?")42 print("Ensure you're only trying to patch the original trialsrising.exe file.")43 return False4445 if modified:46 # backup original file47 backup_path = os.path.splitext(input_path)[0] + "_original.exe"48 shutil.copy(input_path, backup_path)49 print(f"Backed up original file to: {backup_path}")50 # write patched exe51 with open(input_path, 'wb') as outfile:52 outfile.write(data)53 print(f"Successfully patched file: {input_path}")54 return True55 return False565758 except FileNotFoundError:59 print(f"Error: Input file not found: {input_path}")60 return False61 except IOError as e:62 print(f"Error: IO error occurred: {e}")63 return False646566if __name__ == '__main__':67 input_file = input("Enter the path of the trialsrising.exe file, or press Enter to use the default path: ")68 if modify_exe(input_file):69 print("Process completed.")70 else:71 print("Process failed.")
login to post a comment