noDRM / DeDRM_tools

DeDRM tools for ebooks
6.59k stars 287 forks source link

Cannot DeDRM Adobe DRM, AttributeError: module 'Crypto.PublicKey.RSA' has no attribute 'import_key' #406

Closed EgestiaN closed 9 months ago

EgestiaN commented 9 months ago

Question / bug report

I'm trying to access a course book for university and it's protected by Adobe DRM. I'm using Fedora 38, the RPM version of Calibre found from the official repos and Leseratte10's DeACSM plugin, but when trying to import and DeDRM the book, there is an error message in the log, and the DRM doesn't get removed. There is an error: AttributeError: module 'Crypto.PublicKey.RSA' has no attribute 'import_key'

Which version of Calibre are you running?

5.43

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

9calibre Debug log
calibre 5.43  embedded-python: False is64bit: True
Linux-6.4.15-200.fc38.x86_64-x86_64-with-glibc2.37 Linux ('64bit', 'ELF')
('Linux', '6.4.15-200.fc38.x86_64', '#1 SMP PREEMPT_DYNAMIC Thu Sep  7 00:25:01 UTC 2023')
Python 3.11.5
Interface language: en_GB
Successfully initialized third party plugins: DeACSM (0, 0, 16) && DeDRM (10, 0, 3)
calibre 5.43  embedded-python: False is64bit: True
Linux-6.4.15-200.fc38.x86_64-x86_64-with-glibc2.37 Linux ('64bit', 'ELF')
('Linux', '6.4.15-200.fc38.x86_64', '#1 SMP PREEMPT_DYNAMIC Thu Sep  7 00:25:01 UTC 2023')
Python 3.11.5
Interface language: en_GB
Successfully initialized third party plugins: DeACSM (0, 0, 16) && DeDRM (10, 0, 3)
Turning on automatic hidpi scaling
devicePixelRatio: 1.0
logicalDpi: 96.0 x 96.0
physicalDpi: 126.12413793103448 x 127.0
Using calibre Qt style: True
[0.00] Starting up...
[0.00] Showing splash screen...
[0.03] splash screen shown
[0.03] Initializing db...
[0.04] db initialized
[0.04] Constructing main UI...
[1.25] main UI initialized...
[1.25] Hiding splash screen
Starting QuickView
[3.09] splash screen hidden
[3.09] Started up in 3.09 seconds with 1 books
DeDRM v10.0.3: Trying to decrypt dx2mltgi.epub
DeDRM v10.0.3: Verifying zip archive integrity
DeDRM v10.0.3: dx2mltgi.epub is a secure Adobe Adept ePub for UUID 4d1c4... (Don't want to post the whole ID)
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 596, in ePubDecrypt
    defaultkeys, defaultnames = WineGetKeys(scriptpath, ".der",dedrmprefs['adobewineprefix'])
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.config/calibre/plugins/DeDRM.zip/wineutils.py", line 96, in WineGetKeys
    pyexec = WinePythonCLI(wineprefix)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.config/calibre/plugins/DeDRM.zip/wineutils.py", line 59, in __init__
    self.check_call(["-c", self.py3_test])
  File "/home/user/.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.11/subprocess.py", line 408, in check_call
    retcode = call(*popenargs, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/subprocess.py", line 389, in call
    with Popen(*popenargs, **kwargs) as p:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib64/python3.11/subprocess.py", line 1950, 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_4d1c4...' in DeACSM plugin
DeDRM v10.0.3: Trying a new default key
l6_jm3ra.epub is a secure Adobe Adept ePub.
Could not decrypt l6_jm3ra.epub because of an exception:
Traceback (most recent call last):
  File "/home/user/.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'

DeDRM v10.0.3: Failed to decrypt with new default key after 0.3 seconds
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
DeACSM v0.0.16: Running file type plugin failed with traceback:
Traceback (most recent call last):
  File "calibre_plugins.deacsm.__init__", line 486, in run
    plugin_ret = plugin.run(rpl)
                 ^^^^^^^^^^^^^^^
  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.3 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
DeACSM v0.0.16: Trying to parse file URLLink.acsm
DeACSM v0.0.16: Try to fulfill ...
Notifying server ...
Notifying server http://acs4.ellibs.net/fulfillment/FulfillmentNotification
Fulfillment notification successful.
Notifying optional server http://backend2.ellibs.net/drm_settlement_acs4.php
Weird Fulfillment Notification response: 
DeACSM v0.0.16: Downloading book ...
DeACSM v0.0.16: Loading book from http://content1.ellibs.net/bookdata/encrypted/6473...6c.epub
Download took 2212 ms (HTTP 200)
That's a ZIP file -> EPUB
DeACSM v0.0.16: File successfully fulfilled ...
DeACSM v0.0.16: Executing plugin DeDRM ...
DeACSM v0.0.16: Plugin returned nothing - skipping
Added Valtiosääntöoikeus to db in: 0.4
Added 1 books in 15.7 seconds
Worker Launch took: 0.00 seconds
ElleKayEm commented 9 months ago

Try DeDRM 10.0.9: https://github.com/noDRM/DeDRM_tools/releases/tag/v10.0.9

EgestiaN commented 9 months ago

Try DeDRM 10.0.9: https://github.com/noDRM/DeDRM_tools/releases/tag/v10.0.9

That fixed the issue. Thank you, didn't notice a newer version was available!