diff --git a/Adobe_EPUB_Tools/ineptepub.pyw b/Adobe_EPUB_Tools/ineptepub.pyw index 14e51ff..f409686 100644 --- a/Adobe_EPUB_Tools/ineptepub.pyw +++ b/Adobe_EPUB_Tools/ineptepub.pyw @@ -1,6 +1,6 @@ #! /usr/bin/python -# ineptepub.pyw, version 2 +# ineptepub.pyw, version 3 # To run this program install Python 2.6 from http://www.python.org/download/ # and PyCrypto from http://www.voidspace.org.uk/python/modules.shtml#pycrypto @@ -10,6 +10,7 @@ # Revision history: # 1 - Initial release # 2 - Rename to INEPT, fix exit code +# 3 - Add cmd or gui choosing """ Decrypt Adobe ADEPT-encrypted EPUB books. @@ -62,7 +63,7 @@ class ASN1Parser(object): def __init__(self, bytes): self.bytes = bytes self.index = 0 - + def get(self, length): if self.index + length > len(self.bytes): raise ASN1Error("Error decoding ASN.1") @@ -72,22 +73,22 @@ class ASN1Parser(object): x |= self.bytes[self.index] self.index += 1 return x - + def getFixBytes(self, lengthBytes): bytes = self.bytes[self.index : self.index+lengthBytes] self.index += lengthBytes return bytes - + def getVarBytes(self, lengthLength): lengthBytes = self.get(lengthLength) return self.getFixBytes(lengthBytes) - + def getFixList(self, length, lengthList): l = [0] * lengthList for x in range(lengthList): l[x] = self.get(length) return l - + def getVarList(self, length, lengthLength): lengthList = self.get(lengthLength) if lengthList % length != 0: @@ -97,19 +98,19 @@ class ASN1Parser(object): for x in range(lengthList): l[x] = self.get(length) return l - + def startLengthCheck(self, lengthLength): self.lengthCheck = self.get(lengthLength) self.indexCheck = self.index - + def setLengthCheck(self, length): self.lengthCheck = length self.indexCheck = self.index - + def stopLengthCheck(self): if (self.index - self.indexCheck) != self.lengthCheck: raise ASN1Error("Error decoding ASN.1") - + def atLengthCheck(self): if (self.index - self.indexCheck) < self.lengthCheck: return False @@ -162,7 +163,7 @@ class Decryptor(object): path = elem.get('URI', None) if path is not None: encrypted.add(path) - + def decompress(self, bytes): dc = zlib.decompressobj(-15) bytes = dc.decompress(bytes) @@ -170,7 +171,7 @@ class Decryptor(object): if ex: bytes = bytes + ex return bytes - + def decrypt(self, path, data): if path in self._encrypted: data = self._aes.decrypt(data)[16:]