Compare commits

..

No commits in common. "da20e64b8c09f37302117d6cd44f677926d21f39" and "f298191374c4dc8f9a992c66c5572ead8f2f679f" have entirely different histories.

2 changed files with 16 additions and 33 deletions

View File

@ -1,9 +0,0 @@
{
"editor.defaultFormatter": "ms-python.black-formatter",
"black-formatter.cwd": "${workspaceFolder}/src",
"editor.formatOnSave": true,
"html.format.enable": true,
"python.REPL.enableREPLSmartSend": false,
"black-formatter.args": ["--ignore=E203"],
"flake8.args": ["--ignore=E203"]
}

View File

@ -1,16 +1,6 @@
import struct
class OFFSETS:
VERSION = 0x42e
KEYS = 0x12DB
ACCOUNT_LEVEL = 0x12AD
def _bytes_to_string(bytes):
return str(bytes.split(b"\x00")[0].decode())
def load_save(save_file_name):
try:
with open(save_file_name, "rb") as f:
@ -23,22 +13,26 @@ def load_save(save_file_name):
def verify_save(save):
try:
struct.pack("bbbb", *save[:4]) == b"GVAS"
token = _bytes_to_string(read_token_at_offset(save, OFFSETS.VERSION))
if token == "CrabChampionsVersion":
# This I think just means we have an unreal engine save but for now it should suffice
return True
except struct.error:
return False
def read_token_at_offset(save, offset, size=1):
def read_token_at_offset(save, offset):
# Load the first 16 bytes from the offset
try:
data = struct.pack("b" * size, *save[offset: offset + size])
if data[-1] != 0x00:
data = read_token_at_offset(save, offset, size + 1)
return data
except struct.error:
print("Failed to find NULL byte in token, probs not a token")
data = struct.pack("b" * 9, *save[offset : offset + 9])
if data[-1] == 0x00:
return str(data.split(b"\x00")[0].decode())
else:
data = struct.pack("b" * 16, *save[offset : offset + 16])
if data[-1] == 0x00:
return str(data.split(b"\x00")[0].decode())
else:
return None
except struct.error as e:
print(f"Failed to parse data: {e}")
save = load_save("./test.sav")
@ -47,11 +41,9 @@ if verify_save(save):
print("Save appears to be a save file of some kind")
else:
print("The fuck is this shit mate")
exit()
# Should be fine to do shit here
# print(read_token_at_offset(save, 0x12DB)) # Keys
# print(read_token_at_offset(save, 0x12AD)) # AccountLevel
token = read_token_at_offset(save, OFFSETS.KEYS)
print(_bytes_to_string(token))
print(read_token_at_offset(save, 0x1329)) # AccountLevel