noDRM / DeDRM_tools

DeDRM tools for ebooks
6.56k stars 287 forks source link

Cannot remove Kindle DRM on Calibre for Mac #515

Closed fmoncomble closed 3 months ago

fmoncomble commented 3 months ago

Question / bug report

Hi, I'm using Kindle Classic (1.40.3) on my Mac running Ventura as this is the only version that works on that system and will download recent Kindle books (I tried version 1.32 without success on that point). Any hints?

Which version of Calibre are you running?

7.6.0

Which version of the DeDRM plugin are you running?

v10.0.3

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

1.40.3 (Kindle Classic)

Log output

ApplicationPaletteChange event ignored
Using calibre Qt style: True
2024-03-12 17:23:53.715 calibre-debug[11093:287391] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
qt.gui.imageio: libpng warning: iCCP: known incorrect sRGB profile
calibre Debug log
calibre 7.6  embedded-python: True
macOS-14.2.1-x86_64-i386-64bit Darwin ('64bit', '')
('Darwin', '23.2.0', 'Darwin Kernel Version 23.2.0: Wed Nov 15 21:54:10 PST 2023; root:xnu-10002.61.3~2/RELEASE_X86_64')
Python 3.11.5
OSX: ('14.2.1', ('', '', ''), 'x86_64')
Interface language: None
EXE path: /Applications/calibre.app/Contents/MacOS/calibre-debug
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (2, 9, 0) && DeDRM (10, 0, 3) && Package KFX (from KFX Input) (2, 9, 0) && KFX metadata reader (from KFX Input) (2, 9, 0) && From KFX (2, 9, 0) && KFX Input (2, 9, 0)
calibre 7.6  embedded-python: True
macOS-14.2.1-x86_64-i386-64bit Darwin ('64bit', '')
('Darwin', '23.2.0', 'Darwin Kernel Version 23.2.0: Wed Nov 15 21:54:10 PST 2023; root:xnu-10002.61.3~2/RELEASE_X86_64')
Python 3.11.5
OSX: ('14.2.1', ('', '', ''), 'x86_64')
Interface language: None
EXE path: /Applications/calibre.app/Contents/MacOS/calibre-debug
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (2, 9, 0) && DeDRM (10, 0, 3) && Package KFX (from KFX Input) (2, 9, 0) && KFX metadata reader (from KFX Input) (2, 9, 0) && From KFX (2, 9, 0) && KFX Input (2, 9, 0)
QPA platform: cocoa
devicePixelRatio: 2.0
logicalDpi: 72.0 x 72.0
physicalDpi: 133.00000199745963 x 133.0000019974596
[0.00] Starting up...
[0.02] Showing splash screen...
[0.18] splash screen shown
[0.18] Initializing db...
[0.20] db initialized
[0.20] Constructing main UI...
[1.18] GUI main window shown
[1.26] main UI initialized...
[1.26] Hiding splash screen
Gather KFX-ZIP (from KFX Input) 2.9.0: Importing /Users/florent/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/My Kindle Content/B0CW1B2Q7C_EBOK/B0CW1B2Q7C_EBOK.azw
[4.21] splash screen hidden
[4.21] Started up in 4.21 seconds with 2 books

Debugging DND event
text/uri-list 160 b'file:///Users/florent/Library/Containers/com.amazon.Kindle/Data/Library/Application%20Support/Kindle/My%20Kindle%20Content/B0CW1B2Q7C_EBOK/B0CW1B2Q7C_EBOK.azw\r\n' 

Firefox rurl: None None
URLS: ['file:///Users/florent/Library/Containers/com.amazon.Kindle/Data/Library/Application%20Support/Kindle/My%20Kindle%20Content/B0CW1B2Q7C_EBOK/B0CW1B2Q7C_EBOK.azw']
Paths: ['/Users/florent/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/My Kindle Content/B0CW1B2Q7C_EBOK/B0CW1B2Q7C_EBOK.azw']
Extensions: frozenset({'azw'})
Gather KFX-ZIP (from KFX Input): Gathered 4 file(s) as /var/folders/9g/mcjjmb8m8xj0qc0059bjvvs80000gn/C/calibre_7.6.0_tmp_uebnnfah/1l484pmq.kfx-zip
DeDRM v10.0.3: Trying to decrypt 1l484pmq.kfx-zip
Using Library AlfCrypto Python
Decrypting KFX-ZIP ebook: 1l484pmq
Got DSN key from database default_key_1710259505
Found 1 keys to try after 0.1 seconds
Decrypting KFX DRM voucher: amzn1.drm-voucher.v1.1e10d73f-7b74-4c3b-ad15-246922d4b198.voucher
Traceback (most recent call last):
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 105, in decrypt_voucher
    voucher.decryptvoucher()
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 886, in decryptvoucher
    b = pkcs7unpad(b, 16)
        ^^^^^^^^^^^^^^^^^
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 762, in pkcs7unpad
    _assert(paddinglen > 0 and paddinglen <= blocklen, "Incorrect padding - Wrong key")
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 102, in _assert
    raise Exception(msg)
Exception: Incorrect padding - Wrong key
Traceback (most recent call last):
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 105, in decrypt_voucher
    voucher.decryptvoucher()
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 886, in decryptvoucher
    b = pkcs7unpad(b, 16)
        ^^^^^^^^^^^^^^^^^
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 762, in pkcs7unpad
    _assert(paddinglen > 0 and paddinglen <= blocklen, "Incorrect padding - Wrong key")
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 102, in _assert
    raise Exception(msg)
Exception: Incorrect padding - Wrong key
DeDRM v10.0.3: Failed to decrypt with error: Failed to decrypt KFX DRM voucher with any key
DeDRM v10.0.3: Looking for new default Kindle Key after 0.1 seconds
Found k4Mac kinf2018 file: /Users/florent/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/storage/.kinf2018
trying username  b'florent'  on file  /Users/florent/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/storage/.kinf2018
trying IDString: b'27c77965e7a4'
trying IDString: b'99875e4b1bd4'
Decrypted key file using IDString '99875e4b1bd4' and UserName 'florent'
DeDRM v10.0.3: Found 1 new key
Decrypting KFX-ZIP ebook: 1l484pmq
Got DSN key from database key_0
Found 1 keys to try after 0.6 seconds
Decrypting KFX DRM voucher: amzn1.drm-voucher.v1.1e10d73f-7b74-4c3b-ad15-246922d4b198.voucher
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 957, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 111, in decrypt_voucher
    raise Exception("Failed to decrypt KFX DRM voucher with any key")
Exception: Failed to decrypt KFX DRM voucher with any key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 105, in decrypt_voucher
    voucher.decryptvoucher()
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 886, in decryptvoucher
    b = pkcs7unpad(b, 16)
        ^^^^^^^^^^^^^^^^^
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 762, in pkcs7unpad
    _assert(paddinglen > 0 and paddinglen <= blocklen, "Incorrect padding - Wrong key")
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 102, in _assert
    raise Exception(msg)
Exception: Incorrect padding - Wrong key
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 957, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 111, in decrypt_voucher
    raise Exception("Failed to decrypt KFX DRM voucher with any key")
Exception: Failed to decrypt KFX DRM voucher with any key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 105, in decrypt_voucher
    voucher.decryptvoucher()
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 886, in decryptvoucher
    b = pkcs7unpad(b, 16)
        ^^^^^^^^^^^^^^^^^
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 762, in pkcs7unpad
    _assert(paddinglen > 0 and paddinglen <= blocklen, "Incorrect padding - Wrong key")
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 102, in _assert
    raise Exception(msg)
Exception: Incorrect padding - Wrong key
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 957, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 111, in decrypt_voucher
    raise Exception("Failed to decrypt KFX DRM voucher with any key")
Exception: Failed to decrypt KFX DRM voucher with any key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 991, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,newkeys.items(),[],[],[],self.starttime)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 111, in decrypt_voucher
    raise Exception("Failed to decrypt KFX DRM voucher with any key")
Exception: Failed to decrypt KFX DRM voucher with any key
DeDRM v10.0.3: Ultimately failed to decrypt after 0.7 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_plugins.dedrm.__init__", line 957, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/Users/florent/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 111, in decrypt_voucher
    raise Exception("Failed to decrypt KFX DRM voucher with any key")
Exception: Failed to decrypt KFX DRM voucher with any key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre/customize/ui.py", line 187, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 1056, in run
    decrypted_ebook = self.KindleMobiDecrypt(path_to_ebook)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.dedrm.__init__", line 1007, in KindleMobiDecrypt
    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.7 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
Package KFX (from KFX Input) 2.9.0: Packaging /var/folders/9g/mcjjmb8m8xj0qc0059bjvvs80000gn/C/calibre_7.6.0_tmp_uebnnfah/1l484pmq.kfx-zip
Processing container: B0CW1B2Q7C_EBOK.azw
Running file type plugin Package KFX (from KFX Input) failed with traceback:
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 187, in _run_filetype_plugins
  File "calibre_plugins.kfx_input.package_filetype", line 23, in run
    return self.package_kfx(path_to_ebook)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.kfx_input.package_filetype", line 34, in package_kfx
    kfx_data = YJ_Book(path_to_ebook).convert_to_single_kfx()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 79, in convert_to_single_kfx
    self.decode_book()
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 212, in decode_book
    container = self.get_container(datafile)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 321, in get_container
    raise KFXDRMError("Book container %s has DRM and cannot be converted" % datafile.name)
calibre_plugins.kfx_input.kfxlib.utilities.KFXDRMError: Book container B0CW1B2Q7C_EBOK.azw has DRM and cannot be converted
KFX metadata reader (from KFX Input) activated for /var/folders/9g/mcjjmb8m8xj0qc0059bjvvs80000gn/C/calibre_7.6.0_tmp_uebnnfah/gr4ubgjb_add_books/0/B0CW1B2Q7C_EBOK.kfx-zip
fmoncomble commented 3 months ago

My apologies, I installed version 10.0.9 (RC1) of the plug-in and everything worked as intended.