Created
September 12, 2025 13:39
-
-
Save symbioquine/88e7148b4df143822f3b0d565619f80b 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 Crypto.Cipher.AES | |
| from Crypto.Cipher import AES | |
| from Crypto.Util.Padding import pad | |
| from glob import glob | |
| encrypted_firmware_files = glob('/path/to/*.prg') | |
| # Larger 50A - 100A units | |
| # 54726163 72414e43 0cdd527b 05c16b01 ff17cd6f 8c1e3e09 cf1f0c78 87ef8aec | |
| key = bytearray(b'\x54\x72\x61\x63\x72\x41\x4e\x43\x0c\xdd\x52\x7b\x05\xc1\x6b\x01\xff\x17\xcd\x6f\x8c\x1e\x3e\x09\xcf\x1f\x0c\x78\x87\xef\x8a\xec') | |
| # Smaller 10A - 40A units | |
| # 54726952 6f6e2eda 0cdd527b 05c16b01 ff17cd6f 8c1e3e09 cf1f0c78 87ef8aec | |
| key = bytearray(b'\x54\x72\x69\x52\x6f\x6e\x2e\xda\x0c\xdd\x52\x7b\x05\xc1\x6b\x01\xff\x17\xcd\x6f\x8c\x1e\x3e\x09\xcf\x1f\x0c\x78\x87\xef\x8a\xec') | |
| aes = AES.new(key, AES.MODE_CBC, iv=bytearray([0x00] * 16)) | |
| for encrypted_firmware_file in encrypted_firmware_files: | |
| with open(encrypted_firmware_file, 'rb') as rfp: | |
| encrypted_firmware_data = rfp.read() | |
| decrypted_firmware_data = aes.decrypt(pad(encrypted_firmware_data[18:], block_size=16, style="pkcs7")) | |
| with open(encrypted_firmware_file[:-4] + '.bin', 'wb') as fp: | |
| fp.write(decrypted_firmware_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment