Skip to content

Commit d05594d

Browse files
committed
Update to v10.0.2
1 parent 09a34cf commit d05594d

File tree

4 files changed

+75
-24
lines changed

4 files changed

+75
-24
lines changed

CHANGELOG.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
List of changes since the fork of Apprentice Harper's repository:
44

5+
## Fixes in v10.0.0 (2021-11-17):
6+
57
- CI testing / linting removed as that always failed anyways. The CI now "just" packages the plugin.
68
- Support for the Readium LCP DRM (also known as "CARE DRM" or "TEA DRM"). This supports EPUB and PDF files. It does not yet support Readium LCPDF/LPF/LCPA/LCPAU/LCPDI files, as I don't have access to any of these. If you have an LCP-protected file in one of these formats that this plugin does not work with, please open [an issue](https://github.com/noDRM/DeDRM_tools/issues) and attach the file to the report.
79
- Add new Github issue report form which forces the user to include stuff like their Calibre version to hopefully increase the quality of bug reports.
@@ -20,4 +22,15 @@ List of changes since the fork of Apprentice Harper's repository:
2022
- Add a more verbose error message when trying to remove DRM from a book with the new, not-yet-cracked version of the Adobe ADEPT DRM.
2123
- Added back support for Python2 (Calibre 2.0+). Only tested with ADEPT (PDF & EPUB) and Readium LCP so far, please open an issue if there's errors with other book types.
2224
- Begin work on removing some kinds of watermarks from files after DRM removal. This isn't tested a lot, and is disabled by default. You can enable it in the plugin settings.
23-
- If you're using the [ACSM Input Plugin / DeACSM](https://www.mobileread.com/forums/showthread.php?t=341975), the encryption key will automatically be extracted from that plugin if necessary.
25+
- If you're using the [ACSM Input Plugin / DeACSM](https://www.mobileread.com/forums/showthread.php?t=341975), the encryption key will automatically be extracted from that plugin if necessary.
26+
27+
## Fixes in v10.0.1 (2021-11-19):
28+
29+
- Hotfix update to fix broken EPUB DRM removal due to a typo.
30+
31+
## Fixes in v10.0.2 (2021-11-29):
32+
33+
- Fix Kindle for Mac key retrieval (merged [apprenticeharper/DeDRM_tools#1936](https://github.com/apprenticeharper/DeDRM_tools/pull/1936) ), fixing #1.
34+
- Fix Adobe key retrieval in case the username has been changed (merged [apprenticeharper/DeDRM_tools#1946](https://github.com/apprenticeharper/DeDRM_tools/pull/1946) ). This should fix the error "failed to decrypt user key key".
35+
- Fix small issue with elibri watermark removal.
36+
- Adobe key name will now contain account email.

DeDRM_plugin/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Copyright © 2021 NoDRM
77

88
__license__ = 'GPL v3'
9-
__version__ = '10.0.1'
9+
__version__ = '10.0.2'
1010
__docformat__ = 'restructuredtext en'
1111

1212

@@ -80,6 +80,7 @@
8080
# 7.2.1 - Whitespace!
8181
# 10.0.0 - First forked version by NoDRM. See CHANGELOG.md for details.
8282
# 10.0.1 - Fixes a bug in the watermark code.
83+
# 10.0.2 - Fix Kindle for Mac & update Adobe key retrieval
8384

8485
"""
8586
Decrypt DRMed ebooks.

DeDRM_plugin/adobekey.py

+58-21
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
# adobekey.pyw, version 6.0
5-
# Copyright © 2009-2020 i♥cabbages, Apprentice Harper et al.
4+
# adobekey.pyw, version 7.1
5+
# Copyright © 2009-2021 i♥cabbages, Apprentice Harper et al.
66

77
# Released under the terms of the GNU General Public Licence, version 3
88
# <http://www.gnu.org/licenses/>
@@ -29,13 +29,14 @@
2929
# 5.9 - moved unicode_argv call inside main for Windows DeDRM compatibility
3030
# 6.0 - Work if TkInter is missing
3131
# 7.0 - Python 3 for calibre 5
32+
# 7.1 - Fix "failed to decrypt user key key" error (read username from registry)
3233

3334
"""
3435
Retrieve Adobe ADEPT user key.
3536
"""
3637

3738
__license__ = 'GPL v3'
38-
__version__ = '7.0'
39+
__version__ = '7.1'
3940

4041
import sys, os, struct, getopt
4142
from base64 import b64decode
@@ -288,8 +289,13 @@ def __call__(self, *args):
288289

289290
def __del__(self):
290291
if self._buf is not None:
291-
VirtualFree(self._buf)
292-
self._buf = None
292+
try:
293+
VirtualFree(self._buf)
294+
self._buf = None
295+
except TypeError:
296+
# Apparently this sometimes gets cleared on application exit
297+
# Causes a useless exception in the log, so let's just catch and ignore that.
298+
pass
293299

294300
if struct.calcsize("P") == 4:
295301
CPUID0_INSNS = (
@@ -400,25 +406,40 @@ def adeptkeys():
400406
ktype = winreg.QueryValueEx(plkparent, None)[0]
401407
if ktype != 'credentials':
402408
continue
403-
uuid_name = "Unknown"
409+
uuid_name = ""
404410
for j in range(0, 16):
405411
try:
406412
plkkey = winreg.OpenKey(plkparent, "%04d" % (j,))
407413
except WindowsError:
408414
break
409415
ktype = winreg.QueryValueEx(plkkey, None)[0]
410416
if ktype == 'user':
411-
uuid_name = winreg.QueryValueEx(plkkey, 'value')[0]
412-
if ktype != 'privateLicenseKey':
413-
continue
414-
userkey = winreg.QueryValueEx(plkkey, 'value')[0]
415-
userkey = b64decode(userkey)
416-
aes = AES(keykey)
417-
userkey = aes.decrypt(userkey)
418-
userkey = userkey[26:-ord(userkey[-1:])]
419-
# print ("found " + uuid_name + " key: " + str(userkey))
420-
keys.append(userkey)
421-
names.append(uuid_name[9:])
417+
# Add Adobe UUID to key name
418+
uuid_name = uuid_name + winreg.QueryValueEx(plkkey, 'value')[0][9:] + "_"
419+
if ktype == 'username':
420+
# Add account type & email to key name, if present
421+
try:
422+
uuid_name = uuid_name + winreg.QueryValueEx(plkkey, 'method')[0] + "_"
423+
except:
424+
pass
425+
try:
426+
uuid_name = uuid_name + winreg.QueryValueEx(plkkey, 'value')[0] + "_"
427+
except:
428+
pass
429+
if ktype == 'privateLicenseKey':
430+
userkey = winreg.QueryValueEx(plkkey, 'value')[0]
431+
userkey = b64decode(userkey)
432+
aes = AES(keykey)
433+
userkey = aes.decrypt(userkey)
434+
userkey = userkey[26:-ord(userkey[-1:])]
435+
# print ("found " + uuid_name + " key: " + str(userkey))
436+
keys.append(userkey)
437+
438+
if uuid_name == "":
439+
names.append("Unknown")
440+
else:
441+
names.append(uuid_name[:-1])
442+
422443
if len(keys) == 0:
423444
raise ADEPTError('Could not locate privateLicenseKey')
424445
print("Found {0:d} keys".format(len(keys)))
@@ -461,16 +482,32 @@ def adeptkeys():
461482
tree = etree.parse(actpath)
462483
adept = lambda tag: '{%s}%s' % (NSMAP['adept'], tag)
463484
expr = '//%s/%s' % (adept('credentials'), adept('privateLicenseKey'))
464-
exprUUID = '//%s/%s' % (adept('credentials'), adept('user'))
465485
userkey = tree.findtext(expr)
466-
userUUID = "Unknown"
486+
487+
exprUUID = '//%s/%s' % (adept('credentials'), adept('user'))
488+
keyName = ""
467489
try:
468-
userUUID = tree.findtext(exprUUID)
490+
keyName = tree.findtext(exprUUID)[9:] + "_"
469491
except:
470492
pass
493+
494+
try:
495+
exprMail = '//%s/%s' % (adept('credentials'), adept('username'))
496+
keyName = keyName + tree.find(exprMail).attrib["method"] + "_"
497+
keyName = keyName + tree.findtext(exprMail) + "_"
498+
except:
499+
pass
500+
501+
if keyName == "":
502+
keyName = "Unknown"
503+
else:
504+
keyName = keyName[:-1]
505+
506+
507+
471508
userkey = b64decode(userkey)
472509
userkey = userkey[26:]
473-
return [userkey], [userUUID[9:]]
510+
return [userkey], [keyName]
474511

475512
else:
476513
def adeptkeys():

DeDRM_plugin/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ def __init__(self, parent=None,):
832832
key_group = QHBoxLayout()
833833
data_group_box_layout.addLayout(key_group)
834834
key_group.addWidget(QLabel("Unique Key Name:", self))
835-
self.key_ledit = QLineEdit(self.default_name_A, self)
835+
self.key_ledit = QLineEdit("default_ade_key_uuid_" + self.default_name_A, self)
836836
self.key_ledit.setToolTip("<p>Enter an identifying name for the current Adobe key. Note that it's recommended to leave the UUID (the random-looking digits and letters) as it is.")
837837
key_group.addWidget(self.key_ledit)
838838

0 commit comments

Comments
 (0)