Skip to content

Instantly share code, notes, and snippets.

@MagnificentPako
Created March 13, 2019 20:25
Show Gist options
  • Save MagnificentPako/5bac8a8163ff56af88d32a8e20da8774 to your computer and use it in GitHub Desktop.
Save MagnificentPako/5bac8a8163ff56af88d32a8e20da8774 to your computer and use it in GitHub Desktop.
import re
import sys
import os.path
def xor(data, key):
decoded = "U"
for i in range(1, len(data)):
decoded += chr(data[i] ^ key[(i-1) % len(key)])
return decoded
def mkKey(length):
return ([0xFF] * length) + ([0x00] * (length + 2))
pattern = re.compile("CAB-" + "\w" * 32)
assert len(sys.argv) == 2, ("Usage: python " + sys.argv[0] + " <input file>")
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:
with open("out.unity3d", "w") as handle:
handle.write(decoded)
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