Skip to content

Instantly share code, notes, and snippets.

@ilya-bystrov
Forked from ouroborus/fshack.py
Created June 2, 2021 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilya-bystrov/6d2a6cc89b9ad8f307974db2079e24d8 to your computer and use it in GitHub Desktop.
Save ilya-bystrov/6d2a6cc89b9ad8f307974db2079e24d8 to your computer and use it in GitHub Desktop.
Decrypt/Encrypt Fallout Shelter save files
#!/usr/bin/python
from __future__ import print_function,division
from Crypto.Protocol.KDF import PBKDF2
from Crypto.Cipher import AES
from base64 import decodestring,encodestring
from sys import stdout,stdin
from json import loads,dumps
from math import ceil
# fshack.py <Vault1.sav >Vault2.sav
# cp Vault2.sav Vault2.sav.bpk
INITIALIZATION_VECTOR = b'tu89geji340t89u2'
PASSWORD = b'UGxheWVy'
KEY_SIZE = 32
# Derive the key from our password and IV
key = PBKDF2(PASSWORD, INITIALIZATION_VECTOR, KEY_SIZE)
def decode(s):
# Use AES in Block cipher mode with our key and IV
aes = AES.new(key, AES.MODE_CBC, INITIALIZATION_VECTOR)
message = decodestring(encrypted_data)
decrypted_data = aes.decrypt(message)
decrypted_data = decrypted_data[:decrypted_data.rindex("}")+1]
return loads(decrypted_data)
def encode(d):
aes = AES.new(key, AES.MODE_CBC, INITIALIZATION_VECTOR)
message = dumps(d, separators=(',',':'))
pad = int(ceil(len(message)/16))*16-len(message)
pad = chr(pad) * pad
message += pad
encrypted_data = aes.encrypt(message)
return encodestring(encrypted_data).translate(None,"\n")
encrypted_data = stdin.readline()
decrypted_data = decode(encrypted_data)
#decrypted_data["vault"]["storage"]["resources"]["Nuka"] = 999999.00 # caps
decrypted_data["vault"]["storage"]["resources"]["NukaColaQuantum"] = 9999.00
encrypted_data = encode(decrypted_data)
stdout.write(encrypted_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment