if result == 0:
print("{0} v{1}: Decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,keyname,time.time()-self.starttime))
return self.checkFonts(of.name)
+ except ineptepub.ADEPTNewVersionError:
+ print("{0} v{1}: Book uses unsupported (too new) Adobe DRM.".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime))
+ return path_to_ebook
+
except:
print("{0} v{1}: Exception when decrypting after {2:.1f} seconds - trying other keys".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime))
traceback.print_exc()
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
try:
result = ineptepub.decryptBook(userkey, inf.name, of.name)
+ except ineptepub.ADEPTNewVersionError:
+ print("{0} v{1}: Book uses unsupported (too new) Adobe DRM.".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime))
+ return path_to_ebook
except:
print("{0} v{1}: Exception when decrypting after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime))
traceback.print_exc()
if result == 0:
print("{0} v{1}: Decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,keyname,time.time()-self.starttime))
return of.name
+
+ except ineptpdf.ADEPTNewVersionError:
+ print("{0} v{1}: Book uses unsupported (too new) Adobe DRM.".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime))
+ return path_to_ebook
except:
print("{0} v{1}: Exception when decrypting after {2:.1f} seconds - trying other keys".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime))
traceback.print_exc()
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
try:
result = ineptpdf.decryptBook(userkey, path_to_ebook, of.name)
+ except ineptpdf.ADEPTNewVersionError:
+ print("{0} v{1}: Book uses unsupported (too new) Adobe DRM.".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime))
+ return path_to_ebook
except:
print("{0} v{1}: Exception when decrypting after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime))
traceback.print_exc()
class ADEPTError(Exception):
pass
+class ADEPTNewVersionError(Exception):
+ pass
+
def _load_crypto_libcrypto():
from ctypes import CDLL, POINTER, c_void_p, c_char_p, c_int, c_long, \
Structure, c_ulong, create_string_buffer, cast
adept = lambda tag: '{%s}%s' % (NSMAP['adept'], tag)
expr = './/%s' % (adept('encryptedKey'),)
bookkey = ''.join(rights.findtext(expr))
+ if len(bookkey) == 192:
+ print("{0:s} seems to be an Adobe ADEPT ePub with Adobe's new DRM".format(os.path.basename(inpath)))
+ print("This DRM cannot be removed yet. ")
+ print("Try getting your distributor to give you a new ACSM file, then open that in an old version of ADE (2.0).")
+ print("If your book distributor is not enforcing the new DRM yet, this will give you a copy with the old DRM.")
+ raise ADEPTNewVersionError("Book uses new ADEPT encryption")
if len(bookkey) != 172:
print("{0:s} is not a secure Adobe Adept ePub.".format(os.path.basename(inpath)))
return 1
class ADEPTError(Exception):
pass
+class ADEPTNewVersionError(Exception):
+ pass
+
import hashlib
rights = zlib.decompress(rights, -15)
rights = etree.fromstring(rights)
expr = './/{http://ns.adobe.com/adept}encryptedKey'
- bookkey = codecs.decode(''.join(rights.findtext(expr)).encode('utf-8'),'base64')
+ bookkey = ''.join(rights.findtext(expr))
+
+ if len(bookkey) == 192:
+ print("This seems to be an Adobe ADEPT PDF with Adobe's new DRM")
+ print("This DRM cannot be removed yet. ")
+ print("Try getting your distributor to give you a new ACSM file, then open that in an old version of ADE (2.0).")
+ print("If your book distributor is not enforcing the new DRM yet, this will give you a copy with the old DRM.")
+ raise ADEPTNewVersionError("Book uses new ADEPT encryption")
+
+ bookkey = codecs.decode(bookkey.encode('utf-8'),'base64')
bookkey = rsa.decrypt(bookkey)
if len(bookkey) > 16: