Created
March 13, 2019 20:22
-
-
Save MagnificentPako/482612845b16f52b6d6e58bf07b0ea3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
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: | |
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