Howto: Strip Adobe DRM in Debian GNU/Linux

Please note, before reading any further — the legality of anti-DRM tools varies from country to country. Do not do this if you live in one of those countries where it is illegal.

There are plenty of guides to stripping the DRM from ebooks in Windows or Apple computers, but few out there that tell you how to do it in GNU/Linux. This is doubly annoying, as there are no versions of the most popular ereading DRM tools for GNU/Linux, so even those who are OK with DRM in principle (and most GNU/Linux users aren’t) can’t read the DRM’d versions even if they want to.

I tried doing this two years ago, and hit a number of hideous problems, but things have become a little easier now, so it’s only annoyingly difficult. These steps should work for other Debianesque distributions, like Mint or Ubuntu, but Debian’s the only one I’ve tried it on.

First, the version of WiNE that ships with Debian has a bug which stops Python installing correctly. To get around this, first uninstall WiNE:

(as root)

apt-get purge wine*

Now, go to the repository for the MEPIS distribution. Download the latest versions of WiNE (currently wine_1.4-1mcr8.5+1_i386.deb ) and WiNE-gecko (wine-gecko_1.4.0-1mcr85+2_all.deb ).
Then, as root, in the directory to which you have downloaded the files:

dpkg -i wine_1.4-1mcr8.5+1_i386.deb wine-gecko_1.4.0-1mcr85+2_all.deb

You have now installed a working version of WiNE.

Now, you need to install Python and Pycrypto in WiNE. Handily, these are packaged in this .rar file, which also contains the scripts you’re going to need.

Extract that file somewhere, then go to the directory you’ve extracted it to and, as your normal user, run:

wine msiexec /i python-2.6.2.msi

Follow the instructions in the window that pops up, and this should install python into your home directory, in ~/.wine/drive_c/Python26 . If it installs it somewhere else, change the rest of these instructions appropriately.

Next, as your normal user, still in the directory to which you’ve extracted everything, run:

wine pycrypto-2.1.0.win32-py2.6.exe

Follow the instructions, and this should install pycrypto in your WiNE directory.

Now, you will want to remove the MEPIS version of WiNE and go back to the Debian version, because otherwise you won’t be able to update your system easily, so, as root, run:

apt-get purge wine*

and then

apt-get install wine

You shouldn’t have to run anything else as root from this point on.

Now, get hold of a copy of Adobe Digital Editions. This can be downloaded from here (you have to use a direct download as otherwise Adobe’s website will detect your OS and stop you downloading it).

run

wine digitaleditions_172.exe

Follow the instructions and ADE will now be able to run under WiNE. Download a DRM’d book and open it — it should open automatically in ADE.

Now run:

mkdir ~/.wine/drive_c/inept/

Copy the files aineptepub.pyw and ineptkey.pyw to the directory you just created.

Now run

cd ~/.wine/drive_c/Python26
wine python.exe C:\\inept\\ineptkey.pyw

A box should pop up saying “key successfully retrieved to adeptkey.der”.

Next run

wine python.exe C:\\inept\\aineptepub.pyw

A box will pop up, asking for an input directory and an output directory. For the input directory, choose “My Digital Editions” from your home directory, and choose anywhere sensible (like your desktop) as the output directory. Within seconds, you should have decrypted copies of all your DRM’d ebooks in the directory you’ve selected, called something like “Quantum_Computing_since_Democritus.jb.decrypted.epub” (assuming the book you decided to try this on is Scott Aaronson’s excellent new book on quantum computing) which can then be loaded in a program like calibre or copied to an ereader.

To decrypt books in future, all you’ll have to do is first open them in ADE and then run:

cd ~/.wine/drive_c/Python26
wine python.exe C:\\inept\\aineptepub.pyw

I suggest putting those two lines in a little shell script to save time.

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

7 Responses to Howto: Strip Adobe DRM in Debian GNU/Linux

  1. ron says:

    where do I find aineptepub.pyw and ineptkey.pyw files so I can copy to the inept dir?

  2. Robin says:

    Everything’s fine until the last step, which won’t work for me. The GUI pops up and I can enter the filepaths, but nothing beyond that. Here’s the terminal output:

    fixme:font:freetype_SelectFont Untranslated charset 255
    fixme:imm:ImmReleaseContext (0x90118, 0x166928): stub
    fixme:shell:BrsFolder_OnCreate flags 30 not implemented
    fixme:shell:BrsFolder_OnCreate flags 30 not implemented
    fixme:shell:BrsFolder_OnCreate flags 30 not implemented

    • Andrew Hickey says:

      Sorry, I can’t be of any help — the scripts aren’t mine, I’m afraid.
      That said, there’s no confirmation when it works, and that sounds like it’s just a GUI error — have you checked your output directory and seen if the files are there?

  3. Hasukely says:

    Hi Andrew,

    thanks for the post, it helped me a lot. Just wanted to add that there’s also a Python script to remove DRM from pdf files: IneptPDF.pyw
    Maybe you could add that to the post?

  4. Matt says:

    Great job on this Howto. Very clear and accurate instructions. I am running CrunchBang and had no problem following your instructions. Thanks for this much needed post!

    Also, Robin, I get those error messages in the terminal as well, but the files still get decrypted and sent to my output folder.

Comments are closed.