Created
March 13, 2019 20:16
-
-
Save MagnificentPako/f2225bcdbf00bea41a8d2fdcd80568e4 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) | |
if len(sys.argv) != 2: | |
print("Usage: python " + sys.argv[0] + " <input file>") | |
sys.exit() | |
if not os.path.isfile(sys.argv[1]): | |
print("Error: Input file doesn't exist.") | |
sys.exit() | |
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