Remove DRM from Kindle Books

I recently found myself in a bind for law school – I have to read 150 pages by Monday of a novel for a class.  I was driving to Georgia over the weekend and realized 8 hours in the car would be perfect.  However, I struggled to get the book I needed downloaded and converted.  I have a Windows machine but am a Linux user.  I needed to get the Kindle de-DRM functions working in Linux so I could listen to the book I purchased.  By the way – I now own the paperback ($14), the Barnes and Noble version ($12.99) and the Kinde version ($12.99).  I have $42 invested and feel ensuring I can listen to this book is well justified.

The following instructions are for Calibre and Linux.

Linux.
1) Install Calibre.  Choose software updater in Linux and install Calibre.
a) Open Calibre and ensure all looks OK.
2)  Go to Alf’s Apprentice Blog and download the latest DRM tools
a) Download the zip file and unzip it.
3) Install Wine on the Linux machine —https://wiki.winehq.org/Ubuntu
a) If your system is 64 bit, enable 32 bit architecture (if you haven’t already):
sudo dpkg –add-architecture i386
a) add-apt-repository ppa:ubuntu-wine/ppa
b) apt-get update
c) apt-get install wine1.7
d) Launch Wine Configuration
e) Follow the prompts: Wine configuration setup will ask to install the missing Wine dependencies in order to complete its setup to configure wine on the system. Most probably it requires wine Gecko installer and wine Mono installer.
f) Run “Configure Wine”, which will set up the default ‘wineprefix’
5) Run winetricks, select the default wineprefix and install component vcrun2008
6) Follow the following Linux instructions below:
——————————————————————————————–
Download all of the following to a folder
a) Download Kindle for PC
b) Adobe Digital Editions 1.7.x from http://helpx.adobe.com/digital-editions/kb/cant-install-digital-editions.html.  (Adobe Digital Editions 2.x doesn’t work with Wine.)
c) ActivePython 2.7.X for Windows (x86) from http://www.activestate.com/activepython/downloads
d) PyCrypto 2.1 for 32bit Windows and Python 2.7 from http://www.voidspace.org.uk/python/modules.shtml#pycrypto (PyCrypto downloads as a zip file. You will need to unzip it.)
7) Run the mis-named “Uninstall Wine Software”, which also allows installation of software.
 a) Install Kindle for PC. Accept all defaults and register with your Amazon Account.
 b) Install Adobe Digital Editions. Accept all defaults and register with your Adobe ID.
 c) Install ActiveState Python 2.7.x. Accept all defaults.
 d) Install PyCrypto 2.1. Accept all defaults.
8) Don’t do anything yet — we did the easy part.  Now we need to run the script to get the Kindle Key
Hidden away in the Help button of the keys under customize plug is this information.
a) Open Calibre
b) ChoosevPreference
c) Choose Plugins
d) Choose File Type Plugins
e) Choose DRM —
f) Click Customize Plugins and click help to see this text:
First, choose Preferences, then plugins.  Click File Input,
Linux Systems Only
Generating decryption keys for Adobe Digital Editions and Kindle for PC. If you install Kindle for PC and/or Adobe Digital Editions in Wine, you will be able to download DRMed ebooks to them under Wine. To be able to remove the DRM, you will need to generate key files and add them in the plugin’s customisation dialogs.

To generate the key files you will need to install Python and PyCrypto under the same Wine setup as your Kindle for PC and/or Adobe Digital Editions installations. (Kindle for PC, Python and Pycrypto installation instructions in the ReadMe.)Once everything’s installed under Wine, you’ll need to run the adobekey.pyw script (for Adobe Digital Editions) and kindlekey.pyw (For Kindle for PC) using the python installation in your Wine system. The scripts can be found in Other_Tools/Key_Retrieval_Scripts.Each script will create a key file in the same folder as the script. Copy the key files to your Linux system and then load the key files using the Adobe Digital Editions ebooks dialog and the Kindle for Mac/PC ebooks dialog.

9) So….easiest thing to do is go to the folder within your DRM zip folder and copy the kindlekey.pyw script over to your Wine Python folder.  Home/your name/.wine/drive_c/Python27/
a) Drop the kindle key in that folder
b) Choose “Open Folder in terminal”
c) Type wine python kindlekey.pyw
d) Take the key file that is generated and copy it back to your DRM folder.
10) Open Calibre, if closed from above, and go to plugin customization, choose Kindle for PC and Import Data Key.  Choose the key.
11) Close Calibre
12) Go to Kindle for PC – log in and sync your books.  You will see the .azw files under My Documents\My Kindle Content
13) Open Calibre
14) Choose Add Books and browse to the kindle folder to import the books.  Next, choose Convert Books and convert to epub format.
15) I then open the calibre path and cut and paste the converted books to my dropbox.  Now, they are available on my android and I can pull them into Moonreader.