noDRM / DeDRM_tools

DeDRM tools for ebooks
7.32k stars 323 forks source link

DeDRM is not working for some books #330

Open 7enChan opened 1 year ago

7enChan commented 1 year ago

Question / bug report

Hi, The problem I encountered is that some books cannot remove DRM while others can. book source:ADE (download from Google play books)

Which version of Calibre are you running?

6.17

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

Using calibre Qt style: True
calibre 偵錯記錄
calibre 6.17  embedded-python: True
macOS-13.3.1-arm64-arm-64bit Darwin ('64bit', '')
('Darwin', '22.4.0', 'Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:58 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6020')
Python 3.10.1
OSX: ('13.3.1', ('', '', ''), 'arm64')
Interface language: zh_HK
Successfully initialized third party plugins: DeACSM (0, 0, 16) && DeDRM (10, 0, 3) && Chinese Text Conversion (3, 0, 1) && Ebook Translator (1, 3, 6)
calibre 6.17  embedded-python: True
macOS-13.3.1-arm64-arm-64bit Darwin ('64bit', '')
('Darwin', '22.4.0', 'Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:58 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6020')
Python 3.10.1
OSX: ('13.3.1', ('', '', ''), 'arm64')
Interface language: zh_HK
Successfully initialized third party plugins: DeACSM (0, 0, 16) && DeDRM (10, 0, 3) && Chinese Text Conversion (3, 0, 1) && Ebook Translator (1, 3, 6)
QPA platform: cocoa
devicePixelRatio: 2.0
logicalDpi: 72.0 x 72.0
physicalDpi: 81.50000122400722 x 80.50000120898872
[0.00] Starting up...
[0.04] Showing splash screen...
[0.21] splash screen shown
[0.21] Initializing db...
[0.21] db initialized
[0.21] Constructing main UI...
[0.58] main UI initialized...
[0.58] Hiding splash screen
Starting QuickView
DeDRM v10.0.3: Trying to decrypt 奇蹟.epub
DeDRM v10.0.3: Verifying zip archive integrity
DeDRM v10.0.3: 奇蹟.epub is a secure Adobe Adept ePub for UUID 6abe9221-0c08-48cb-bc9a-f26e8e36805b
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 591, in ePubDecrypt
    defaultkeys, defaultnames = adeptkeys()
  File "/Users/zen/Library/Preferences/calibre/plugins/DeDRM.zip/adobekey.py", line 439, in adeptkeys
    raise ADEPTError("Could not find ADE activation.dat file.")
adobekey.ADEPTError: Could not find ADE activation.dat file.
DeDRM v10.0.3: Found new key 'DeACSM_uuid_767ddaee-8c2f-4afc-9a68-82196ed1aaf6' in DeACSM plugin
DeDRM v10.0.3: Trying a new default key
w05bq9m6.epub is a secure Adobe Adept ePub.
Could not decrypt w05bq9m6.epub because of an exception:
Traceback (most recent call last):
  File "/Users/zen/Library/Preferences/calibre/plugins/DeDRM.zip/ineptepub.py", line 327, in decryptBook
    decryptor = Decryptor(bookkey, encryption)
  File "/Users/zen/Library/Preferences/calibre/plugins/DeDRM.zip/ineptepub.py", line 150, in __init__
    self._aes = AES.new(bookkey, AES.MODE_CBC, b'\x00'*16)
  File "Crypto/Cipher/AES.py", line 232, in new
  File "Crypto/Cipher/__init__.py", line 79, in _create_cipher
  File "Crypto/Cipher/_mode_cbc.py", line 274, in _create_cbc_cipher
  File "Crypto/Cipher/AES.py", line 93, in _create_base_cipher
ValueError: Incorrect AES key length (0 bytes)

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 "calibre/customize/ui.py", line 187, in _run_filetype_plugins
  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
[9.35] splash screen hidden
[9.35] Started up in 9.35 seconds with 2 books
Added 奇蹟 to db in: 0.0
Added 1 books in 0.4 seconds
ElleKayEm commented 1 year ago

Was this book downloaded with the DeACSM plugin?

7enChan commented 1 year ago

Was this book downloaded with the DeACSM plugin?

No, downloaded with ADE

7enChan commented 1 year ago

This is from the log on the Windows system, My ADE is installed on the Windows system

ApplicationPaletteChange event ignored
Using calibre Qt style: True
ApplicationPaletteChange event received
calibre 调试日志
calibre 6.15.1  embedded-python: True
Windows-10-10.0.17763-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.17763')
Python 3.10.1
Windows: ('10', '10.0.17763', 'SP0', 'Multiprocessor Free')
Interface language: zh_CN
Successfully initialized third party plugins: DeDRM (10, 0, 3) && Chinese Text Conversion (3, 0, 1)
calibre 6.15.1  embedded-python: True
Windows-10-10.0.17763-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.17763')
Python 3.10.1
Windows: ('10', '10.0.17763', 'SP0', 'Multiprocessor Free')
Interface language: zh_CN
Successfully initialized third party plugins: DeDRM (10, 0, 3) && Chinese Text Conversion (3, 0, 1)
QPA platform: windows
devicePixelRatio: 2.0
logicalDpi: 96.0 x 96.0
physicalDpi: 81.55183946488295 x 80.68235294117646
[0.00] Starting up...
[0.02] Showing splash screen...
[0.52] splash screen shown
[0.52] Initializing db...
[0.52] db initialized
[0.52] Constructing main UI...
[1.19] main UI initialized...
[1.19] Hiding splash screen
Starting QuickView
DeDRM v10.0.3: Trying to decrypt 奇蹟.epub
DeDRM v10.0.3: Verifying zip archive integrity
DeDRM v10.0.3: 奇蹟.epub is a secure Adobe Adept ePub for UUID 6abe9221-0c08-48cb-bc9a-f26e8e36805b
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "encodings\hex_codec.py", line 19, in hex_decode
ValueError: string argument should contain only ASCII characters

The above exception was the direct cause of the following exception:

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 533, in ePubDecrypt
ValueError: decoding with 'hex' codec failed (ValueError: string argument should contain only ASCII characters)
[3.34] splash screen hidden
[3.34] Started up in 3.34 seconds with 1 books
Added 奇蹟 to db in: 0.1
Added 1 books in 0.6 seconds
ElleKayEm commented 1 year ago

Delete the saved Adobe key from DeDRM's customization. Add the book letting DeDRM automatically retrieve the key.

7enChan commented 1 year ago

Delete the saved Adobe key from DeDRM's customization. Add the book letting DeDRM automatically retrieve the key.

I have tried this method, but still cannot remove the DRM.

ElleKayEm commented 1 year ago

You've done this on the computer with ADE which was used to download the book? Let's see a log of adding the book after the key is deleted again.

7enChan commented 1 year ago

Yes,on my PC.
the log without the key:

ApplicationPaletteChange event ignored
Using calibre Qt style: True
ApplicationPaletteChange event received
calibre 调试日志
calibre 6.15.1  embedded-python: True
Windows-10-10.0.17763-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.17763')
Python 3.10.1
Windows: ('10', '10.0.17763', 'SP0', 'Multiprocessor Free')
Interface language: zh_CN
Successfully initialized third party plugins: DeDRM (10, 0, 3) && Chinese Text Conversion (3, 0, 1)
calibre 6.15.1  embedded-python: True
Windows-10-10.0.17763-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.17763')
Python 3.10.1
Windows: ('10', '10.0.17763', 'SP0', 'Multiprocessor Free')
Interface language: zh_CN
Successfully initialized third party plugins: DeDRM (10, 0, 3) && Chinese Text Conversion (3, 0, 1)
QPA platform: windows
devicePixelRatio: 2.0
logicalDpi: 96.0 x 96.0
physicalDpi: 81.55183946488295 x 80.68235294117646
[0.00] Starting up...
[0.02] Showing splash screen...
[0.48] splash screen shown
[0.48] Initializing db...
[0.48] db initialized
[0.48] Constructing main UI...
Failed to check for calibre update: [Errno 11001] getaddrinfo failed
Failed to check for plugin update: [Errno 11001] getaddrinfo failed
[1.14] main UI initialized...
[1.14] Hiding splash screen
Starting QuickView
DeDRM v10.0.3: Trying to decrypt 奇蹟.epub
DeDRM v10.0.3: Verifying zip archive integrity
DeDRM v10.0.3: 奇蹟.epub is a secure Adobe Adept ePub for UUID 6abe9221-0c08-48cb-bc9a-f26e8e36805b
DeDRM v10.0.3: Looking for new default Adobe Digital Editions Keys after 0.2 seconds
Found 1 keys
DeDRM v10.0.3: Trying a new default key
vyucodtz.epub is a secure Adobe Adept ePub.
[12.80] splash screen hidden
[12.80] Started up in 12.80 seconds with 1 books
Could not decrypt vyucodtz.epub because of an exception:
Traceback (most recent call last):
  File "C:\Users\ZenChan\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptepub.py", line 342, in decryptBook
  File "C:\Users\ZenChan\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptepub.py", line 180, in get_xml
AttributeError: 'Decryptor' object has no attribute '_encryption'

DeDRM v10.0.3: Failed to decrypt with new default key after 1.0 seconds
DeDRM v10.0.3: Ultimately failed to decrypt after 1.0 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 1.0 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
ElleKayEm commented 1 year ago

Okay, this log shows where the issue is. But it is something that @noDRM or someone else will need to look at. I don't know how to resolve it.

j-howell commented 1 year ago

Okay, this log shows where the issue is. But it is something that @noDRM or someone else will need to look at. I don't know how to resolve it.

That error is caused by a bug fixed by NoDRM in commit 3c12806f38eecfd5b37a5ace890f7c00cbe52169 on Jan 6. However an updated version of the plugin was not released since then.

7enChan commented 1 year ago

Okay, this log shows where the issue is. But it is something that @noDRM or someone else will need to look at. I don't know how to resolve it.

That error is caused by a bug fixed by NoDRM in commit 3c12806 on Jan 6. However an updated version of the plugin was not released since then.

thanks, I tried the outdated DeDRM 7.X version and it worked.

ElleKayEm commented 1 year ago

DeDRM 7.2.1 and calibre 5.x?

7enChan commented 1 year ago

DeDRM 7.2.1 and calibre 5.x?

DeDRM 7.2.1 and calibre 6.2.1

ElleKayEm commented 1 year ago

Interesting. Thanks for reporting what worked.

nzeppos commented 1 year ago

Had a similar error trying to de-drm a greek book:

Running file type plugin DeDRM failed with traceback: Traceback (most recent call last): File "encodings\hex_codec.py", line 19, in hex_decode ValueError: string argument should contain only ASCII characters

The above exception was the direct cause of the following exception:

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 533, in ePubDecrypt
ValueError: decoding with 'hex' codec failed (ValueError: string argument should contain only ASCII characters)
[27.30] splash screen hidden
[27.30] Started up in 27.30 seconds with 661 books

Was fixed after I followed advice:

Delete the saved Adobe key from DeDRM's customization. Add the book letting DeDRM automatically retrieve the key.

ElleKayEm commented 1 year ago

It wasn't the book. This was a bug in manually retrieving the Adobe key. Fixed in 10.0.9.