Skip to content

Instantly share code, notes, and snippets.

@MagnificentPako
Created March 13, 2019 20:21
Show Gist options
  • Save MagnificentPako/079f89c4e93327eec7399a4b8d580b79 to your computer and use it in GitHub Desktop.
Save MagnificentPako/079f89c4e93327eec7399a4b8d580b79 to your computer and use it in GitHub Desktop.
import re
import sys
import os.path
def xor(data, key):
l = len(key)
decoded = "U"
for i in range(1, len(data)):
decoded += chr(data[i] ^ key[(i-1) % l])
return decoded
def mkKey(length):
return ([0xFF] * length) + ([0x00] * (length + 2))
pattern = re.compile("CAB-" + "\w" * 32)
if len(sys.argv) != 2:
print("Usage: python " + sys.argv[0] + " <input file>")
sys.exit()
assert os.path.isfile(sys.argv[1]), "File doesn't exist"
data = bytearray(open(sys.argv[1], "rb").read())
for i in range(0, 10):
key = mkKey(i)
decoded = xor(data, key)
if pattern.search(decoded) != None:
handle = open("out.unity3d", "w")
handle.write(decoded)
handle.close()
print("Managed to extract with key " + str(i) + " into out.unity3d")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment