-
-
Save lab313ru/7aa894689d3d61db3089fd732eff305f to your computer and use it in GitHub Desktop.
Decrypt ca.bin, config.bin, stunnel.conf.bin, stunnel.pem.bin for YAS-109
This file contains 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.path | |
import sys | |
from Crypto.Cipher import ARC4 | |
INDICES = [3, 1, 10, 7, 5, 1] | |
ROWS = [ | |
[0xA3, 0x42, 0xB4, 0x9D, 0xAC, 0x60, 0xF4, 0x57, 0xAB, 0xE4, 0x12, 0x93, 0x82, 0x9F, 0x23, 0x10], | |
[0xEB, 0x39, 0x84, 0x89, 0x6D, 0xD7, 0x0B, 0xA3, 0x78, 0x76, 0x83, 0x93, 0x01, 0x01, 0x82, 0x73], | |
[0x4D, 0x01, 0x72, 0xF4, 0xD3, 0xF5, 0xA0, 0x1E, 0x68, 0x0E, 0xBA, 0x8A, 0x20, 0x10, 0x12, 0x32], | |
[0xF1, 0x30, 0x45, 0x95, 0x32, 0xA8, 0xF2, 0x87, 0x70, 0xC3, 0xDF, 0x9E, 0xAA, 0x11, 0x10, 0xA1], | |
[0xD1, 0x1C, 0x52, 0xA3, 0x31, 0xBD, 0x6C, 0x73, 0x81, 0xB6, 0xDF, 0xAD, 0x55, 0x55, 0xFF, 0xEE], | |
[0xB2, 0x40, 0x41, 0xDB, 0x02, 0x98, 0x92, 0x9C, 0x4B, 0x01, 0xFF, 0xFE, 0xA5, 0xA5, 0x3D, 0xF2] | |
] | |
def decrypt(key, buf): | |
rc4 = ARC4.new(key) | |
return rc4.decrypt(buf) | |
def prep_key(): | |
data_idx = 0 | |
edata = bytearray() | |
for i in range(len(INDICES)): | |
edata.extend(ROWS[i][data_idx:data_idx+i+1]) | |
data_idx = INDICES[len(INDICES) - i - 1] | |
return bytes(edata)[:16] | |
def main(path): | |
key = prep_key() | |
with open(path, 'rb') as f: | |
fn, _ = os.path.splitext(path) | |
dec = decrypt(key, f.read()) | |
with open(fn, 'wb') as w: | |
w.write(dec) | |
if __name__ == '__main__': | |
main(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment