noDRM / DeDRM_tools

DeDRM tools for ebooks
7.16k stars 321 forks source link

Can't remove DRM from Kindle for PC 1.30 with AZW3 patch #123

Closed ghost closed 2 years ago

ghost commented 2 years ago

Question / bug report

I installed Kindle for PC 1.30 and the patch to make it download only in AZW3 format.

Anyway, I had to install a very outdated version of Python 3 in Wine for it to get as far as it did, but the crypto dependencies it needs require Visual C++ 14.0 which I can't install over Wine at all. It would be brilliant if it could, on Linux, use Python natively.

I'm using Calibre through Flatpak.

Which version of Calibre are you running?

6.2.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.30

Log output

DeDRM v10.0.3: Trying to decrypt B09T5JYMYH_EBOK.azw
Using Library AlfCrypto DLL/DYLIB/SO
MobiDeDrm v1.1.
Copyright © 2008-2020 The Dark Reverser, Apprentice Harper et al.
Decrypting Kindle Format 8 ebook: The Fascinating Origin of the Dominican Republic
Found 0 keys to try after 0.0 seconds
Crypto Type is: 2
DeDRM v10.0.3: Failed to decrypt with error: No key found in 0 PIDs tried.
DeDRM v10.0.3: Looking for new default Kindle Key after 0.0 seconds
DeDRM v10.0.3: Exception when getting default Kindle Key after 0.0 seconds
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 "/home/duds/.var/app/com.calibre_ebook.calibre/config/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/home/duds/.var/app/com.calibre_ebook.calibre/config/calibre/plugins/DeDRM.zip/mobidedrm.py", line 501, in processBook
    raise DrmException("No key found in {0:d} PIDs tried.".format(len(goodpids)))
mobidedrm.DrmException: No key found in 0 PIDs tried.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 975, in KindleMobiDecrypt
    defaultkeys, defaultnames = WineGetKeys(scriptpath, ".k4i",dedrmprefs['kindlewineprefix'])
  File "/home/duds/.var/app/com.calibre_ebook.calibre/config/calibre/plugins/DeDRM.zip/wineutils.py", line 96, in WineGetKeys
    pyexec = WinePythonCLI(wineprefix)
  File "/home/duds/.var/app/com.calibre_ebook.calibre/config/calibre/plugins/DeDRM.zip/wineutils.py", line 59, in __init__
    self.check_call(["-c", self.py3_test])
  File "/home/duds/.var/app/com.calibre_ebook.calibre/config/calibre/plugins/DeDRM.zip/wineutils.py", line 84, in check_call
    subprocess.check_call(self.python_exec + cli_args, env=env_dict,
  File "subprocess.py", line 364, in check_call
  File "subprocess.py", line 345, in call
  File "subprocess.py", line 966, in __init__
  File "subprocess.py", line 1842, in _execute_child
FileNotFoundError: [Errno 2] No existe el fichero o el directorio: 'wine'
DeDRM v10.0.3: Ultimately failed to decrypt after 0.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_plugins.dedrm.__init__", line 957, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "/home/duds/.var/app/com.calibre_ebook.calibre/config/calibre/plugins/DeDRM.zip/k4mobidedrm.py", line 261, in GetDecryptedBook
    mb.processBook(totalpids)
  File "/home/duds/.var/app/com.calibre_ebook.calibre/config/calibre/plugins/DeDRM.zip/mobidedrm.py", line 501, in processBook
    raise DrmException("No key found in {0:d} PIDs tried.".format(len(goodpids)))
mobidedrm.DrmException: No key found in 0 PIDs tried.

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.0 seconds. Read the FAQs at noDRM's repository: https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md
ElleKayEm commented 2 years ago

Try using the official Linux calibre: https://calibre-ebook.com/download_linux

ghost commented 2 years ago

Try using the official Linux calibre: https://calibre-ebook.com/download_linux

Same issue. Still tries using Python inside of wine.

noDRM commented 2 years ago

I did some crypto cleanup in 10.0.3, maybe I fucked something up. Would you mind testing 10.0.2 and see if the same error occurs with that, and post a log of the same book with 10.0.2?

ElleKayEm commented 2 years ago

Would they need to use a previous 5.x version of calibre with 10.0.2?

noDRM commented 2 years ago

Damn, I didn't check the version. Yes, for 10.0.2 you'll probably need Calibre 5.x. I can try to make a patched version of 10.0.2 later that just has the Calibre-6 fixes and none of the other 10.0.3 changes, just in case this issue is related to Calibre 6 somehow (but I doubt that).

road2larissa commented 2 years ago

Hi there, I'm also struggling to remove DRM from a .azw in Windows. I tried with Calibre 6.3 and DeDRM 10.3, then downgraded to Calibre 5.44 and DeDRM 10.2. I get the following:

calibre, version 5.44.0 ERROR: Conversion failed:

Failed to convert: B093GB94J3 EBOK

This is an Amazon KFX book. It cannot be processed. See here for information on how to handle KFX books.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "runpy.py", line 194, in _run_module_as_main File "runpy.py", line 87, in _run_code File "site.py", line 82, in File "site.py", line 77, in main File "site.py", line 49, in run_entry_point File "calibre\utils\ipc\worker.py", line 215, in main File "calibre\gui2\convert\gui_conversion.py", line 38, in gui_convert_override File "calibre\gui2\convert\gui_conversion.py", line 25, in gui_convert File "calibre\ebooks\conversion\plumber.py", line 1108, in run File "calibre\customize\conversion.py", line 242, in call File "calibre\ebooks\conversion\plugins\mobi_input.py", line 33, in convert File "calibre\ebooks\mobi\reader\mobi6.py", line 89, in init calibre.ebooks.mobi.reader.mobi6.KFXError: This is an Amazon KFX book. It cannot be processed. See here for information on how to handle KFX books.

Convert book 1 of 1 (B093GB94J3 EBOK) DeDRM v10.0.2: Trying to decrypt acha7eu4.azw Using Library AlfCrypto DLL/DYLIB/SO Using Library AlfCrypto DLL/DYLIB/SO DeDRM v10.0.2: Failed to decrypt with error: The .kfx DRMION file cannot be decrypted by itself. A .kfx-zip archive containing a DRM voucher is required. DeDRM v10.0.2: Looking for new default Kindle Key after 0.1 seconds searching for kinfoFiles in C:\Users\Nick\AppData\Local Found K4PC 1.25+ kinf2018 file: C:\Users\Nick\AppData\Local\Amazon\Kindle\storage.kinf2018 Decrypted key file using IDString '3696669176' and UserName 'Nick' DeDRM v10.0.2: Found 1 new key DeDRM v10.0.2: Ultimately failed to decrypt after 3.0 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md Conversion options changed from defaults: verbose: 2 read_metadata_from_opf: 'C:\Users\Nick\AppData\Local\Temp\calibre_f6xrap6h\fhazr446.opf' Resolved conversion options calibre version: 5.44.0 {'asciiize': False, 'author_sort': None, 'authors': None, 'base_font_size': 0.0, 'book_producer': None, 'change_justification': 'original', 'chapter': "//[((name()='h1' or name()='h2') and re:test(., " "'\s((chapter|book|section|part)\s+)|((prolog|prologue|epilogue)(\s+|$))', " "'i')) or @class = 'chapter']", 'chapter_mark': 'pagebreak', 'comments': None, 'cover': None, 'debug_pipeline': None, 'dehyphenate': True, 'delete_blank_paragraphs': True, 'disable_font_rescaling': False, 'dont_split_on_page_breaks': False, 'duplicate_links_in_toc': False, 'embed_all_fonts': False, 'embed_font_family': None, 'enable_heuristics': False, 'epub_flatten': False, 'epub_inline_toc': False, 'epub_toc_at_end': False, 'epub_version': '2', 'expand_css': False, 'extra_css': None, 'extract_to': None, 'filter_css': '', 'fix_indents': True, 'flow_size': 260, 'font_size_mapping': None, 'format_scene_breaks': True, 'html_unwrap_factor': 0.4, 'input_encoding': None, 'input_profile': <calibre.customize.profiles.InputProfile object at 0x00000147CD76EFA0>, 'insert_blank_line': False, 'insert_blank_line_size': 0.5, 'insert_metadata': False, 'isbn': None, 'italicize_common_cases': True, 'keep_ligatures': False, 'language': None, 'level1_toc': None, 'level2_toc': None, 'level3_toc': None, 'line_height': 0.0, 'linearize_tables': False, 'margin_bottom': 5.0, 'margin_left': 5.0, 'margin_right': 5.0, 'margin_top': 5.0, 'markup_chapter_headings': True, 'max_toc_links': 50, 'minimum_line_height': 120.0, 'no_chapters_in_toc': False, 'no_default_epub_cover': False, 'no_inline_navbars': False, 'no_svg_cover': False, 'output_profile': <calibre.customize.profiles.OutputProfile object at 0x00000147CD7642B0>, 'page_breaks_before': "//*[name()='h1' or name()='h2']", 'prefer_metadata_cover': False, 'preserve_cover_aspect_ratio': False, 'pretty_print': True, 'pubdate': None, 'publisher': None, 'rating': None, 'read_metadata_from_opf': 'C:\Users\Nick\AppData\Local\Temp\calibre_f6xrap6h\fhazr446.opf', 'remove_fake_margins': True, 'remove_first_image': False, 'remove_paragraph_spacing': False, 'remove_paragraph_spacing_indent_size': 1.5, 'renumber_headings': True, 'replace_scene_breaks': '', 'search_replace': '[]', 'series': None, 'series_index': None, 'smarten_punctuation': False, 'sr1_replace': None, 'sr1_search': None, 'sr2_replace': None, 'sr2_search': None, 'sr3_replace': None, 'sr3_search': None, 'start_reading_at': None, 'subset_embedded_fonts': False, 'tags': None, 'timestamp': None, 'title': None, 'title_sort': None, 'toc_filter': None, 'toc_threshold': 6, 'toc_title': None, 'transform_css_rules': '[]', 'transform_html_rules': '[]', 'unsmarten_punctuation': False, 'unwrap_lines': True, 'use_auto_toc': False, 'verbose': 2} Running file type plugin DeDRM failed with traceback: Traceback (most recent call last): File "calibre_plugins.dedrm.init", line 795, in KindleMobiDecrypt File "calibre_plugins.dedrm.k4mobidedrm", line 214, in GetDecryptedBook calibre_plugins.dedrm.k4mobidedrm.DrmException: The .kfx DRMION file cannot be decrypted by itself. A .kfx-zip archive containing a DRM voucher is required.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "calibre\customize\ui.py", line 175, in _run_filetype_plugins File "calibre_plugins.dedrm.init", line 888, in run File "calibre_plugins.dedrm.init", line 838, in KindleMobiDecrypt calibre_plugins.dedrm.DeDRMError: DeDRM v10.0.2: Ultimately failed to decrypt after 3.0 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md DeDRM v10.0.2: Trying to decrypt acha7eu4.azw DeDRM v10.0.2: Failed to decrypt with error: The .kfx DRMION file cannot be decrypted by itself. A .kfx-zip archive containing a DRM voucher is required. DeDRM v10.0.2: Looking for new default Kindle Key after 0.0 seconds searching for kinfoFiles in C:\Users\Nick\AppData\Local Found K4PC 1.25+ kinf2018 file: C:\Users\Nick\AppData\Local\Amazon\Kindle\storage.kinf2018 Decrypted key file using IDString '3696669176' and UserName 'Nick' DeDRM v10.0.2: Found 1 new key DeDRM v10.0.2: Ultimately failed to decrypt after 3.0 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/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 795, in KindleMobiDecrypt File "calibre_plugins.dedrm.k4mobidedrm", line 214, in GetDecryptedBook calibre_plugins.dedrm.k4mobidedrm.DrmException: The .kfx DRMION file cannot be decrypted by itself. A .kfx-zip archive containing a DRM voucher is required.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "calibre\customize\ui.py", line 175, in _run_filetype_plugins File "calibre_plugins.dedrm.init", line 888, in run File "calibre_plugins.dedrm.init", line 838, in KindleMobiDecrypt calibre_plugins.dedrm.DeDRMError: DeDRM v10.0.2: Ultimately failed to decrypt after 3.0 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md InputFormatPlugin: MOBI Input running on C:\Users\Nick\AppData\Local\Temp\calibre_f6xrap6h\acha7eu4.azw Traceback (most recent call last): File "calibre\ebooks\conversion\plugins\mobi_input.py", line 27, in convert File "calibre\ebooks\mobi\reader\mobi6.py", line 89, in init calibre.ebooks.mobi.reader.mobi6.KFXError: This is an Amazon KFX book. It cannot be processed. See https://www.mobileread.com/forums/showthread.php?t=283371 for information on how to handle KFX books.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "runpy.py", line 194, in _run_module_as_main File "runpy.py", line 87, in _run_code File "site.py", line 82, in File "site.py", line 77, in main File "site.py", line 49, in run_entry_point File "calibre\utils\ipc\worker.py", line 215, in main File "calibre\gui2\convert\gui_conversion.py", line 38, in gui_convert_override File "calibre\gui2\convert\gui_conversion.py", line 25, in gui_convert File "calibre\ebooks\conversion\plumber.py", line 1108, in run File "calibre\customize\conversion.py", line 242, in call File "calibre\ebooks\conversion\plugins\mobi_input.py", line 33, in convert File "calibre\ebooks\mobi\reader\mobi6.py", line 89, in init calibre.ebooks.mobi.reader.mobi6.KFXError: This is an Amazon KFX book. It cannot be processed. See https://www.mobileread.com/forums/showthread.php?t=283371 for information on how to handle KFX books.

ghost commented 2 years ago

I did some crypto cleanup in 10.0.3, maybe I fucked something up. Would you mind testing 10.0.2 and see if the same error occurs with that, and post a log of the same book with 10.0.2?

No luck here either. Same problem using Calibre 5.44.0 and DeDRM_tools 10.0.2. It tries to run the Python script inside of Wine, instead of natively, which I think is the problem. I can't install Python and the script's dependencies inside Wine.

DeDRM v10.0.2: Trying to decrypt B09T5JYMYH_EBOK.azw
Using Library AlfCrypto DLL/DYLIB/SO
Using Library AlfCrypto DLL/DYLIB/SO
MobiDeDrm v1.0.
Copyright © 2008-2020 The Dark Reverser, Apprentice Harper et al.
Decrypting Kindle Format 8 ebook: The Fascinating Origin of the Dominican Republic
Found 0 keys to try after 0.0 seconds
Crypto Type is: 2
DeDRM v10.0.2: Failed to decrypt with error: No key found in 0 PIDs tried.
DeDRM v10.0.2: Looking for new default Kindle Key after 0.0 seconds
Application could not be started, or no application associated with the specifie
d file.
ShellExecuteEx failed: File not found.

DeDRM v10.0.2: wine py.exe -3 is not python3
Application could not be started, or no application associated with the specifie
d file.
ShellExecuteEx failed: File not found.

DeDRM v10.0.2: wine python3.exe is not python3
Application could not be started, or no application associated with the specifie
d file.
ShellExecuteEx failed: File not found.

DeDRM v10.0.2: wine python.exe is not python3
wine: failed to open "C:\\Python27\\python.exe": c0000135
DeDRM v10.0.2: wine C:\Python27\python.exe does not exist
DeDRM v10.0.2: Unable to find python3 executable in WINEPREFIX=""
DeDRM v10.0.2: Ultimately failed to decrypt after 0.5 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/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 795, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 244, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.mobidedrm", line 500, in processBook
    raise DrmException("No key found in {0:d} PIDs tried.".format(len(goodpids)))
calibre_plugins.dedrm.mobidedrm.DrmException: No key found in 0 PIDs tried.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre/customize/ui.py", line 175, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 888, in run
    decrypted_ebook = self.KindleMobiDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 838, in KindleMobiDecrypt
    raise DeDRMError("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
calibre_plugins.dedrm.DeDRMError: DeDRM v10.0.2: Ultimately failed to decrypt after 0.5 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
noDRM commented 2 years ago

The script needs to be executed in WINE - after all, it needs to load / extract the cryptography keys from the Kindle4PC installation that's running under WINE. Taking the Windows script and just running it under wine is way easier than writing a wine-aware Linux python script that can run under a native Linux Python interpreter and still read data from an application that's running under WINE.

What's the issue with running Python under WINE? As far as I know, that's the solution most Linux users used to get the Kindle 4 PC key.

As a workaround - but I'm not sure if that's going to work - you could try running the Windows version of Calibre in the same WINEPREFIX as your Kindle4PC installation, then run the plugin inside that. That should use all the python binaries and packages that come included with the Windows Calibre. Once the plugin is loaded and you've dumped the Kindle 4 PC key, you can then extract the key from the Windows Calibre and import it in your Linux calibre.

ghost commented 2 years ago

The script needs to be executed in WINE - after all, it needs to load / extract the cryptography keys from the Kindle4PC installation that's running under WINE. Taking the Windows script and just running it under wine is way easier than writing a wine-aware Linux python script that can run under a native Linux Python interpreter and still read data from an application that's running under WINE.

What's the issue with running Python under WINE? As far as I know, that's the solution most Linux users used to get the Kindle 4 PC key.

As a workaround - but I'm not sure if that's going to work - you could try running the Windows version of Calibre in the same WINEPREFIX as your Kindle4PC installation, then run the plugin inside that. That should use all the python binaries and packages that come included with the Windows Calibre. Once the plugin is loaded and you've dumped the Kindle 4 PC key, you can then extract the key from the Windows Calibre and import it in your Linux calibre.

The problem is it's hard to find a Python 3 version that works with WINE (I had to use a really outdated one before forgetting the version after switching distros two days ago due to a separate issue), and then there's the Python crypto module dependencies themselves which include Visual C++ 14.0 (can't install in WINE at all).

I'll try again as I'm on a new setup now anyway, so may as well, but idk how well it'll go ; ;

ghost commented 2 years ago

Log after installing the latest Python 3 with WINE after changing its system version to Windows 8.1 in winecfg:

DeDRM v10.0.2: Trying to decrypt B09T5JYMYH_EBOK.azw
Using Library AlfCrypto DLL/DYLIB/SO
Using Library AlfCrypto DLL/DYLIB/SO
MobiDeDrm v1.0.
Copyright © 2008-2020 The Dark Reverser, Apprentice Harper et al.
Decrypting Kindle Format 8 ebook: The Fascinating Origin of the Dominican Republic
Found 0 keys to try after 0.0 seconds
Crypto Type is: 2
DeDRM v10.0.2: Failed to decrypt with error: No key found in 0 PIDs tried.
DeDRM v10.0.2: Looking for new default Kindle Key after 0.0 seconds
DeDRM v10.0.2: Python3 exec found as wine py.exe -3
DeDRM v10.0.2: Running kindlekey.py under Wine
kindlekey.py v3.0
Copyright © 2010-2020 by some_updates, Apprentice Harper et al.
searching for kinfoFiles in C:\users\duds\AppData\Local
Found K4PC 1.25+ kinf2018 file: C:\users\duds\AppData\Local\Amazon\Kindle\storage\.kinf2018
Traceback (most recent call last):
  File "Z:\home\duds\.config\calibre\plugins\DeDRM\libraryfiles\kindlekey.py", line 1835, in <module>
    sys.exit(cli_main())
  File "Z:\home\duds\.config\calibre\plugins\DeDRM\libraryfiles\kindlekey.py", line 1776, in cli_main
    if not getkey(outpath, files):
  File "Z:\home\duds\.config\calibre\plugins\DeDRM\libraryfiles\kindlekey.py", line 1709, in getkey
    keys = kindlekeys(files)
  File "Z:\home\duds\.config\calibre\plugins\DeDRM\libraryfiles\kindlekey.py", line 1696, in kindlekeys
    key = getDBfromFile(file)
  File "Z:\home\duds\.config\calibre\plugins\DeDRM\libraryfiles\kindlekey.py", line 1146, in getDBfromFile
    from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'
DeDRM v10.0.2: Wine subprocess call error: 1
DeDRM v10.0.2: Found and decrypted 0 key files
DeDRM v10.0.2: Found 2 new keys
MobiDeDrm v1.0.
Copyright © 2008-2020 The Dark Reverser, Apprentice Harper et al.
Decrypting Kindle Format 8 ebook: The Fascinating Origin of the Dominican Republic
Error getting PIDs from database default_key_1: list indices must be integers or slices, not str
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 795, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 244, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.mobidedrm", line 500, in processBook
    raise DrmException("No key found in {0:d} PIDs tried.".format(len(goodpids)))
calibre_plugins.dedrm.mobidedrm.DrmException: No key found in 0 PIDs tried.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre_plugins.dedrm.kgenpids", line 299, in getPidList
    pidlst.extend(map(bytes,getK4Pids(md1, md2, kDatabase)))
  File "calibre_plugins.dedrm.kgenpids", line 209, in getK4Pids
    kindleAccountToken = bytearray.fromhex((kindleDatabase[1])['kindle.account.tokens'])
TypeError: list indices must be integers or slices, not str
Error getting PIDs from database default_key_2: list indices must be integers or slices, not str
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 795, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 244, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.mobidedrm", line 500, in processBook
    raise DrmException("No key found in {0:d} PIDs tried.".format(len(goodpids)))
calibre_plugins.dedrm.mobidedrm.DrmException: No key found in 0 PIDs tried.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre_plugins.dedrm.kgenpids", line 299, in getPidList
    pidlst.extend(map(bytes,getK4Pids(md1, md2, kDatabase)))
  File "calibre_plugins.dedrm.kgenpids", line 209, in getK4Pids
    kindleAccountToken = bytearray.fromhex((kindleDatabase[1])['kindle.account.tokens'])
TypeError: list indices must be integers or slices, not str
Found 0 keys to try after 2.9 seconds
Crypto Type is: 2
DeDRM v10.0.2: Ultimately failed to decrypt after 2.9 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/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 795, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 244, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.mobidedrm", line 500, in processBook
    raise DrmException("No key found in {0:d} PIDs tried.".format(len(goodpids)))
calibre_plugins.dedrm.mobidedrm.DrmException: No key found in 0 PIDs tried.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre/customize/ui.py", line 175, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 888, in run
    decrypted_ebook = self.KindleMobiDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 838, in KindleMobiDecrypt
    raise DeDRMError("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
calibre_plugins.dedrm.DeDRMError: DeDRM v10.0.2: Ultimately failed to decrypt after 2.9 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md

Now I'll try getting those dependencies from pip, but this is where I last got stuck.

ghost commented 2 years ago

I actually managed to install pycryptodome without the Visual C++ requirement thrust onto me, but now I get this error, which I don't know how to get through at all...

DeDRM v10.0.2: Trying to decrypt B09T5JYMYH_EBOK.azw
Using Library AlfCrypto DLL/DYLIB/SO
Using Library AlfCrypto DLL/DYLIB/SO
MobiDeDrm v1.0.
Copyright © 2008-2020 The Dark Reverser, Apprentice Harper et al.
Decrypting Kindle Format 8 ebook: The Fascinating Origin of the Dominican Republic
Found 0 keys to try after 0.0 seconds
Crypto Type is: 2
DeDRM v10.0.2: Failed to decrypt with error: No key found in 0 PIDs tried.
DeDRM v10.0.2: Looking for new default Kindle Key after 0.0 seconds
DeDRM v10.0.2: Python3 exec found as wine py.exe -3
DeDRM v10.0.2: Running kindlekey.py under Wine
kindlekey.py v3.0
Copyright © 2010-2020 by some_updates, Apprentice Harper et al.
searching for kinfoFiles in C:\users\duds\AppData\Local
Found K4PC 1.25+ kinf2018 file: C:\users\duds\AppData\Local\Amazon\Kindle\storage\.kinf2018
Decrypted key file using IDString '1124073472' and UserName 'duds'
Saved a key to Z:\home\duds\.config\calibre\plugins\DeDRM\libraryfiles\winekeysdir\kindlekey1.k4i
DeDRM v10.0.2: Found and decrypted 1 key file
DeDRM v10.0.2: Found 2 new keys
MobiDeDrm v1.0.
Copyright © 2008-2020 The Dark Reverser, Apprentice Harper et al.
Decrypting Kindle Format 8 ebook: The Fascinating Origin of the Dominican Republic
Error getting PIDs from database default_key_1: list indices must be integers or slices, not str
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 795, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 244, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.mobidedrm", line 500, in processBook
    raise DrmException("No key found in {0:d} PIDs tried.".format(len(goodpids)))
calibre_plugins.dedrm.mobidedrm.DrmException: No key found in 0 PIDs tried.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre_plugins.dedrm.kgenpids", line 299, in getPidList
    pidlst.extend(map(bytes,getK4Pids(md1, md2, kDatabase)))
  File "calibre_plugins.dedrm.kgenpids", line 209, in getK4Pids
    kindleAccountToken = bytearray.fromhex((kindleDatabase[1])['kindle.account.tokens'])
TypeError: list indices must be integers or slices, not str
Error getting PIDs from database default_key_2: list indices must be integers or slices, not str
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 795, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 244, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.mobidedrm", line 500, in processBook
    raise DrmException("No key found in {0:d} PIDs tried.".format(len(goodpids)))
calibre_plugins.dedrm.mobidedrm.DrmException: No key found in 0 PIDs tried.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre_plugins.dedrm.kgenpids", line 299, in getPidList
    pidlst.extend(map(bytes,getK4Pids(md1, md2, kDatabase)))
  File "calibre_plugins.dedrm.kgenpids", line 209, in getK4Pids
    kindleAccountToken = bytearray.fromhex((kindleDatabase[1])['kindle.account.tokens'])
TypeError: list indices must be integers or slices, not str
Found 0 keys to try after 2.9 seconds
Crypto Type is: 2
DeDRM v10.0.2: Ultimately failed to decrypt after 2.9 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/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 795, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 244, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.mobidedrm", line 500, in processBook
    raise DrmException("No key found in {0:d} PIDs tried.".format(len(goodpids)))
calibre_plugins.dedrm.mobidedrm.DrmException: No key found in 0 PIDs tried.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre/customize/ui.py", line 175, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 888, in run
    decrypted_ebook = self.KindleMobiDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 838, in KindleMobiDecrypt
    raise DeDRMError("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
calibre_plugins.dedrm.DeDRMError: DeDRM v10.0.2: Ultimately failed to decrypt after 2.9 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
ghost commented 2 years ago

I fixed it by just going back to the latest versions of both Calibre and DeDRM_tools and using installing pycryptodome on pip through WINE. The latest versions of Python 3 do work in WINE as long as you set your system to Windows 8.1 on winecfg and run it in a 32-bit prefix.