from struct import unpack as up, pack as pk from binascii import unhexlify as uhx, hexlify as hx from Crypto.Cipher import AES from Crypto.Util import Counter import sys pk11key = uhx('') # Insert key here. def string_to_ctr(ctr): return Counter.new(128, initial_value=int(hx(ctr), 16)) def main(argc, argv): if argc == 2: out_fn = '%s.dec' % argv[1] elif argc == 3: out_fn = argv[2] else: print 'Usage: %s package1 out_fn' % argv[0] sys.exit(1) try: with open(argv[1], 'rb') as f: pk11 = f.read() except IOError: print 'Failed to read %s!' % argv[1] sys.exit(1) sz, padding, ctr = up('