Closed ghost closed 3 years ago
Was the book downloaded with the current installation of Kindle for Mac located on the same machine and user as calibre with DeDRM?
Yes. But not the "current" installation of Kindle for Mac. It was version 1.26.1
For some reason, DeDRM is unable to decrypt the key that it is finding. Possibly something left behind from a previous installation. Try deleting this file: /Users/lisa/Library/Application Support/Kindle/storage/.kinf2018 Then remove and re-add the book.
So I decided to just delete everything and start over. I uninstalled Kindle, Calibre, deDRM plugin. (I also deleted that entire Kindle folder under Application Support (and anywhere else I found Kindle App items). I reinstalled everything in the versions noted above. Tried to import a book from my Amazon library and received the same error. I went to the /Users/lisa/Library/Application Support/Kindle/storage/ folder and that .kinf2018 file was there again. So I deleted it (again). When I went back into Kindle for Mac, my "device registration" was deleted, so I had to re-register that. But it kept crashing. Once I de-registered from Amazon's site, it let me re-register it. I deleted the book and tried one more time to download and import the book into Calibre, and still received the cannot convert error. So I did it all one more time to gather the log. That .kinf2018 keeps recreating. I don't know if that's expected or not.
And you redownloaded the book after this new installation? And added the fresh copy to calibre?
Yes, I deleted from Calibre, deleted from My Kindle Library and redownloaded... multiple times.
I also have all these same versions installed on a MacBook running Catalina, and it all works fine. I'm suspicious that it has something to do with Big Sur.
Do you have KFX downloads disabled?
I think so. If you mean, running: chmod -x /Applications/Kindle.app/Contents/MacOS/renderer-test
Then yes. If not, then probably not.
Yes, that's what I meant. I don't know what else to suggest. Seems like it might be something to do with Big Sur. But I have no idea.
Are you one of the developers? If not, are they monitoring this thread? More and more users will be upgrading to Big Sur. Seems like this might be something they'd want to look into. I'm willing to try any other ideas to help debug this including (but not limited to), uninstalling, reinstalling, changing up the order of steps, etc.
I'm not. As you say, I'm sure there will be more reports if Big Sur is the issue, and @apprenticeharper and company will become aware. I will also ask around myself.
I tried posting to mobileread, but they closed it immediately. I didn't even post instructions, I just spoke about the problem in the abstract. I don't know where else to post to see if others are having the same issue.
Yeah, I think they were a little overzealous with that. Hopefully we get some responses from the other thread there.
I decided to look at the customization of deDRM and the Keys are blank! Gonna try copying them from my Catalina Mac...
Saving the keys from my MacBook running Catalina and importing them to my Mac mini running Big Sur did not work: I still received the "this book is locked by DRM" error.
If I click the plus sign, I get this error:
So the problem seems to lie with the non-existence of the proper keys. Maybe @apprenticeharper can offer some help?
DeDRM will only automatically save a key that successfully decrypted a book. So that's why nothing was there at first. I think the error message you got when trying to add the key may be because DeDRM is not able to decrypt the key, not because it can't find one at all. At least that's what the log from importing a book seemed to indicate. And the key for each installation of the Kindle is unique (even a reinstallation on the same machine which requires you to login again can change the key). So that's why the keys from your Catalina don't work on books from the Big Sur Kindle app. I'd be curious to see if you could decrypt a book from the Catalina Kindle app with the Big Sur calibre/DeDRM setup with the Catalina's imported keys.
Ha! So that worked. I downloaded the book on my Catalina MacBook in Kindle for Mac. Then I copied that .azw file from the Catalina Mac to my Big Sur Mac. (Big Sur Mac had the keys from the Catalina Mac.) Catalina did it's import and it removed the DRM and created the .azw3 (and .epub) files!
So how do we get the proper keys for Big Sur???
Therein lies the problem. It appears that DeDRM can't decrypt the key for the Big Sur installation of the Kindle app. It's beyond my knowledge of this to see why. But at least that might narrow the issue for those who can figure it out.
If I use the "download via usb" method, it all works fine! TBH, that's easier anyway.
Ah, didn't know you had an E-ink Kindle. This will still need looking at, but at least book decryption seems fine with Big Sur. It's just getting and decrypting the key for Kindle for Mac that is giving trouble.
Thanks for all your help. If and when someone has time to fix this, just @ me or something and I'll be happy to test it.
Patch kindle for mac catalina and Big Sur with following command, chmod -x /Applications/Kindle.app/Contents/MacOS/renderer-test OR sudo chmod -x /Applications/Kindle.app/Contents/MacOS/renderer-test, Then right-click kindle book to download. DON'T double click or open it before the drm removing. Convert Kindle KFX to EPUB/PDF Free on macOS Big Sur (Effective)
Remember that you have to do this every time the Kindle app is upgraded.
On 11/24/20 9:16 PM, Augilare wrote:
Patch kindle for mac catalina and Big Sur with following command, chmod -x /Applications/Kindle.app/Contents/MacOS/renderer-test OR sudo chmod -x /Applications/Kindle.app/Contents/MacOS/renderer-test, Then right-click kindle book to download. DON'T double click or open it before the drm removing. Convert Kindle KFX to EPUB/PDF Free on macOS Big Sur (Effective) https://garydadic.medium.com/convert-kindle-kfx-to-epub-pdf-free-on-mac-10-15-catalina-included-7ea1d7d2b609
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apprenticeharper/DeDRM_tools/issues/1369#issuecomment-733491539, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWVX7LZDYKDEQFUF2PZNLDSRSOKJANCNFSM4T4K6REA.
-- "There are more things in heaven and earth, Horatio, Than are dreamt of in your philosophy. "
@Augilare The OP did this. The problem here is decrypting the Kindle for Mac key. Not KFX format (which can be decrypted if from K4Mac 1.26 anyway).
@Lisa10101 — have you tried this with K4Mac 1.30?
The blogger referenced by @Augilare reports success using Calibre 4.23, DeDRM 6.8, K4Mac 1.30 and Mac mini M1 Big Sur.
@ZolaLa9 I have not tried 1.30, mostly because DeDRM 6.8 states it's not compatible with anything over 1.26. If I give it a try later, I'll report back.
@Lisa10101 That is in regard to KFX format. If you have KFX downloads disabled (chmod -x ...), you can use 1.30.
@Lisa10101 — This post is updated regularly and tends to have the most up-to-date info on K4Mac compatibility: https://www.mobileread.com/forums/showpost.php?p=3819708&postcount=508
Not sure how active you are on MobileRead, but there is also active discussion happening here on DeDRM 7.0 beta and Mac: https://www.mobileread.com/forums/showthread.php?s=32fb948c4aa246ac91444f4a00ca6632&p=4061946#post4061946
I'm not interested in installing things that are "beta" or "in development", so I felt this was the better place to look for compatibility between DeDRM and Calibre: https://apprenticealf.wordpress.com It was just updated today, so I was going off the previous post which says this:
This means that this release now works with version 1.26 and earlier of Kindle for PC and Kindle for Mac.
and this:
Thanks to work by several people, the DeDRM calibre plugin can decrypt KFX format ebooks from Amazon as long as they are downloaded with Kindle for Mac/PC prior to version 1.27.
@ZolaLa9 @Augilare Just tried it using Kindle for Mac 1.30 (and yes, I did the step to disable KFX before downloading the book) and it did not work:
I'm pretty skeptical that the author of that blog actually tested this on a new Mac mini M1 running Big Sur.
And the next sentence:
Books which require the later versions of Kindle for PC/Mac will not be able to be decrypted at this time.
But non-KFX formats can be decrypted from the later versions.
@ElleKayEm It doesn't say "But non-KFX formats can be decrypted from the later versions." There is nothing in that post from June 18, 2020 that would lead one to believe you could use DeDRM 6.8 with Kindle for Mac 1.30. Regardless... if all or most of your books are KFX formats, then anything over 1.26 does not work. (I don't want to muddy the waters here by discussing other tests.. but before I switched to Mac mini M1 Big Sur, I was using a MacBook Catalina and I was unable to use 1.30 there (disabling KFX of course) with DeDRM 6.8. I had to downgrade to 1.26 and disable KFX for it to work. )
Have a look at this old issue #255. It seemed to be a similar issue with DeDRM not being able to decrypt the Kindle for Mac key. Sounds like the key encryption is tied to an ID number from the internal drive. Perhaps something with Big Sur or your particular setup is causing DeDRM to grab the wrong number.
(DeDRM 6.8 addressed two things: decryption of the new Kindle for PC/Mac key which first appeared in version 1.25 and new KFX DRM used in versions 1.25-1.26. A further change to KFX DRM happened beginning with 1.27 which DeDRM does not handle yet. But the DRM on the older formats that you get when you disable KFX format downloads has not changed.)
DeDRM uses a variety of cryptographic routines that do much of the same thing due to its history as a bunch of separate tools created by different individuals. I believe that the problem with Big Sur is caused by one of those no longer being available or having its named changed. This and others like it could be eliminated in favor of the cryptography library built into calibre.
It looks like the plugin is failing to load libcrypto
because of a change in the way that Big Sur handles loading dynamic libraries. The libcrypto.dylib
file no longer exists on disk, so if the plugin is running on a Mac then the code in https://github.com/apprenticeharper/DeDRM_tools/blob/v6.8.0/DeDRM_plugin/kindlekey.py#L1184-L1186 needs to try loading /usr/lib/libcrypto.dylib
directly when libcrypto
is None
and handling an exception if it doesn't work after that. I tested this with Big Sur, Kindle for Mac 1.30, DeDRM 6.8.0 and Calibre 4.21 and it was able to handle getting the key just fine.
See https://github.com/saltstack/salt/issues/57787 for more info re: failing to load dylibs in Big Sur.
It does seem like loading Calibre's version of OpenSSL would solve this once and for all, but I'm happy to put in a PR with the fix.
@protochron — AWESOME!!! If you would put in a PR, it would be mucho appreciated!
before I switched to Mac mini M1 Big Sur, I was using a MacBook Catalina and I was unable to use 1.30 there (disabling KFX of course) with DeDRM 6.8. I had to downgrade to 1.26 and disable KFX for it to work.
@Lisa10101 — Catalina + K4Mac 1.30 + Calibre 4.23 + Alf 6.8.0 = working for me
I don't have Big Sur, and I'm still working on other Python 3 problems. A pull request that fixed this problem would be much appreciated.
azw
file:DeDRM v7.0.0: Trying to decrypt book.azw
Using Library AlfCrypto Python
Using Library AlfCrypto Python
MobiDeDrm v1.0.
Copyright © 2008-2020 The Dark Reverser, Apprentice Harper et al.
Decrypting Kindle Format 8 ebook: [title]
Got SerialNumber from database default_key
Got UsernameHash from database default_key
Found 4 keys to try after 0.0 seconds
Crypto Type is: 2
DeDRM v7.0.0: Failed to decrypt with error: No key found in 4 keys tried.
DeDRM v7.0.0: Looking for new default Kindle Key after 0.0 seconds
Found k4Mac kinf2018 file: /Users/jcs/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/storage/.kinf2018
Found k4Mac kinf2018 file: /Users/jcs/Library/Application Support/Kindle/storage/.kinf2018
trying username b'jcs' on file /Users/jcs/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/storage/.kinf2018
trying IDString: b'bb8ce...'
trying IDString: b'bb8ce...'
trying IDString: b'bd9b4...'
Decrypted key file using IDString 'bd9b4...' and UserName 'jcs'
trying username b'jcs' on file /Users/jcs/Library/Application Support/Kindle/storage/.kinf2018
trying IDString: b'bb8ce...'
trying IDString: b'bb8ce...'
trying IDString: b'bd9b4...'
Decrypted key file using IDString 'bd9b4...' and UserName 'jcs'
DeDRM v7.0.0: Found 1 new key
MobiDeDrm v1.0.
Copyright © 2008-2020 The Dark Reverser, Apprentice Harper et al.
Decrypting Kindle Format 8 ebook: [title]
Got SerialNumber from database default_key_2
Got UsernameHash from database default_key_2
Found 4 keys to try after 2.3 seconds
Crypto Type is: 2
DeDRM v7.0.0: Ultimately failed to decrypt after 2.3 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 533, in KindleMobiDecrypt
book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
File "calibre_plugins.dedrm.k4mobidedrm", line 238, in GetDecryptedBook
mb.processBook(totalpids)
File "calibre_plugins.dedrm.mobidedrm", line 476, in processBook
raise DrmException("No key found in {0:d} keys tried.".format(len(goodpids)))
calibre_plugins.dedrm.mobidedrm.DrmException: No key found in 4 keys tried.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "calibre/customize/ui.py", line 172, in _run_filetype_plugins
File "calibre_plugins.dedrm.__init__", line 626, in run
decrypted_ebook = self.KindleMobiDecrypt(path_to_ebook)
File "calibre_plugins.dedrm.__init__", line 576, 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 v7.0.0: Ultimately failed to decrypt after 2.3 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
I know this is an old thread but I had a similar issue with Catalina, kindle 1.26 and calibre 4 and 5. What Aguilare said not to actually click the book when downloading, helped me. It appears as soon as kindle opens the book it says preparing your book and deletes the azw format. Despite using kindle 1.26, updates disabled, updates folder removed, etc. So conclusion don't open the book in kindle app on mac os until you have imported in calibre.
Then right-click kindle book to download. DON'T double click or open it before the drm removing.
CheckList
The Title
and TheLog Title
are setted correctly.my environment
.the log
.Title
DRM is not being removed
My Environment
Calibre: 4.23
Kindle: 1.26.1
DeDRM: 6.8
Mac mini M1 Big Sur
Log
Removing DRM of Salt to the Sea
``` calibre Debug log calibre 4.23 embedded-python: True is64bit: True Darwin-20.1.0-x86_64-i386-64bit Darwin ('64bit', '') ('Darwin', '20.1.0', 'Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:10 PDT 2020; root:xnu-7195.50.7~2/RELEASE_ARM64_T8101') Python 2.7.16 OSX: ('10.16', ('', '', ''), 'x86_64') Interface language: None Successfully initialized third party plugins: DeDRM (6, 8, 0) calibre 4.23 embedded-python: True is64bit: True Darwin-20.1.0-x86_64-i386-64bit Darwin ('64bit', '') ('Darwin', '20.1.0', 'Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:10 PDT 2020; root:xnu-7195.50.7~2/RELEASE_ARM64_T8101') Python 2.7.16 OSX: ('10.16', ('', '', ''), 'x86_64') Interface language: None Successfully initialized third party plugins: DeDRM (6, 8, 0) devicePixelRatio: 1.0 logicalDpi: 72.0 x 72.0 physicalDpi: 92.0000013817 x 91.0000013667 Using calibre Qt style: True [0.00] Starting up... [0.01] Showing splash screen... [0.21] splash screen shown [0.21] Initializing db... [0.22] db initialized [0.22] Constructing main UI... [0.80] main UI initialized... [0.80] Hiding splash screen [8.18] splash screen hidden [8.18] Started up in 8.18 seconds with 253 books DeDRM v6.8.0: Trying to decrypt B00YM34WM8_EBOK.azw Using Library AlfCrypto Python MobiDeDrm v0.42. Copyright © 2008-2017 The Dark Reverser, Apprentice Harper et al. Decrypting Kindle Format 8 ebook: Salt to the Sea Found 0 keys to try after 0.2 seconds Crypto Type is: 2 DeDRM v6.8.0: Failed to decrypt with error: No key found in 0 keys tried. DeDRM v6.8.0: Looking for new default Kindle Key after 0.2 seconds Found k4Mac kinf2018 file: /Users/lisa/Library/Application Support/Kindle/storage/.kinf2018 Couldn't decrypt file. DeDRM v6.8.0: Ultimately failed to decrypt after 0.3 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 "site-packages/calibre/customize/ui.py", line 172, in _run_filetype_plugins File "calibre_plugins.dedrm.__init__", line 625, in run File "calibre_plugins.dedrm.__init__", line 575, in KindleMobiDecrypt DeDRMError: DeDRM v6.8.0: Ultimately failed to decrypt after 0.3 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md Worker Launch took: 0.0718188285828 Job: 0 Convert book 1 of 1 (Salt to the Sea) finished Convert book 1 of 1 (Salt to the Sea) Conversion options changed from defaults: read_metadata_from_opf: u'/var/folders/j2/hhvbfrxx3dg9ry4xr4xpp0gc0000gn/C/calibre_4.23.0_tmp_ivwUhU/BhxNOm.opf' verbose: 2 cover: u'/var/folders/j2/hhvbfrxx3dg9ry4xr4xpp0gc0000gn/C/calibre_4.23.0_tmp_ivwUhU/f3MaNO.jpeg' output_profile: u'kindle_oasis' input_profile: u'kindle' Resolved conversion options calibre version: 4.23.0 {'asciiize': False, 'author_sort': None, 'authors': None, 'base_font_size': 0.0, 'book_producer': None, 'change_justification': u'original', 'chapter': u"//*[((name()='h1' or name()='h2') and re:test(., '\\s*((chapter|book|section|part)\\s+)|((prolog|prologue|epilogue)(\\s+|$))', 'i')) or @class = 'chapter']", 'chapter_mark': u'pagebreak', 'comments': None, 'cover': u'/var/folders/j2/hhvbfrxx3dg9ry4xr4xpp0gc0000gn/C/calibre_4.23.0_tmp_ivwUhU/f3MaNO.jpeg', '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': u'2', 'expand_css': False, 'extra_css': None, 'extract_to': None, 'filter_css': u'', 'fix_indents': True, 'flow_size': 260, 'font_size_mapping': None, 'format_scene_breaks': True, 'html_unwrap_factor': 0.4, 'input_encoding': None, 'input_profile':