-
-
Save RoadrunnerWMC/91b5429eca0112e856b6f1ce5e13011c to your computer and use it in GitHub Desktop.
Super Mario Run .stir file decrypter
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
# fun fact: | |
# this is internally referred to as 'SimpleEncryption' | |
# it is pretty damn simple, really | |
import sys | |
KEY = 0x5D | |
INITIAL_SPAN = 0x200 | |
SPAN = 0x100 | |
input_name = sys.argv[1] | |
if '.stir' in input_name: | |
output_name = input_name.replace('.stir', '') | |
else: | |
output_name = input_name + '_decrypted' | |
with open(input_name, 'rb') as f: | |
work = bytearray(f.read()) | |
first_block_size = min(INITIAL_SPAN, len(work)) | |
value = KEY | |
for i in range(first_block_size): | |
value ^= work[i] | |
work[i] = value | |
offset = first_block_size | |
while offset < len(work): | |
value ^= work[offset] | |
work[offset] = value | |
offset += SPAN | |
with open(output_name, 'wb') as f: | |
f.write(work) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment