Created
October 26, 2019 23:17
-
-
Save adrianosela/a19ac0e09269f2f75773a1acce9444ef to your computer and use it in GitHub Desktop.
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
import os | |
import sys | |
import hashlib | |
import binascii | |
def change_pw(path, hash, password): | |
# build hash for new password | |
new_pw_hash = hashlib.sha1(password.encode()) | |
# read program file bytes | |
s = open(path, 'rb').read() | |
# replace old hash with new hash in file bytes | |
s = s.replace(binascii.unhexlify(hash), binascii.unhexlify(new_pw_hash.hexdigest())) | |
# write the bytes to a new file | |
f = open(path + ".patched", 'wb') | |
f.write(s) | |
path = sys.argv[1] | |
pw_hash = sys.argv[2] | |
new_pw = sys.argv[3] | |
change_pw(path, pw_hash, new_pw) | |
print("program patched!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment