]> xmof Git - DeDRM.git/commitdiff
ineptepub 3
authori♥cabbages <i♥cabbages@blogspot.co.uk>
Sat, 13 Feb 2010 22:15:36 +0000 (22:15 +0000)
committerApprentice Alf <apprenticealf@gmail.com>
Mon, 2 Mar 2015 18:06:42 +0000 (18:06 +0000)
Adobe_EPUB_Tools/ineptepub.pyw

index 14e51ff57c14091def8d9bf9aa775279e4c17f37..f4096867b2b2adf2f471b32fd6d93bf96cb4b22d 100644 (file)
@@ -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:]