Skip to content

Instantly share code, notes, and snippets.

@Treeki
Created December 29, 2016 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Treeki/b26c3668014cb408ce092243e7eeed33 to your computer and use it in GitHub Desktop.
Save Treeki/b26c3668014cb408ce092243e7eeed33 to your computer and use it in GitHub Desktop.
Super Mario Run .stir file decrypter
# 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)
@Supurreme
Copy link

im trying to use this script but whenever i attempt to run it i get this error:
File "C:\Users\Mimi\Documents\AssetBundle\AssetBundle\unstir.py", line 10, in
input_name = sys.argv[1]
IndexError: list index out of range

@LolHacksRule
Copy link

LolHacksRule commented Dec 30, 2018

Do py/python unstir.py STIRCOMPRESSSEDFILE.unity3d. What file(s) have this problem?

Copy link

ghost commented Jul 10, 2019

How to run this script on multiple files at same time?

@LolHacksRule
Copy link

LolHacksRule commented Oct 16, 2021

Late but forfiles /s /m *.unity3d /C "cmd /c python unstir.py @file can help you decrypt multiple on Windows.

*edit to fix errors with encoding

Copy link

ghost commented Oct 17, 2021

Late but forfiles /s /m *.unity3d /c "python \"decstir.py\" @file can help you decrypt multiple on Windows.

Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment