noDRM / DeDRM_tools

DeDRM tools for ebooks
7.24k stars 323 forks source link

adobekey.ADEPTError: Failed to decrypt user key key (sic) #307

Open rectalogic opened 1 year ago

rectalogic commented 1 year ago

Question / bug report

DeDRM fails to decrypt ADE key. I also tried reinstalling on a different machine, and authorizing ADE on that machine but it still fails. The log is from opening Calibre and going to DeDRM preferences and choosing "Adobe Digital Editions ebooks" - it fails to load the key.

Which version of Calibre are you running?

6.14.1

Which version of the DeDRM plugin are you running?

v10.0.3

If applicable, which version of the Kindle software are you running?

No response

Log output

ApplicationPaletteChange event ignored
Using calibre Qt style: True
ApplicationPaletteChange event received
calibre Debug log
calibre 6.14.1  embedded-python: True
Windows-10-10.0.22621-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.22621')
Python 3.10.1
Windows: ('10', '10.0.22621', 'SP0', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: DeDRM (10, 0, 3)
calibre 6.14.1  embedded-python: True
Windows-10-10.0.22621-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.22621')
Python 3.10.1
Windows: ('10', '10.0.22621', 'SP0', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: DeDRM (10, 0, 3)
QPA platform: windows
devicePixelRatio: 1.0
logicalDpi: 96.0 x 96.0
physicalDpi: 96.07011070110701 x 96.09458128078816
[0.00] Starting up...
[0.00] Showing splash screen...
[0.17] splash screen shown
[0.17] Initializing db...
[0.17] db initialized
[0.17] Constructing main UI...
[0.64] main UI initialized...
[0.64] Hiding splash screen
Starting QuickView
Traceback (most recent call last):
  File "C:\Users\aw\AppData\Roaming\calibre\plugins\DeDRM.zip\config.py", line 1158, in __init__
  File "C:\Users\aw\AppData\Roaming\calibre\plugins\DeDRM.zip\adobekey.py", line 347, in adeptkeys
  File "C:\Users\aw\AppData\Roaming\calibre\plugins\DeDRM.zip\adobekey.py", line 327, in CryptUnprotectData
adobekey.ADEPTError: Failed to decrypt user key key (sic)
Traceback (most recent call last):
  File "C:\Users\aw\AppData\Roaming\calibre\plugins\DeDRM.zip\config.py", line 1158, in __init__
  File "C:\Users\aw\AppData\Roaming\calibre\plugins\DeDRM.zip\adobekey.py", line 347, in adeptkeys
  File "C:\Users\aw\AppData\Roaming\calibre\plugins\DeDRM.zip\adobekey.py", line 327, in CryptUnprotectData
adobekey.ADEPTError: Failed to decrypt user key key (sic)
ElleKayEm commented 1 year ago

What about adding an Adobe DRM book to calibre and letting DeDRM automatically retrieve the key?

rectalogic commented 1 year ago

The book appears to import ok, but when I view it is still encrypted garbage. It gets the same Failed to decrypt user key when importing - that's why I tried to reproduce it by just configuring the plugin - the simplest way to reproduce the error.

Starting QuickView
DeDRM v10.0.3: Trying to decrypt xxx.epub
DeDRM v10.0.3: Verifying zip archive integrity
DeDRM v10.0.3: xxx.epub is a secure Adobe Adept ePub for UUID 645df698-e402-47ca-954e-8485a2b856be
DeDRM v10.0.3: Looking for new default Adobe Digital Editions Keys after 0.1 seconds
DeDRM v10.0.3: Exception when getting default Adobe Key after 0.1 seconds
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 591, in ePubDecrypt
  File "C:\Users\aw\AppData\Roaming\calibre\plugins\DeDRM.zip\adobekey.py", line 347, in adeptkeys
  File "C:\Users\aw\AppData\Roaming\calibre\plugins\DeDRM.zip\adobekey.py", line 327, in CryptUnprotectData
adobekey.ADEPTError: Failed to decrypt user key key (sic)
DeDRM v10.0.3: Ultimately failed to decrypt after 0.3 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "calibre\customize\ui.py", line 187, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 1067, in run
  File "calibre_plugins.dedrm.__init__", line 665, in ePubDecrypt
calibre_plugins.dedrm.DeDRMError: DeDRM v10.0.3: Ultimately failed to decrypt after 0.3 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
[3.12] splash screen hidden

Is there a way to run the plugin directly to get more info on what's going wrong - e.g. & 'C:\Program Files\Calibre2\calibre-debug.exe' -r DeDRM passhash ???

ElleKayEm commented 1 year ago

Are you using ADE to download the book? Is it installed on the same machine and user as calibre?

rectalogic commented 1 year ago

Yes I used ADE and it's same machine/user and the book is viewable in ADE.

I set a breakpoint in adobekey.py and running 'C:\Program Files\Calibre2\calibre-debug.exe' -e "C:\Users\aw\Desktop\DeDRM_plugin\adobekey.py" -- mykey

I can see it finds my username and the binary key, but fails to decrypt it.

I'm running Windows 11 ARM in a UTM virtual machine, so maybe UTM broke something - this used to work though, but perhaps some UTM upgrade incompatibility.

ElleKayEm commented 1 year ago

Do you still have a previous working setup? If you used the same Adobe ID, you could import the key from there. I've seen at least one case where a Windows 11 user was having issues, but I would have thought we would have seen more if that was a problem.

roberts011 commented 12 months ago

Hi @ElleKayEm , no idea if OPs problem is still open, but I can confirm that I have the same issue.

Running on a Windows 11 machine with an ARM Processor (Surface Pro X first Generation to be exact). Using noDRM v10.0.9 on calibre 6.29.

Clean installed both Calibre and ADE 2.0 (de-authorized, unistalled, removed registry entries) on this machine, downloaded the .ascm file from Google Play Books for the PDF version of my book.

Activated ADE with my AdobeID, loaded the .ascm file, viewed the book. That part works.

Now when I try to de-DRM the book via calibre using the Plugin, I get the log below:

Log, click to expand ApplicationPaletteChange event ignored Using calibre Qt style: True calibre Debug log calibre 6.29 embedded-python: True Windows-10-10.0.22621-SP0 Windows ('64bit', 'WindowsPE') ('Windows', '10', '10.0.22621') Python 3.10.1 Windows: ('10', '10.0.22621', 'SP0', 'Multiprocessor Free') Interface language: None Successfully initialized third party plugins: DeDRM (10, 0, 9) calibre 6.29 embedded-python: True Windows-10-10.0.22621-SP0 Windows ('64bit', 'WindowsPE') ('Windows', '10', '10.0.22621') Python 3.10.1 Windows: ('10', '10.0.22621', 'SP0', 'Multiprocessor Free') Interface language: None Successfully initialized third party plugins: DeDRM (10, 0, 9) QPA platform: windows devicePixelRatio: 2.0 logicalDpi: 96.0 x 96.0 physicalDpi: 133.4890510948905 x 133.24590163934425 [0.00] Starting up... [0.02] Showing splash screen... [0.23] splash screen shown [0.23] Initializing db... [0.27] db initialized [0.27] Constructing main UI... [1.95] main UI initialized... [1.95] Hiding splash screen Starting QuickView DeDRM v10.0.9: Trying to decrypt EBOOK The Economics of European Integration 7e.pdf [7.59] splash screen hidden [7.59] Started up in 7.59 seconds with 0 books DeDRM v10.0.9: EBOOK The Economics of European Integration 7e.pdf is a PDF ebook with encryption EBX_HANDLER DeDRM v10.0.9: EBOOK The Economics of European Integration 7e.pdf is a PDF ebook (EBX) for UUID a83c34a0-7727-4c38-b5d5-d30dfaf60277 DeDRM v10.0.9: Looking for new default Adobe Digital Editions Keys after 0.6 seconds DeDRM v10.0.9: Exception when getting default Adobe Key after 0.6 seconds Traceback (most recent call last): File "calibre_plugins.dedrm.__init__", line 727, in PDFIneptDecrypt File "C:\Users\schup\AppData\Roaming\calibre\plugins\DeDRM.zip\adobekey.py", line 293, in adeptkeys File "C:\Users\schup\AppData\Roaming\calibre\plugins\DeDRM.zip\adobekey.py", line 273, in CryptUnprotectData adobekey.ADEPTError: Failed to decrypt user key key (sic) DeDRM v10.0.9: Finished after 0.9 seconds Traceback (most recent call last): File "calibre\customize\ui.py", line 469, in get_file_type_metadata File "calibre\customize\builtins.py", line 324, in get_metadata File "calibre\ebooks\metadata\pdf.py", line 124, in get_metadata ValueError: Could not read info dict from PDF Syntax Error: Couldn't find the 'EBX_HANDLER' security handler pdfinfo errored out with return code: 1

Since Google Play Books also provides an ascm file for the EPUB version of the book, I also tried that one out of interest, resulting in the (in my opinion interesting) screenshot below:

Screenshot, click to expand ![image](https://github.com/noDRM/DeDRM_tools/assets/31773450/e3d1bfc8-ea6c-4952-a364-d0cdc76192b4)

Looking forward to your response.

ElleKayEm commented 12 months ago

Let's take a look at the log for the epub.

roberts011 commented 12 months ago

Same error if I read it correctly:

Log ApplicationPaletteChange event ignored Using calibre Qt style: True calibre Debug log calibre 6.29 embedded-python: True Windows-10-10.0.22621-SP0 Windows ('64bit', 'WindowsPE') ('Windows', '10', '10.0.22621') Python 3.10.1 Windows: ('10', '10.0.22621', 'SP0', 'Multiprocessor Free') Interface language: None Successfully initialized third party plugins: DeACSM (0, 0, 16) && DeDRM (10, 0, 9) calibre 6.29 embedded-python: True Windows-10-10.0.22621-SP0 Windows ('64bit', 'WindowsPE') ('Windows', '10', '10.0.22621') Python 3.10.1 Windows: ('10', '10.0.22621', 'SP0', 'Multiprocessor Free') Interface language: None Successfully initialized third party plugins: DeACSM (0, 0, 16) && DeDRM (10, 0, 9) QPA platform: windows devicePixelRatio: 2.0 logicalDpi: 96.0 x 96.0 physicalDpi: 133.4890510948905 x 133.24590163934425 [0.00] Starting up... [0.02] Showing splash screen... [0.19] splash screen shown [0.19] Initializing db... [0.20] db initialized [0.20] Constructing main UI... [1.34] main UI initialized... [1.34] Hiding splash screen Starting QuickView [19.08] splash screen hidden [19.08] Started up in 19.08 seconds with 0 books Added EBOOK The Economics of European Integrat-epub to db in: 0.1 DeDRM v10.0.9: Trying to decrypt The Economics of European Integration, 7e.epub DeDRM v10.0.9: Verifying zip archive integrity Added 1 books in 1.0 seconds Worker Launch took: 0.02 seconds DeDRM v10.0.9: The Economics of European Integration, 7e.epub is a secure Adobe Adept ePub for UUID a83c34a0-7727-4c38-b5d5-d30dfaf60277 DeDRM v10.0.9: Looking for new default Adobe Digital Editions Keys after 0.5 seconds DeDRM v10.0.9: Exception when getting default Adobe Key after 0.5 seconds Traceback (most recent call last): File "calibre_plugins.dedrm.__init__", line 565, in ePubDecrypt File "C:\Users\schup\AppData\Roaming\calibre\plugins\DeDRM.zip\adobekey.py", line 293, in adeptkeys File "C:\Users\schup\AppData\Roaming\calibre\plugins\DeDRM.zip\adobekey.py", line 273, in CryptUnprotectData adobekey.ADEPTError: Failed to decrypt user key key (sic) DeDRM v10.0.9: Ultimately failed to decrypt after 0.8 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md Running file type plugin DeDRM failed with traceback: Traceback (most recent call last): File "calibre\customize\ui.py", line 187, in _run_filetype_plugins File "calibre_plugins.dedrm.__init__", line 1041, in run File "calibre_plugins.dedrm.__init__", line 639, in ePubDecrypt calibre_plugins.dedrm.DeDRMError: DeDRM v10.0.9: Ultimately failed to decrypt after 0.8 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
ElleKayEm commented 12 months ago

Yes it does look like the same situation. I don't know how to resolve it...other than trying on another machine that isn't Windows 11.

roberts011 commented 12 months ago

FIXED IT! On my seperate setup, I got it to work.

Setup details: Acer Nitro 5, Windows 11, 64bit, regular x64-x64 Intel processor

ADE Version: 4.5 (yes you read that correctly) Calibre Version: 6.27 DeDRM Version: v10.0.2 CUSTOMIZED! I found this version on Github a few weeks ago, unfortunately forgot where exactly. Attching it here: DeDRM_plugin_for_ADE4.5.zip

Please find the Calibre Log attached as well: log.txt

One interesting observation: While Calibre successfully de-DRMs the book, it doesnt load in the built-in reader. It just spins forever, saying "preparing book for first read". Screenshot

I aborted the process after a few minutes and opened the file in the good old Edge browser, which could now display it successfully.

My hope is that this will help to improve the DeDRM / UnDRM project at large.

ElleKayEm commented 12 months ago

DeDRM 10.0.3 and up also works with the hardened Adobe DRM that it's possible to get with Adobe 3 and up from the few places that actually use it. ProQuest is the only place I've seen mentioned here where they've switched to that exclusively.

I suspect this is something to do with the original setup you and the first poster had. Glad you got things working. And yeah don't bother trying to use the calibre ebook viewer for pdfs.