Compare commits

..

No commits in common. "c2b287c22829e629588a5812a69f77237da3fb87" and "43e29ab277030f1cbfbb77e50369c52f15e03e52" have entirely different histories.

2 changed files with 5 additions and 21 deletions

BIN
notes.md

Binary file not shown.

View File

@ -1,15 +1,9 @@
import struct import struct
# BUG: I am dumb and used struct.pack to read values like a moron
# need to move to using struct.unpack and loading the size from the
# save file to make sure the entire label is retrieved
# Format for structure in notes.md
class OFFSETS: class OFFSETS:
VERSION = 0x42e VERSION = 0x42e
KEYS_LABEL = 0x12DB KEYS = 0x12DB
KEYS_VALUE = 0x12F9
ACCOUNT_LEVEL = 0x12AD ACCOUNT_LEVEL = 0x12AD
@ -26,22 +20,13 @@ def load_save(save_file_name):
print(f"Failed to read save file: {e}") print(f"Failed to read save file: {e}")
def get_key_value(save):
try:
data = struct.pack(">i", save[OFFSETS.KEYS_VALUE])
return data
except struct.error as e:
print(f"{e}")
def verify_save(save): def verify_save(save):
try: try:
struct.pack("bbbb", *save[:4]) == b"GVAS" struct.pack("bbbb", *save[:4]) == b"GVAS"
token = _bytes_to_string(read_token_at_offset(save, OFFSETS.VERSION)) token = _bytes_to_string(read_token_at_offset(save, OFFSETS.VERSION))
if token == "CrabChampionsVersion": if token == "CrabChampionsVersion":
return True return True
except struct.error as e: except struct.error:
print(f"{e}")
return False return False
@ -59,7 +44,7 @@ def read_token_at_offset(save, offset, size=1):
save = load_save("./test.sav") save = load_save("./test.sav")
if verify_save(save): if verify_save(save):
print("Save is a valid Crab Champions save") print("Save appears to be a save file of some kind")
else: else:
print("The fuck is this shit mate") print("The fuck is this shit mate")
exit() exit()
@ -68,6 +53,5 @@ else:
# Should be fine to do shit here # Should be fine to do shit here
# print(read_token_at_offset(save, 0x12DB)) # Keys # print(read_token_at_offset(save, 0x12DB)) # Keys
# print(read_token_at_offset(save, 0x12AD)) # AccountLevel # print(read_token_at_offset(save, 0x12AD)) # AccountLevel
token = read_token_at_offset(save, OFFSETS.KEYS_LABEL) token = read_token_at_offset(save, OFFSETS.KEYS)
# print(_bytes_to_string(token)) print(_bytes_to_string(token))
print(f"You have {int.from_bytes(get_key_value(save))} keys")