Created
May 5, 2019 20:45
-
-
Save Andoryuuta/7e5c26f9d19ea10d18937f938286ecfa to your computer and use it in GitHub Desktop.
This file contains 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 sys | |
import os | |
# Check if we have an argument. | |
if(len(sys.argv) <= 1): | |
print('Usage: {} file.dyn'.format(sys.argv[0])) | |
sys.exit(1) | |
# File names | |
input_filename = sys.argv[1] | |
output_filename = os.path.splitext(input_filename)[0] + '.zip' | |
# XOR key and shuffle index arrays for decryption. | |
CHUNK_SIZE = 8 | |
key = bytearray([(0x8D + i) for i in range(CHUNK_SIZE)]) | |
indices = [5, 3, 6, 7, 4, 2, 0, 1] | |
# Decrypt... | |
with open(input_filename, 'rb') as input_file, open(output_filename, 'wb') as output_file: | |
while True: | |
# Read in a chunk of raw data | |
chunk = input_file.read(CHUNK_SIZE) | |
if not chunk: | |
break | |
# Need a full 8-byte chunk to decrypt. | |
if(len(chunk) == CHUNK_SIZE): | |
output = bytearray(CHUNK_SIZE) | |
# Decrypt the chunk. | |
for i in range(CHUNK_SIZE): | |
output[i] = chunk[indices[i]] ^ key[i] | |
else: | |
output = chunk | |
output_file.write(output) | |
print('Done.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment