Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -ur key-gen-original/gen.py key-gen/gen.py
- --- key-gen-original/gen.py
- +++ key-gen/gen.py
- @@ -7,4 +7,4 @@
- if len(argv)!=4:
- exit("Usage: "+argv[0]+" <ScopeID> <flags> <mask>")
- -print lec.key.encode(int(argv[1], 16), int(argv[2], 16), int(argv[3], 16))
- \ No newline at end of file
- +print(lec.key.encode(int(argv[1], 16), int(argv[2], 16), int(argv[3], 16)))
- diff -ur key-gen-original/lec/crypto.py key-gen/lec/crypto.py
- --- key-gen-original/lec/crypto.py
- +++ key-gen/lec/crypto.py
- @@ -1,27 +1,27 @@
- # educational use only
- -from Crypto.Cipher import Blowfish
- +from Cryptodome.Cipher import Blowfish
- from struct import pack, unpack
- -key_ct = "\205\023\064\027\154\014\026\116\230\076\141\360\373\253\252\267"
- +key_ct = b"\205\023\064\027\154\014\026\116\230\076\141\360\373\253\252\267"
- -key = ""
- +key = b""
- for c in key_ct[::-1]:
- - key += chr(ord(c)^116)
- + key += bytes((c^116,))
- cipher = Blowfish.new(key, Blowfish.MODE_ECB)
- # reverse byte order of two dwords
- def revd(blk):
- - return pack(">LL", *unpack("<LL", blk))
- + return pack(">LL", *unpack("<LL", blk))
- def decrypt(blk):
- - return revd(cipher.decrypt(revd(blk)))
- + return revd(cipher.decrypt(revd(blk)))
- def encrypt(blk):
- - return revd(cipher.encrypt(revd(blk)))
- + return revd(cipher.encrypt(revd(blk)))
- -__all__ = ["decrypt", "encrypt"]
- \ No newline at end of file
- +__all__ = ["decrypt", "encrypt"]
- diff -ur key-gen-original/lec/db.py key-gen/lec/db.py
- --- key-gen-original/lec/db.py
- +++ key-gen/lec/db.py
- @@ -1,12 +1,12 @@
- # educational use only
- -from crypto import decrypt
- +from .crypto import decrypt
- from struct import unpack
- -from cStringIO import StringIO
- +from io import BytesIO
- import os
- def fsize(hf):
- pos = hf.tell()
- - hf.seek(0, os.SEEK_END)
- + hf.seek(0, os.SEEK_END)
- size = hf.tell()
- hf.seek(pos)
- return size
- @@ -14,7 +14,7 @@
- def DecryptFile(hfi, hfo):
- size = fsize(hfi)
- - for i in xrange(0, size, 8):
- + for i in range(0, size, 8):
- hfo.write(decrypt(hfi.read(8)))
- ############################################################################
- @@ -31,13 +31,13 @@
- class LicReader(object):
- def __init__(self, fname):
- hfi = open(fname, "rb")
- - hfo = StringIO()
- + hfo = BytesIO()
- DecryptFile(hfi, hfo)
- hfi.close()
- plain_cfg = hfo.getvalue()
- hfo.close()
- - self.hf = StringIO(plain_cfg)
- + self.hf = BytesIO(plain_cfg)
- self.size = fsize(self.hf)
- self.nomore = False
- @@ -231,7 +231,7 @@
- def LoadGroup(reader, cls):
- num = reader.GetInt()
- group = dict()
- - for i in xrange(num):
- + for i in range(num):
- obj = cls(reader)
- group[obj.idx] = obj
- return group
- @@ -240,7 +240,7 @@
- def PrintGroup(grp):
- for idx in sorted(grp.keys()):
- - print grp[idx]
- + print(grp[idx])
- #############################################################################
- @@ -313,4 +313,4 @@
- # decrypt into str buf
- db = fromfile(argv[1])
- - PrintGroup(db.options)
- \ No newline at end of file
- + PrintGroup(db.options)
- Only in key-gen/lec: .db.py.swp
- diff -ur key-gen-original/lec/key.py key-gen/lec/key.py
- --- key-gen-original/lec/key.py
- +++ key-gen/lec/key.py
- @@ -1,5 +1,5 @@
- # educational use only
- -from crypto import encrypt, decrypt
- +from .crypto import encrypt, decrypt
- from binascii import hexlify, unhexlify
- from struct import pack, unpack
- @@ -25,7 +25,7 @@
- iid = (b0<<16) | (b1<<8) | b2
- pt = pack(">LL", (iid<<8)+flags, mask)
- - res = hexlify(encrypt(pt)).upper()
- + res = hexlify(encrypt(pt)).upper().decode('ASCII', 'ignore')
- return res[0:4]+"-"+res[4:8]+"-"+res[8:12]+"-"+res[12:16]
- -__all__ = ["decode", "encode"]
- \ No newline at end of file
- +__all__ = ["decode", "encode"]
- Only in key-gen/lec: __pycache__
- diff -ur key-gen-original/list.py key-gen/list.py
- --- key-gen-original/list.py
- +++ key-gen/list.py
- @@ -8,4 +8,4 @@
- db = lec.db.fromfile(argv[1])
- for idx in sorted(db.options.keys()):
- - print "%02X-%08X %-20s %s" % (idx>>32, idx & 0x0FFFFFFFF, db.options[idx].name, db.options[idx].description)
- \ No newline at end of file
- + print("%02X-%08X %-20s %s" % (idx>>32, idx & 0x0FFFFFFFF, db.options[idx].name, db.options[idx].description))
- diff -ur key-gen-original/validate.py key-gen/validate.py
- --- key-gen-original/validate.py
- +++ key-gen/validate.py
- @@ -8,18 +8,18 @@
- iid, flags, mask = lec.key.decode(argv[1])
- -print "ScopeID: %06X\nFlags:\t %02X\nMask:\t %08X" % (iid, flags, mask)
- +print ("ScopeID: %06X\nFlags:\t %02X\nMask:\t %08X" % (iid, flags, mask))
- if len(argv)==3:
- db = lec.db.fromfile(argv[2])
- - print "Options:"
- + print ("Options:")
- page = flags & 0x43
- for i in xrange(32):
- bmsk = 1<<i
- if mask & bmsk:
- idx = (page<<32) | bmsk
- - print "%02X-%08X" % (page, bmsk),
- + print ("%02X-%08X" % (page, bmsk),)
- if idx in db.options:
- - print "%-20s %s" % (db.options[idx].name, db.options[idx].description)
- + print ("%-20s %s" % (db.options[idx].name, db.options[idx].description))
- else:
- - print "Unknown option"
- \ No newline at end of file
- + print ("Unknown option")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement