mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2024-11-16 19:06:09 +06:00
ineptepub 3
This commit is contained in:
parent
9c73801685
commit
e9a7312759
|
@ -1,6 +1,6 @@
|
||||||
#! /usr/bin/python
|
#! /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/
|
# 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
|
# and PyCrypto from http://www.voidspace.org.uk/python/modules.shtml#pycrypto
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
# Revision history:
|
# Revision history:
|
||||||
# 1 - Initial release
|
# 1 - Initial release
|
||||||
# 2 - Rename to INEPT, fix exit code
|
# 2 - Rename to INEPT, fix exit code
|
||||||
|
# 3 - Add cmd or gui choosing
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Decrypt Adobe ADEPT-encrypted EPUB books.
|
Decrypt Adobe ADEPT-encrypted EPUB books.
|
||||||
|
@ -62,7 +63,7 @@ class ASN1Parser(object):
|
||||||
def __init__(self, bytes):
|
def __init__(self, bytes):
|
||||||
self.bytes = bytes
|
self.bytes = bytes
|
||||||
self.index = 0
|
self.index = 0
|
||||||
|
|
||||||
def get(self, length):
|
def get(self, length):
|
||||||
if self.index + length > len(self.bytes):
|
if self.index + length > len(self.bytes):
|
||||||
raise ASN1Error("Error decoding ASN.1")
|
raise ASN1Error("Error decoding ASN.1")
|
||||||
|
@ -72,22 +73,22 @@ class ASN1Parser(object):
|
||||||
x |= self.bytes[self.index]
|
x |= self.bytes[self.index]
|
||||||
self.index += 1
|
self.index += 1
|
||||||
return x
|
return x
|
||||||
|
|
||||||
def getFixBytes(self, lengthBytes):
|
def getFixBytes(self, lengthBytes):
|
||||||
bytes = self.bytes[self.index : self.index+lengthBytes]
|
bytes = self.bytes[self.index : self.index+lengthBytes]
|
||||||
self.index += lengthBytes
|
self.index += lengthBytes
|
||||||
return bytes
|
return bytes
|
||||||
|
|
||||||
def getVarBytes(self, lengthLength):
|
def getVarBytes(self, lengthLength):
|
||||||
lengthBytes = self.get(lengthLength)
|
lengthBytes = self.get(lengthLength)
|
||||||
return self.getFixBytes(lengthBytes)
|
return self.getFixBytes(lengthBytes)
|
||||||
|
|
||||||
def getFixList(self, length, lengthList):
|
def getFixList(self, length, lengthList):
|
||||||
l = [0] * lengthList
|
l = [0] * lengthList
|
||||||
for x in range(lengthList):
|
for x in range(lengthList):
|
||||||
l[x] = self.get(length)
|
l[x] = self.get(length)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
def getVarList(self, length, lengthLength):
|
def getVarList(self, length, lengthLength):
|
||||||
lengthList = self.get(lengthLength)
|
lengthList = self.get(lengthLength)
|
||||||
if lengthList % length != 0:
|
if lengthList % length != 0:
|
||||||
|
@ -97,19 +98,19 @@ class ASN1Parser(object):
|
||||||
for x in range(lengthList):
|
for x in range(lengthList):
|
||||||
l[x] = self.get(length)
|
l[x] = self.get(length)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
def startLengthCheck(self, lengthLength):
|
def startLengthCheck(self, lengthLength):
|
||||||
self.lengthCheck = self.get(lengthLength)
|
self.lengthCheck = self.get(lengthLength)
|
||||||
self.indexCheck = self.index
|
self.indexCheck = self.index
|
||||||
|
|
||||||
def setLengthCheck(self, length):
|
def setLengthCheck(self, length):
|
||||||
self.lengthCheck = length
|
self.lengthCheck = length
|
||||||
self.indexCheck = self.index
|
self.indexCheck = self.index
|
||||||
|
|
||||||
def stopLengthCheck(self):
|
def stopLengthCheck(self):
|
||||||
if (self.index - self.indexCheck) != self.lengthCheck:
|
if (self.index - self.indexCheck) != self.lengthCheck:
|
||||||
raise ASN1Error("Error decoding ASN.1")
|
raise ASN1Error("Error decoding ASN.1")
|
||||||
|
|
||||||
def atLengthCheck(self):
|
def atLengthCheck(self):
|
||||||
if (self.index - self.indexCheck) < self.lengthCheck:
|
if (self.index - self.indexCheck) < self.lengthCheck:
|
||||||
return False
|
return False
|
||||||
|
@ -162,7 +163,7 @@ class Decryptor(object):
|
||||||
path = elem.get('URI', None)
|
path = elem.get('URI', None)
|
||||||
if path is not None:
|
if path is not None:
|
||||||
encrypted.add(path)
|
encrypted.add(path)
|
||||||
|
|
||||||
def decompress(self, bytes):
|
def decompress(self, bytes):
|
||||||
dc = zlib.decompressobj(-15)
|
dc = zlib.decompressobj(-15)
|
||||||
bytes = dc.decompress(bytes)
|
bytes = dc.decompress(bytes)
|
||||||
|
@ -170,7 +171,7 @@ class Decryptor(object):
|
||||||
if ex:
|
if ex:
|
||||||
bytes = bytes + ex
|
bytes = bytes + ex
|
||||||
return bytes
|
return bytes
|
||||||
|
|
||||||
def decrypt(self, path, data):
|
def decrypt(self, path, data):
|
||||||
if path in self._encrypted:
|
if path in self._encrypted:
|
||||||
data = self._aes.decrypt(data)[16:]
|
data = self._aes.decrypt(data)[16:]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user