I'd like to know how I can strip DRM from a Kindle book. I would like to buy a Kindle ebook from Amazon. I'd strip the DRM, and convert it to Epub (so I can listen to it on a headset connected to my iPhone) and to PDF format (so, while listening, I can follow the story in a PDF reader (Okular) using my Ubuntu based distro, and annotate the book).
I have spent an hour searching for software for stripping the DRM but only found links to pages of which the content didn't seem helpful, or which I didn't trust.
I'll leave the legalities, and ethicalness of this up to the lawyers, but my understanding is that it's illegal to break DRM, but legal to make a single backup of DRM material you have a legal right to have access to.
The answer to the question I believe is found by combining two separate works:
The directions are detailed at the plugin link.
I'm not going to go into the legality of the removal of DRM, as it varies by country — in some it falls under fair use, in others the situation is murky and in others yet it's explicitly illegal.
The following steps worked for me, on Ubuntu 18.04.
Install necessary programs using the package manager
Download other necessary programs
DeDRM plugin
Kindle for PC v 1.17
(Closely based on the information from the official FAQ (snapshot). Link to the latest version.)
For best results you need an old version of Kindle for PC (≤1.17). (Slightly more recent versions (≥1.24) use the sub-optimal KFX file format for downloaded books, while even more recent versions can't be "exploited" by the DeDRM plugin, at all.)
Unfortunately, that version of Kindle for PC is no longer available from Amazon's websites, so you'll need to google/duckduckgo for the filename
KindleForPC-installer-1.17.44170.exe
and download it from some sketchy website. To ensure that you've downloaded the "original" file (and not a modified version with bonus malware), you need to check the hash of the file. (md5 is "broken" and sha1 is partially "broken" so I don't recommend relying solely on them.)If you don't trust me, a random person on the internet, to tell you the correct hash, (you have no reason to) you can go to the official FAQ, above — after all, you're already trusting the DeDRM plugin not to be malicious. (There's a space in the sha256 hash, in the FAQ, for some reason.)
winetricks
We can't use winetricks for Kindle for PC, as that installs version 1.20, which isn't as suitable.
Install and run Kindle for PC
Enter your amazon account details, download the relevant books to the "device" (i.e. your computer) etc.
Install the calibre DeDRM plugin
Alternatively, after unzipping you can just install it via Calibre's standard UI. (Preferences > Advanced > Plugins > Load plugin from file.)
Extract your kindle keys
If you're using WINE/Linux, the DeDRM plugin won't extract the keys by itself "auto-magically" without some fiddling.
DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt
contains some suggestions on how to proceed. They partially, but not completely worked for me.Install python (within wine)
In order to extract the DRM keys, a python script (provided by the calibre plugin) will need to be run within wine (ideally) by the calibre plugin itself. Hence, you need to install python within the wine environment.
There are two alternatives here — use winetricks or install manually from the official python website.
Manual installation (currently recommended)
Note that this differs from the instructions currently in
DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt
by the crucial addition ofALLUSERS=1
.Winetricks (not recommended unless you have a new version of winetricks)
If you're using winetricks installed from Ubuntu's repositories, on 18.04, then unfortunately only python-2.6 (which you can install with
winetricks python26
) is available. Because the calibre plugin currently hardcodes the path to a standard python-2.7 installation, that's suboptimal. Consequently you would either need to patch the calibre plugin or run the wine python script yourself and copy the decryption keys.If you have a newer version of winetricks, you can install python-2.7.
Have the wine python script run
In order for the calibre plugin to run the script, you have to tell it where your wine installation is located (the so-called "WINEPREFIX"). By default, the wineprefix is
~/.wine/
. You can tell the calibre plugin yourWINEPREFIX
, in Calibre, by going to Preferences > Advanced > Plugins > File type plugins > DeDRM > Customize plugin > Kindle for PC and Adobe Digital Editions. You can prompt the running of the script by pressing the "+" button — otherwise it will be run when you first try adding a book with Kindle DRM.That should be it — when you add books to calibre, they'll be automatically stripped of DRM. Alternatively, you can look at the (almost) cli version, below, which is stripped of most of my verbose explanations.
(Almost) purely command-line version
Don't just copy-paste all of this in one go, as it won't work — a couple of the steps need human participation.