noDRM / DeDRM_tools

DeDRM tools for ebooks
7.05k stars 316 forks source link

Can't remove DRM from Kindle book #441

Closed allindow closed 10 months ago

allindow commented 10 months ago

Question / bug report

Trying to convert the book to pdf results in an error about DRM

Which version of Calibre are you running?

7.1

Which version of the DeDRM plugin are you running?

v10.0.3

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

1.33.0

Log output

Using calibre Qt style: True
calibre Debug log
calibre 7.1  embedded-python: True
macOS-13.0-arm64-arm-64bit Darwin ('64bit', '')
('Darwin', '22.1.0', 'Darwin Kernel Version 22.1.0: Sun Oct  9 20:19:12 PDT 2022; root:xnu-8792.41.9~3/RELEASE_ARM64_T6020')
Python 3.11.5
OSX: ('13.0', ('', '', ''), 'arm64')
Interface language: None
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (2, 6, 0) && DeDRM (10, 0, 3) && Package KFX (from KFX Input) (2, 6, 0) && KFX metadata reader (from KFX Input) (2, 6, 0) && KFX Input (2, 6, 0)
calibre 7.1  embedded-python: True
macOS-13.0-arm64-arm-64bit Darwin ('64bit', '')
('Darwin', '22.1.0', 'Darwin Kernel Version 22.1.0: Sun Oct  9 20:19:12 PDT 2022; root:xnu-8792.41.9~3/RELEASE_ARM64_T6020')
Python 3.11.5
OSX: ('13.0', ('', '', ''), 'arm64')
Interface language: None
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (2, 6, 0) && DeDRM (10, 0, 3) && Package KFX (from KFX Input) (2, 6, 0) && KFX metadata reader (from KFX Input) (2, 6, 0) && KFX Input (2, 6, 0)
QPA platform: cocoa
devicePixelRatio: 2.0
logicalDpi: 72.0 x 72.0
physicalDpi: 69.50000104378529 x 68.50000102876679
[0.00] Starting up...
[0.04] Showing splash screen...
[0.20] splash screen shown
[0.20] Initializing db...
[0.21] db initialized
[0.21] Constructing main UI...
[0.56] main UI initialized...
[0.56] Hiding splash screen
Starting QuickView
Gather KFX-ZIP (from KFX Input) 2.6.0: Importing /Users/angela/Library/Application Support/Kindle/My Kindle Content/B000S1LX5C_EBOK/B000S1LX5C_EBOK.azw
Gather KFX-ZIP (from KFX Input): Gathered 4 file(s) as /var/folders/bx/bm80hzc54238w5hqx918qbd40000gn/C/calibre_7.1.0_tmp_5ptiw38q/nne36iri.kfx-zip
DeDRM v10.0.3: Trying to decrypt nne36iri.kfx-zip
Using Library AlfCrypto Python
Decrypting KFX-ZIP ebook: nne36iri
Got DSN key from database default_key_1701202007
Found 1 keys to try after 0.0 seconds
Decrypting KFX DRM voucher: amzn1.drm-voucher.v1.20b5309a-925f-470b-98ee-492a222cfe7f.voucher
Traceback (most recent call last):
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 105, in decrypt_voucher
    voucher.decryptvoucher()
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 886, in decryptvoucher
    b = pkcs7unpad(b, 16)
        ^^^^^^^^^^^^^^^^^
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 762, in pkcs7unpad
    _assert(paddinglen > 0 and paddinglen <= blocklen, "Incorrect padding - Wrong key")
  File "/Users/angela/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/angela/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 105, in decrypt_voucher
    voucher.decryptvoucher()
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 886, in decryptvoucher
    b = pkcs7unpad(b, 16)
        ^^^^^^^^^^^^^^^^^
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 762, in pkcs7unpad
    _assert(paddinglen > 0 and paddinglen <= blocklen, "Incorrect padding - Wrong key")
  File "/Users/angela/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.0 seconds
Found k4Mac kinf2018 file: /Users/angela/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/storage/.kinf2018
Found k4Mac kinf2018 file: /Users/angela/Library/Application Support/Kindle/storage/.kinf2018
trying username  b'angela'  on file  /Users/angela/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/storage/.kinf2018
trying IDString: b'47a0cbf2d31a'
trying IDString: b'47a0cbf2d365'
trying IDString: b'47a0cbf2d364'
trying IDString: b'5d419e52e639'
trying IDString: b'93e3811aca65'
trying IDString: b'f94cbb680975'
Decrypted key file using IDString 'f94cbb680975' and UserName 'angela'
trying username  b'angela'  on file  /Users/angela/Library/Application Support/Kindle/storage/.kinf2018
trying IDString: b'47a0cbf2d31a'
[12.89] splash screen hidden
[12.89] Started up in 12.89 seconds with 0 books
trying IDString: b'47a0cbf2d365'
trying IDString: b'47a0cbf2d364'
trying IDString: b'5d419e52e639'
trying IDString: b'93e3811aca65'
trying IDString: b'f94cbb680975'
Decrypted key file using IDString 'f94cbb680975' and UserName 'angela'
DeDRM v10.0.3: Found 1 new key
Decrypting KFX-ZIP ebook: nne36iri
Got DSN key from database key_1
Found 1 keys to try after 1.3 seconds
Decrypting KFX DRM voucher: amzn1.drm-voucher.v1.20b5309a-925f-470b-98ee-492a222cfe7f.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/angela/Library/Preferences/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/Users/angela/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/angela/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 105, in decrypt_voucher
    voucher.decryptvoucher()
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 886, in decryptvoucher
    b = pkcs7unpad(b, 16)
        ^^^^^^^^^^^^^^^^^
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 762, in pkcs7unpad
    _assert(paddinglen > 0 and paddinglen <= blocklen, "Incorrect padding - Wrong key")
  File "/Users/angela/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/angela/Library/Preferences/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/Users/angela/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/angela/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 105, in decrypt_voucher
    voucher.decryptvoucher()
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 886, in decryptvoucher
    b = pkcs7unpad(b, 16)
        ^^^^^^^^^^^^^^^^^
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 762, in pkcs7unpad
    _assert(paddinglen > 0 and paddinglen <= blocklen, "Incorrect padding - Wrong key")
  File "/Users/angela/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/angela/Library/Preferences/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/Users/angela/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/angela/Library/Preferences/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/Users/angela/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 1.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_plugins.dedrm.__init__", line 957, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/Users/angela/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/Users/angela/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 1.3 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
Package KFX (from KFX Input) 2.6.0: Packaging /var/folders/bx/bm80hzc54238w5hqx918qbd40000gn/C/calibre_7.1.0_tmp_5ptiw38q/nne36iri.kfx-zip
Processing container: B000S1LX5C_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 21, in run
    return self.run_kfx(path_to_ebook)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.kfx_input.package_filetype", line 32, in run_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 222, in decode_book
    container = self.get_container(datafile)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 331, 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 B000S1LX5C_EBOK.azw has DRM and cannot be converted
KFX metadata reader (from KFX Input) activated for /var/folders/bx/bm80hzc54238w5hqx918qbd40000gn/C/calibre_7.1.0_tmp_5ptiw38q/tt78_lgx_add_books/0/B000S1LX5C_EBOK.kfx-zip
ElleKayEm commented 10 months ago

For kfx format, you'll need DeDRM 10.0.9: https://github.com/noDRM/DeDRM_tools/releases/tag/v10.0.9

allindow commented 10 months ago

worked perfectly, thanks so much!