Advertisement
Guest User

Untitled

a guest
Jan 18th, 2023
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. diff -ur key-gen-original/gen.py key-gen/gen.py
  2. --- key-gen-original/gen.py
  3. +++ key-gen/gen.py
  4. @@ -7,4 +7,4 @@
  5. if len(argv)!=4:
  6. exit("Usage: "+argv[0]+" <ScopeID> <flags> <mask>")
  7.  
  8. -print lec.key.encode(int(argv[1], 16), int(argv[2], 16), int(argv[3], 16))
  9. \ No newline at end of file
  10. +print(lec.key.encode(int(argv[1], 16), int(argv[2], 16), int(argv[3], 16)))
  11. diff -ur key-gen-original/lec/crypto.py key-gen/lec/crypto.py
  12. --- key-gen-original/lec/crypto.py
  13. +++ key-gen/lec/crypto.py
  14. @@ -1,27 +1,27 @@
  15. # educational use only
  16. -from Crypto.Cipher import Blowfish
  17. +from Cryptodome.Cipher import Blowfish
  18. from struct import pack, unpack
  19.  
  20. -key_ct = "\205\023\064\027\154\014\026\116\230\076\141\360\373\253\252\267"
  21. +key_ct = b"\205\023\064\027\154\014\026\116\230\076\141\360\373\253\252\267"
  22.  
  23. -key = ""
  24. +key = b""
  25. for c in key_ct[::-1]:
  26. - key += chr(ord(c)^116)
  27. + key += bytes((c^116,))
  28.  
  29. cipher = Blowfish.new(key, Blowfish.MODE_ECB)
  30.  
  31.  
  32. # reverse byte order of two dwords
  33. def revd(blk):
  34. - return pack(">LL", *unpack("<LL", blk))
  35. + return pack(">LL", *unpack("<LL", blk))
  36.  
  37.  
  38. def decrypt(blk):
  39. - return revd(cipher.decrypt(revd(blk)))
  40. + return revd(cipher.decrypt(revd(blk)))
  41.  
  42.  
  43. def encrypt(blk):
  44. - return revd(cipher.encrypt(revd(blk)))
  45. + return revd(cipher.encrypt(revd(blk)))
  46.  
  47.  
  48. -__all__ = ["decrypt", "encrypt"]
  49. \ No newline at end of file
  50. +__all__ = ["decrypt", "encrypt"]
  51. diff -ur key-gen-original/lec/db.py key-gen/lec/db.py
  52. --- key-gen-original/lec/db.py
  53. +++ key-gen/lec/db.py
  54. @@ -1,12 +1,12 @@
  55. # educational use only
  56. -from crypto import decrypt
  57. +from .crypto import decrypt
  58. from struct import unpack
  59. -from cStringIO import StringIO
  60. +from io import BytesIO
  61. import os
  62.  
  63. def fsize(hf):
  64. pos = hf.tell()
  65. - hf.seek(0, os.SEEK_END)
  66. + hf.seek(0, os.SEEK_END)
  67. size = hf.tell()
  68. hf.seek(pos)
  69. return size
  70. @@ -14,7 +14,7 @@
  71.  
  72. def DecryptFile(hfi, hfo):
  73. size = fsize(hfi)
  74. - for i in xrange(0, size, 8):
  75. + for i in range(0, size, 8):
  76. hfo.write(decrypt(hfi.read(8)))
  77.  
  78. ############################################################################
  79. @@ -31,13 +31,13 @@
  80. class LicReader(object):
  81. def __init__(self, fname):
  82. hfi = open(fname, "rb")
  83. - hfo = StringIO()
  84. + hfo = BytesIO()
  85. DecryptFile(hfi, hfo)
  86. hfi.close()
  87. plain_cfg = hfo.getvalue()
  88. hfo.close()
  89.  
  90. - self.hf = StringIO(plain_cfg)
  91. + self.hf = BytesIO(plain_cfg)
  92. self.size = fsize(self.hf)
  93. self.nomore = False
  94.  
  95. @@ -231,7 +231,7 @@
  96. def LoadGroup(reader, cls):
  97. num = reader.GetInt()
  98. group = dict()
  99. - for i in xrange(num):
  100. + for i in range(num):
  101. obj = cls(reader)
  102. group[obj.idx] = obj
  103. return group
  104. @@ -240,7 +240,7 @@
  105.  
  106. def PrintGroup(grp):
  107. for idx in sorted(grp.keys()):
  108. - print grp[idx]
  109. + print(grp[idx])
  110.  
  111. #############################################################################
  112.  
  113. @@ -313,4 +313,4 @@
  114. # decrypt into str buf
  115. db = fromfile(argv[1])
  116.  
  117. - PrintGroup(db.options)
  118. \ No newline at end of file
  119. + PrintGroup(db.options)
  120. Only in key-gen/lec: .db.py.swp
  121. diff -ur key-gen-original/lec/key.py key-gen/lec/key.py
  122. --- key-gen-original/lec/key.py
  123. +++ key-gen/lec/key.py
  124. @@ -1,5 +1,5 @@
  125. # educational use only
  126. -from crypto import encrypt, decrypt
  127. +from .crypto import encrypt, decrypt
  128. from binascii import hexlify, unhexlify
  129. from struct import pack, unpack
  130.  
  131. @@ -25,7 +25,7 @@
  132. iid = (b0<<16) | (b1<<8) | b2
  133.  
  134. pt = pack(">LL", (iid<<8)+flags, mask)
  135. - res = hexlify(encrypt(pt)).upper()
  136. + res = hexlify(encrypt(pt)).upper().decode('ASCII', 'ignore')
  137. return res[0:4]+"-"+res[4:8]+"-"+res[8:12]+"-"+res[12:16]
  138.  
  139. -__all__ = ["decode", "encode"]
  140. \ No newline at end of file
  141. +__all__ = ["decode", "encode"]
  142. Only in key-gen/lec: __pycache__
  143. diff -ur key-gen-original/list.py key-gen/list.py
  144. --- key-gen-original/list.py
  145. +++ key-gen/list.py
  146. @@ -8,4 +8,4 @@
  147. db = lec.db.fromfile(argv[1])
  148.  
  149. for idx in sorted(db.options.keys()):
  150. - print "%02X-%08X %-20s %s" % (idx>>32, idx & 0x0FFFFFFFF, db.options[idx].name, db.options[idx].description)
  151. \ No newline at end of file
  152. + print("%02X-%08X %-20s %s" % (idx>>32, idx & 0x0FFFFFFFF, db.options[idx].name, db.options[idx].description))
  153. diff -ur key-gen-original/validate.py key-gen/validate.py
  154. --- key-gen-original/validate.py
  155. +++ key-gen/validate.py
  156. @@ -8,18 +8,18 @@
  157.  
  158.  
  159. iid, flags, mask = lec.key.decode(argv[1])
  160. -print "ScopeID: %06X\nFlags:\t %02X\nMask:\t %08X" % (iid, flags, mask)
  161. +print ("ScopeID: %06X\nFlags:\t %02X\nMask:\t %08X" % (iid, flags, mask))
  162.  
  163. if len(argv)==3:
  164. db = lec.db.fromfile(argv[2])
  165. - print "Options:"
  166. + print ("Options:")
  167. page = flags & 0x43
  168. for i in xrange(32):
  169. bmsk = 1<<i
  170. if mask & bmsk:
  171. idx = (page<<32) | bmsk
  172. - print "%02X-%08X" % (page, bmsk),
  173. + print ("%02X-%08X" % (page, bmsk),)
  174. if idx in db.options:
  175. - print "%-20s %s" % (db.options[idx].name, db.options[idx].description)
  176. + print ("%-20s %s" % (db.options[idx].name, db.options[idx].description))
  177. else:
  178. - print "Unknown option"
  179. \ No newline at end of file
  180. + print ("Unknown option")
  181.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement