noDRM / DeDRM_tools

DeDRM tools for ebooks
7.38k stars 326 forks source link

Unable to decrypt ADE .epub #569

Closed edutchie closed 4 months ago

edutchie commented 4 months ago

Question / bug report

The plugin fails to decrypt an Adobe Digital Editions .epub I have tried without a key (see log below) and with my key imported into the plugin. No luck either way.

Which version of Calibre are you running? 7.13

Which version of the DeDRM plugin are you running? v10.0.3

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

Log output


DeDRM v10.0.3: Trying to decrypt A Hat Full of Sky - Terry Pratchett.epub
DeDRM v10.0.3: Verifying zip archive integrity
DeDRM v10.0.3: A Hat Full of Sky - Terry Pratchett.epub is a secure Adobe Adept ePub for UUID 438c67be-f197-4bb2-a09a-9d16be850ee5
DeDRM v10.0.3: Looking for new default Adobe Digital Editions Keys after 0.0 seconds
DeDRM v10.0.3: Exception when getting default Adobe Key after 0.0 seconds
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 596, in ePubDecrypt
    defaultkeys, defaultnames = WineGetKeys(scriptpath, ".der",dedrmprefs['adobewineprefix'])
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phares/.config/calibre/plugins/DeDRM.zip/wineutils.py", line 96, in WineGetKeys
    pyexec = WinePythonCLI(wineprefix)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/phares/.config/calibre/plugins/DeDRM.zip/wineutils.py", line 59, in __init__
    self.check_call(["-c", self.py3_test])
  File "/home/phares/.config/calibre/plugins/DeDRM.zip/wineutils.py", line 84, in check_call
    subprocess.check_call(self.python_exec + cli_args, env=env_dict,
  File "/usr/lib64/python3.12/subprocess.py", line 408, in check_call
    retcode = call(*popenargs, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/subprocess.py", line 389, in call
    with Popen(*popenargs, **kwargs) as p:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib64/python3.12/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'wine'
DeDRM v10.0.3: Found new key 'DeACSM_uuid_438c67be-f197-4bb2-a09a-9d16be850ee5' in DeACSM plugin
DeDRM v10.0.3: Trying a new default key
vh9dopas.epub is a secure Adobe Adept ePub.
Could not decrypt vh9dopas.epub because of an exception:
Traceback (most recent call last):
  File "/home/phares/.config/calibre/plugins/DeDRM.zip/ineptepub.py", line 305, in decryptBook
    rsakey = RSA.import_key(userkey) # parses the ASN1 structure
             ^^^^^^^^^^^^^^
AttributeError: module 'Crypto.PublicKey.RSA' has no attribute 'import_key'. Did you mean: 'importKey'?

DeDRM v10.0.3: Failed to decrypt with new default key after 0.1 seconds
DeDRM v10.0.3: Ultimately failed to decrypt after 0.1 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 "/usr/lib64/calibre/calibre/customize/ui.py", line 199, in _run_filetype_plugins
    nfp = plugin.run(nfp) or nfp
          ^^^^^^^^^^^^^^^
  File "calibre_plugins.dedrm.__init__", line 1067, in run
    decrypted_ebook = self.ePubDecrypt(path_to_ebook)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.dedrm.__init__", line 665, in ePubDecrypt
    raise DeDRMError("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
calibre_plugins.dedrm.DeDRMError: DeDRM v10.0.3: Ultimately failed to decrypt after 0.1 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
Added A Hat Full of Sky to db in: 0.3
Added 1 books in 0.8 seconds
ElleKayEm commented 4 months ago

This is on Linux? Recommend using the DeACSM plugin to download the book directly into calibre instead of using ADE at all. You may need to add the key from DeACSM into DeDRM yourself. You might also want to update to DeDRM 10.0.9 as there are some bug fixes.

edutchie commented 4 months ago

Correct, Fedora Linux 40. The .epub was downloaded with DeACSM but they were not decrypted upon download. It was my understanding that the .epub still needs to be decrypted with DeDRM. I imported the key which gave the following result:

DeDRM v10.0.3: Trying to decrypt A Hat Full of Sky - Terry Pratchett.epub
DeDRM v10.0.3: Verifying zip archive integrity
DeDRM v10.0.3: A Hat Full of Sky - Terry Pratchett.epub is a secure Adobe Adept ePub for UUID 438c67be-f197-4bb2-a09a-9d16be850ee5
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "/usr/lib64/calibre/calibre/customize/ui.py", line 199, in _run_filetype_plugins
    nfp = plugin.run(nfp) or nfp
          ^^^^^^^^^^^^^^^
  File "calibre_plugins.dedrm.__init__", line 1067, in run
    decrypted_ebook = self.ePubDecrypt(path_to_ebook)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.dedrm.__init__", line 533, in ePubDecrypt
    userkey = codecs.decode(userkeyhex, 'hex')
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/encodings/hex_codec.py", line 19, in hex_decode
    return (binascii.a2b_hex(input), len(input))
            ^^^^^^^^^^^^^^^^^^^^^^^
ValueError: string argument should contain only ASCII characters
decoding with 'hex' codec failed

Debugging DND event
application/x-gtk-local-dnd 0 b'' 

application/vnd.portal.filetransfer 20 b'9274014774387918266\x00' 

application/vnd.portal.files 20 b'4482902011576412024\x00' 

text/uri-list 86 b'file:///home/phares/Documents/A%20Hat%20Full%20of%20Sky%20-%20Terry%20Pratchett.epub\r\n' 

text/plain;charset=utf-8 63 b'/home/phares/Documents/A Hat Full of Sky - Terry Pratchett.epub' 

Firefox rurl: None None
URLS: ['file:///home/phares/Documents/A%20Hat%20Full%20of%20Sky%20-%20Terry%20Pratchett.epub']
Paths: ['/home/phares/Documents/A Hat Full of Sky - Terry Pratchett.epub']
Extensions: frozenset({'epub'})
Added A Hat Full of Sky to db in: 0.3
Added 1 books in 0.7 seconds
edutchie commented 4 months ago

Pre-release 10.0.9 fixed the issue. Thank you so much for your help!