mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2026-04-22 01:18:56 +00:00
Compare commits
3 Commits
v10.0.3
...
9a11f480b5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a11f480b5 | ||
|
|
59839ae5c7 | ||
|
|
c15135b12f |
@@ -69,4 +69,6 @@ List of changes since the fork of Apprentice Harper's repository:
|
|||||||
|
|
||||||
## Fixes on master (not yet released):
|
## Fixes on master (not yet released):
|
||||||
|
|
||||||
- (None)
|
- Fix a bug introduced with #48 that breaks DeDRM'ing on Calibre 4 (fixes #101).
|
||||||
|
- Fix some more Calibre-6 bugs in the Obok plugin (should fix #114).
|
||||||
|
- Fix a bug where invalid Adobe keys could cause the plugin to stop trying subsequent keys (partially fixes #109).
|
||||||
@@ -511,10 +511,10 @@ class DeDRM(FileTypePlugin):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Found matching key
|
# Found matching key
|
||||||
userkey = codecs.decode(userkeyhex, 'hex')
|
|
||||||
print("{0} v{1}: Trying UUID-matched encryption key {2:s}".format(PLUGIN_NAME, PLUGIN_VERSION, keyname))
|
print("{0} v{1}: Trying UUID-matched encryption key {2:s}".format(PLUGIN_NAME, PLUGIN_VERSION, keyname))
|
||||||
of = self.temporary_file(".epub")
|
of = self.temporary_file(".epub")
|
||||||
try:
|
try:
|
||||||
|
userkey = codecs.decode(userkeyhex, 'hex')
|
||||||
result = ineptepub.decryptBook(userkey, inf.name, of.name)
|
result = ineptepub.decryptBook(userkey, inf.name, of.name)
|
||||||
of.close()
|
of.close()
|
||||||
if result == 0:
|
if result == 0:
|
||||||
@@ -531,12 +531,13 @@ class DeDRM(FileTypePlugin):
|
|||||||
|
|
||||||
# Attempt to decrypt epub with each encryption key (generated or provided).
|
# Attempt to decrypt epub with each encryption key (generated or provided).
|
||||||
for keyname, userkeyhex in dedrmprefs['adeptkeys'].items():
|
for keyname, userkeyhex in dedrmprefs['adeptkeys'].items():
|
||||||
userkey = codecs.decode(userkeyhex, 'hex')
|
|
||||||
print("{0} v{1}: Trying Encryption key {2:s}".format(PLUGIN_NAME, PLUGIN_VERSION, keyname))
|
print("{0} v{1}: Trying Encryption key {2:s}".format(PLUGIN_NAME, PLUGIN_VERSION, keyname))
|
||||||
of = self.temporary_file(".epub")
|
of = self.temporary_file(".epub")
|
||||||
|
|
||||||
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
|
# Give the user key, ebook and TemporaryPersistent file to the decryption function.
|
||||||
try:
|
try:
|
||||||
|
userkey = codecs.decode(userkeyhex, 'hex')
|
||||||
result = ineptepub.decryptBook(userkey, inf.name, of.name)
|
result = ineptepub.decryptBook(userkey, inf.name, of.name)
|
||||||
except ineptepub.ADEPTNewVersionError:
|
except ineptepub.ADEPTNewVersionError:
|
||||||
print("{0} v{1}: Book uses unsupported (too new) Adobe DRM.".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime))
|
print("{0} v{1}: Book uses unsupported (too new) Adobe DRM.".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime))
|
||||||
@@ -673,11 +674,11 @@ class DeDRM(FileTypePlugin):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Found matching key
|
# Found matching key
|
||||||
userkey = codecs.decode(userkeyhex, 'hex')
|
|
||||||
print("{0} v{1}: Trying UUID-matched encryption key {2:s}".format(PLUGIN_NAME, PLUGIN_VERSION, keyname))
|
print("{0} v{1}: Trying UUID-matched encryption key {2:s}".format(PLUGIN_NAME, PLUGIN_VERSION, keyname))
|
||||||
of = self.temporary_file(".pdf")
|
of = self.temporary_file(".pdf")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
userkey = codecs.decode(userkeyhex, 'hex')
|
||||||
result = ineptpdf.decryptBook(userkey, path_to_ebook, of.name)
|
result = ineptpdf.decryptBook(userkey, path_to_ebook, of.name)
|
||||||
of.close()
|
of.close()
|
||||||
if result == 0:
|
if result == 0:
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ def decryptBook(userkey, inpath, outpath):
|
|||||||
|
|
||||||
if len(bookkey) != 64:
|
if len(bookkey) != 64:
|
||||||
# Normal or "hardened" Adobe ADEPT
|
# Normal or "hardened" Adobe ADEPT
|
||||||
rsakey = RSA.import_key(userkey) # parses the ASN1 structure
|
rsakey = RSA.importKey(userkey) # parses the ASN1 structure
|
||||||
bookkey = base64.b64decode(bookkey)
|
bookkey = base64.b64decode(bookkey)
|
||||||
if int(keytype, 10) > 2:
|
if int(keytype, 10) > 2:
|
||||||
bookkey = removeHardening(rights, keytype, bookkey)
|
bookkey = removeHardening(rights, keytype, bookkey)
|
||||||
|
|||||||
@@ -1669,7 +1669,7 @@ class PDFDocument(object):
|
|||||||
|
|
||||||
def initialize_ebx_inept(self, password, docid, param):
|
def initialize_ebx_inept(self, password, docid, param):
|
||||||
self.is_printable = self.is_modifiable = self.is_extractable = True
|
self.is_printable = self.is_modifiable = self.is_extractable = True
|
||||||
rsakey = RSA.import_key(password) # parses the ASN1 structure
|
rsakey = RSA.importKey(password) # parses the ASN1 structure
|
||||||
length = int_value(param.get('Length', 0)) // 8
|
length = int_value(param.get('Length', 0)) // 8
|
||||||
rights = codecs.decode(param.get('ADEPT_LICENSE'), 'base64')
|
rights = codecs.decode(param.get('ADEPT_LICENSE'), 'base64')
|
||||||
rights = zlib.decompress(rights, -15)
|
rights = zlib.decompress(rights, -15)
|
||||||
|
|||||||
@@ -265,13 +265,13 @@ class ReadOnlyTableWidgetItem(QTableWidgetItem):
|
|||||||
def __init__(self, text):
|
def __init__(self, text):
|
||||||
if text is None:
|
if text is None:
|
||||||
text = ''
|
text = ''
|
||||||
QTableWidgetItem.__init__(self, text, QTableWidgetItem.UserType)
|
QTableWidgetItem.__init__(self, text, QTableWidgetItem.ItemType.UserType)
|
||||||
self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
|
self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
|
||||||
|
|
||||||
class RatingTableWidgetItem(QTableWidgetItem):
|
class RatingTableWidgetItem(QTableWidgetItem):
|
||||||
|
|
||||||
def __init__(self, rating, is_read_only=False):
|
def __init__(self, rating, is_read_only=False):
|
||||||
QTableWidgetItem.__init__(self, '', QTableWidgetItem.UserType)
|
QTableWidgetItem.__init__(self, '', QTableWidgetItem.ItemType.UserType)
|
||||||
self.setData(Qt.DisplayRole, rating)
|
self.setData(Qt.DisplayRole, rating)
|
||||||
if is_read_only:
|
if is_read_only:
|
||||||
self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
|
self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
|
||||||
@@ -284,11 +284,11 @@ class DateTableWidgetItem(QTableWidgetItem):
|
|||||||
if date_read is None or date_read == UNDEFINED_DATE and default_to_today:
|
if date_read is None or date_read == UNDEFINED_DATE and default_to_today:
|
||||||
date_read = now()
|
date_read = now()
|
||||||
if is_read_only:
|
if is_read_only:
|
||||||
QTableWidgetItem.__init__(self, format_date(date_read, fmt), QTableWidgetItem.UserType)
|
QTableWidgetItem.__init__(self, format_date(date_read, fmt), QTableWidgetItem.ItemType.UserType)
|
||||||
self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
|
self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
|
||||||
self.setData(Qt.DisplayRole, QDateTime(date_read))
|
self.setData(Qt.DisplayRole, QDateTime(date_read))
|
||||||
else:
|
else:
|
||||||
QTableWidgetItem.__init__(self, '', QTableWidgetItem.UserType)
|
QTableWidgetItem.__init__(self, '', QTableWidgetItem.ItemType.UserType)
|
||||||
self.setData(Qt.DisplayRole, QDateTime(date_read))
|
self.setData(Qt.DisplayRole, QDateTime(date_read))
|
||||||
|
|
||||||
from calibre.gui2.library.delegates import DateDelegate as _DateDelegate
|
from calibre.gui2.library.delegates import DateDelegate as _DateDelegate
|
||||||
|
|||||||
@@ -224,5 +224,5 @@ class ReadOnlyTableWidgetItem(QTableWidgetItem):
|
|||||||
def __init__(self, text):
|
def __init__(self, text):
|
||||||
if text is None:
|
if text is None:
|
||||||
text = ''
|
text = ''
|
||||||
QTableWidgetItem.__init__(self, text, QTableWidgetItem.UserType)
|
QTableWidgetItem.__init__(self, text, QTableWidgetItem.ItemType.UserType)
|
||||||
self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
|
self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
|
||||||
|
|||||||
Reference in New Issue
Block a user