|
|
@@ -0,0 +1,50 @@ |
|
|
#!/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' |
|
|
encrypted_data = stdin.readline() |
|
|
|
|
|
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") |
|
|
|
|
|
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) |