noDRM / DeDRM_tools

DeDRM tools for ebooks
7.05k stars 316 forks source link

Can't DeDRM KFX eInk Kindle Book #193

Open juandanielserrano opened 1 year ago

juandanielserrano commented 1 year ago

Hi, been trying to remove DRM from KFX book but can't seem to make it work. Device is Kindle Voyage (2014) running firmware v. 5.13.6

Thanks!

Using calibre Qt style: True
calibre Debug log
calibre 6.7.1  embedded-python: True
macOS-12.6-arm64-arm-64bit Darwin ('64bit', '')
('Darwin', '21.6.0', 'Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101')
Python 3.10.1
OSX: ('12.6', ('', '', ''), 'arm64')
Interface language: None
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (1, 49, 0) && DeDRM (10, 0, 3) && Package KFX (from KFX Input) (1, 49, 0) && KFX metadata reader (from KFX Input) (1, 49, 0) && KFX Input (1, 49, 0)
calibre 6.7.1  embedded-python: True
macOS-12.6-arm64-arm-64bit Darwin ('64bit', '')
('Darwin', '21.6.0', 'Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101')
Python 3.10.1
OSX: ('12.6', ('', '', ''), 'arm64')
Interface language: None
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (1, 49, 0) && DeDRM (10, 0, 3) && Package KFX (from KFX Input) (1, 49, 0) && KFX metadata reader (from KFX Input) (1, 49, 0) && KFX Input (1, 49, 0)
QPA platform: cocoa
devicePixelRatio: 2.0
logicalDpi: 72.0 x 72.0
physicalDpi: 149.00000223775552 x 149.0000022377555
[0.00] Starting up...
[0.06] Showing splash screen...
[0.39] splash screen shown
[0.39] Initializing db...
[0.43] db initialized
[0.43] Constructing main UI...
Key '' for shortcut Book list header menu is already used by Manage categories, ignoring
[0.98] main UI initialized...
[0.98] Hiding splash screen
Starting QuickView
Gather KFX-ZIP (from KFX Input) 1.49.0: Importing /Users/serrano/Downloads/The Spy and the Traitor_ The Greatest Espionage Story of the Cold War_B0782X9PFP.kfx
Gather KFX-ZIP (from KFX Input): Gathered 6 file(s) as /var/folders/fs/5t0s9zm520gf9by3zrdqtj500000gn/C/calibre_6.7.1_tmp_17zjarcd/wxaxwrws.kfx-zip
DeDRM v10.0.3: Trying to decrypt wxaxwrws.kfx-zip
Using Library AlfCrypto Python
Decrypting KFX-ZIP ebook: wxaxwrws
Found 1 keys to try after 0.1 seconds
Decrypting KFX DRM voucher: voucher
Traceback (most recent call last):
  File "/Users/serrano/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 105, in decrypt_voucher
    voucher.decryptvoucher()
  File "/Users/serrano/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 886, in decryptvoucher
    b = pkcs7unpad(b, 16)
  File "/Users/serrano/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 762, in pkcs7unpad
    _assert(paddinglen > 0 and paddinglen <= blocklen, "Incorrect padding - Wrong key")
  File "/Users/serrano/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/serrano/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 105, in decrypt_voucher
    voucher.decryptvoucher()
  File "/Users/serrano/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 886, in decryptvoucher
    b = pkcs7unpad(b, 16)
  File "/Users/serrano/Library/Preferences/calibre/plugins/DeDRM.zip/ion.py", line 762, in pkcs7unpad
    _assert(paddinglen > 0 and paddinglen <= blocklen, "Incorrect padding - Wrong key")
  File "/Users/serrano/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
No k4Mac kindle-info/rainier/kinf2011 files have been found.
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_plugins.dedrm.__init__", line 957, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "/Users/serrano/Library/Preferences/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/Users/serrano/Library/Preferences/calibre/plugins/DeDRM.zip/kfxdedrm.py", line 67, in processBook
    self.decrypt_voucher(totalpids)
  File "/Users/serrano/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 178, 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.1 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
Package KFX (from KFX Input) 1.49.0: Packaging /var/folders/fs/5t0s9zm520gf9by3zrdqtj500000gn/C/calibre_6.7.1_tmp_17zjarcd/wxaxwrws.kfx-zip
Processing container: CR!DRBG83EP115TKAXA4G64R9JNG0C1.kfx
Processing container: CR!H6S2RYV7HS26XE0V67FKQCXCRH95.kfx
Processing container: CR!WWFQBSRVS133F1R2861DJVG40TRJ.kfx
Processing container: The Spy and the Traitor_ The Greatest Espionage Story of the Cold War_B0782X9PFP.kfx
Running file type plugin Package KFX (from KFX Input) failed with traceback:
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 178, 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 83, in convert_to_single_kfx
    self.decode_book()
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 210, in decode_book
    container = self.get_container(datafile)
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 317, 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 The Spy and the Traitor_ The Greatest Espionage Story of the Cold War_B0782X9PFP.kfx has DRM and cannot be converted
KFX metadata reader (from KFX Input) activated for /var/folders/fs/5t0s9zm520gf9by3zrdqtj500000gn/C/calibre_6.7.1_tmp_17zjarcd/0xgxapw1_add_books/0/The Spy and the Traitor_ The Greatest Espionage Story of the Cold War_B0782X9PFP.kfx-zip
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 435, in get_file_type_metadata
  File "calibre_plugins.kfx_input.metadata_reader", line 28, in get_metadata
    md = YJ_Book(stream).get_metadata()
  File "calibre_plugins.kfx_input.kfxlib.yj_book", line 148, in get_metadata
    raise Exception("Failed to locate a KFX container with metadata")
Exception: Failed to locate a KFX container with metadata
[9.68] splash screen hidden
[9.68] Started up in 9.68 seconds with 97 books
Unable to open device <calibre.devices.kindle.driver.KINDLE2 object at 0x1148ef010>
Traceback (most recent call last):
  File "calibre/devices/usbms/device.py", line 728, in open
  File "calibre/devices/usbms/device.py", line 393, in open_osx
  File "calibre/devices/usbms/device.py", line 382, in osx_bsd_names
  File "calibre/devices/usbms/device.py", line 341, in _osx_bsd_names
calibre.devices.errors.DeviceError: Could not detect BSD names for Kindle 2/3/4/Touch/PaperWhite/Voyage Device Interface. Try rebooting.
Output from osx_get_usb_drives():
[]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre/gui2/device.py", line 225, in do_connect
  File "calibre/devices/usbms/device.py", line 731, in open
  File "calibre/devices/usbms/device.py", line 393, in open_osx
  File "calibre/devices/usbms/device.py", line 382, in osx_bsd_names
  File "calibre/devices/usbms/device.py", line 341, in _osx_bsd_names
calibre.devices.errors.DeviceError: Could not detect BSD names for Kindle 2/3/4/Touch/PaperWhite/Voyage Device Interface. Try rebooting.
Output from osx_get_usb_drives():
[]

Connect to device failed, retrying in 5 seconds...
Added The Spy and the Traitor The Greatest Espionage Story of the Cold War B0782X9PFP to db in: 0.0
Added 1 books in 0.6 seconds
ElleKayEm commented 1 year ago

You won't be able to decrypt a KFX format book which is directly from your Kindle. See this post for other methods: https://www.mobileread.com/forums/showthread.php?t=283371

juandanielserrano commented 1 year ago

Hi ElleKayEm

thank you so much for writing back. Will take a look at the other methods. :)