Skip to content

Instantly share code, notes, and snippets.

@ilya-bystrov
Forked from ouroborus/fshack.py
Created June 2, 2021 13:41

Revisions

  1. @ouroborus ouroborus revised this gist Feb 22, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions fshack.py
    Original file line number Diff line number Diff line change
    @@ -12,8 +12,6 @@

    INITIALIZATION_VECTOR = b'tu89geji340t89u2'
    PASSWORD = b'UGxheWVy'
    encrypted_data = stdin.readline()

    KEY_SIZE = 32

    # Derive the key from our password and IV
    @@ -41,6 +39,7 @@ def encode(d):

    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
  2. @ouroborus ouroborus created this gist Feb 22, 2018.
    50 changes: 50 additions & 0 deletions fshack.py
    Original file line number Diff line number Diff line change
    @@ -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)