Thursday, November 25, 2010

Apprentice Alf's DeDRM AppleScript for Mac OS X 10.5, 10.6

E-books that you buy are usually encrypted with "Digital Rights Management," or DRM. DRM is copy protection; it's intended to keep you from making a copy of your book and letting someone else have it.

But DRM can interfere with uses of the book that are legal. Some of the books I have bought in the Adobe EPUB format, for instance, can't be moved to my iPhone for reading — unless, that is, I strip off the DRM encryption first.

I showed how to do that in an earlier post, iPhone: Reading Adobe/EPUB eBooks. It's a complicated set of steps. Now there's a way that is less complicated.

Unfortunately, the new way is available only to users of Mac OS X 10.5 ("Leopard") and 10.6 ("Snow Leopard") but not to users of any Windows system. That's because DeDRM, as its author Apprentice Alf named it, is in the AppleScript scripting language.

Apprentice Alf, who wrote DeDRM, has gone into retirement, and his original blog post about it has been modified and no longer links to the DeDRM 2.6 download per se. You can instead download tools v3.8 ZIP file from here. It contains DeDRM 2.6. The link I just gave will take you to RapidShare, where you need to click on the Download button under Save File To ... your computer. A popup window will require you to wait a couple of minutes and then click on a second Download button. Then the actual download will begin. It will normally (depending on how you have your browser set up) put the tools v3.8.zip file on your Desktop. Double clicking that file will expand the ZIP file into a tools v3.8 folder. Open the folder. A DeDRM 2.6 AppleScript "droplet" should be the top item. Option-drag it to the Desktop to make a copy of it there. You can then (after possibly doing the setup I describe below) drag the icons of e-book files that you want decrypted and drop the icons on the DeDRM 2.0 droplet to have the e-books decrypted.

After you put the DeDRM 2.6 droplet on your desktop, you will see something like:


I took that screenshot when using an older version of DeDRM; the current version is DeDRM 2.6. What I describe below pertains to version 1.1, but it remains about the same in later versions.

I'll assume you'll leave/put the DeDRM 2.6 icon on the desktop, but you can optionally move it to any folder you like.

To use DeDRM, you'll simply drag an e-book file's icon over to the DeDRM icon, and drop the e-book's icon there. You can also drag the icon of a folder that contains more than one e-book, and DeDRM will decrypt them all. The decrypted e-book(s) will show up in the same folder as the original e-book(s) are in.

Before you start dragging and dropping e-books, though, some setup may be required. (If you want to bypass it and just try your luck now, skip down to Using DeDRM.)

Optional Setup

Double-click on the DeDRM icon to see:


When you click Continue, you'll see:


You can click None for this dialog ... unless you have Kindle e-books in the Mobipocket format from Amazon.com. In that case, you can enter the necessary PIDs (Personal IDs) for your Kindle device(s) here, clicking Add after each one. (How to learn what those PIDs are is a topic beyond the scope of this post.)

If you, like me, want to bypass Mobipocket PID specifications for now, just click None. You can always re-launch DeDRM as a standalone application, using the double-click method, and enter Mobipocket PIDs later.

You'll now see something like:


You can enter, one at a time, any Name:Credit_Card_Number "key pairs" you use to buy e-books at Barnes & Noble or eReader.com, and click Add. Once you have entered them all, you will click on the No More button which has replaced the None button.

Each key pair represents:

  1. the name on your account at Barnes & Noble online or on eReader.com
  2. the number on the credit card registered for that account.

These two items must be entered with a colon (':') — but with no spaces or other characters — between them. If the card number is for an eReader account, you can opt to enter just the last eight digits of the card number. If it is for a B&N account, you will need to enter the whole 16-digit card number.

If you don't want to enter any Barnes & Noble or eReader.com key pairs, just click None in the dialog box above.

Next you'll see:


The intention here is for you to specify any adeptkey.der key files that you may have generated previously. These are key files that, again, you may have generated using a Python script, ineptkeymac_v1.py, as shown in Step 4 of iPhone: Reading Adobe/EPUB eBooks. If you do happen to have any previously generated adeptkey.der key files, you can use the Add... button at this point to tell DeDRM about them, one by one.

But you don't really need to specify any previously existing adeptkey.der key files! DeDRM can generate the "local" ADEPT key file you need on the fly for you.

ADEPT stands for Adobe Digital Editions Protection Technology, by the way.

The only time you'll need to specify your own existing adeptkey.der key files is in a situation where you in fact have some older Adobe EPUB e-book files lying around, ones that were downloaded when you were using a different Adobe ID/Password combination than you currently use.

For purposes of this post, I'll assume all your Adobe EPUBs were downloaded (possibly using Sony's Reader Library application) with an Adobe ID/Password combination that is still current. So all you have to do in the dialog box above is click on No More. At that point, the DeDRM script merely quits.

Using DeDRM

Now you're ready to use the DeDRM script for real. I suggest you consider moving or copying the DeDRM "droplet" icon to a folder you've created, named something like DeDRM Folder. Alternatively, you can leave the DeDRM "droplet" icon right on your desktop.

The next step is to locate in your Mac's folder hierarchy any Adobe EPUB e-book file that you want to strip DRM from:

  • If you got the file via the Sony Reader Library application, it's in ~/Documents/My Books/Reader Library/{book title}.epub. (The '~' node stands for the Home folder of the user account you are using on the Mac.)
  • If you obtained the Adobe EPUB online in any other manner and then imported it into the Adobe Digital Reader application, you can expect to find it in ~/Documents/Digital Editions/{book title}.epub.
  • If your Adobe EPUB e-book can be found in neither of those two locations, you can probably locate it by doing a Finder filename search on the book's title.

You might want to make a copy of the Adobe EPUB in your DeDRM Folder folder (or, alternatively, on the desktop, if that's where your DeDRM "droplet" icon is) by dragging its icon to that location while holding down the option key.

Using a copy of the adobe EPUB is not, strictly speaking, necessary. However, DeDRM will produce its decrypted output copy in the same folder location (possibly the desktop) as the location of the input original Adobe EPUB that you drop onto the DeDRM icon. So if you want the decrypted version to be created in a more convenient folder location than ~/Documents/My Books/Reader Library/ or ~/Documents/Digital Editions/, it's best to work with a copy that you have previously established in the desired output location.

Now drag the copied Adobe EPUB e-book's icon onto the DeDRM icon and drop it there. DeDRM will open. After a brief delay, you should see something like:


Click Thanks. DeDRM goes away. It's that easy!

If the input file was called The Snake, the Crocodile, and the Dog.epub, as above, an output file called The Snake, the Crocodile, and the Dog_dedrmed.epub will appear in the same folder (possibly, the desktop). The filename will be that of the original file with _dedrmed added. The filename extension will continue to be .epub.

The output file is just like the input file — except that it's no longer copy-protected. It can be read in any application or on any device that can read "open" (i.e., non-DRMed) EPUB e-books:
  • Stanza for the Mac or Windows
  • Reader Library for the Mac or Windows
  • Adobe Digital Editions for the Mac or Windows
  • Any iPad/iPhone/iPod Touch app that reads EPUBs, including Stanza, Kobo, and Borders
  • etc.
You can also read it in the iBooks app on an iPad/iPhone/iPod Touch. To do that:
  • Import the open EPUB file into iTunes by dragging it into the Library portion of the main iTunes window
  • With the open EPUB now visible in the Books section of the iTunes library, sync your iPad/iPhone/iPod Touch
The open EPUB will now appear in the Library of the iBooks app on the iPad/iPhone/iPod Touch!

You can use a similar procedure to use DeDRM to remove DRM encryption from:
  • PDB files that you obtain from Barnes & Noble or eReader.com online
  • Mobipocket e-books, such as those from Amazon.com
  • Amazon Kindle e-books — provided they're not in the dreaded Topaz format! (You can open your Kindle e-book in TextEdit and look for the characters TPZ0 near the top. If they're there, the book is Topaz and you'll need more powerful mojo to decrypt it.)
Wonderful, no?

15 comments:

Anonymous said...

Eric, the link to get the tools doesn't work anymore. Suggestions?

I was trying to use the old pycrypto method, which doesn't work; I was going to ask you for help with it when I saw your newer post. Do you have an updated link for the new tools? It would be much appreciated!

Anonymous said...

Spoke too soon! I followed links through Apprentice Alf's posts and found the tools here:
http://www.datafilehost.com/download-aa179896.html

So much easier than the old way!

Anonymous said...

It's probably worth giving the link to Apprentice Alf's blog, in case there are any further updates posted there by some_updates:

http://apprenticealf.wordpress.com/2010/02/11/

eric said...

In response to the posts by sonomalass and anonymous giving the most recent links:

The link to Apprentice Alf's tools v3.6 is:

http://www.datafilehost.com/download-aa179896.html

Unzipped, it creates a folder called "tools" in which you can find, yes, a whole bunch of tools that can be used in removing DRM from or otherwise manipulating e-books. One of the folders is "DeDRM_for_Mac_and_Win". In it is a ZIP file called "DeDRM_2.4.app.zip" that you can unzip to get a DeDRM 2.4 AppleScript droplet that on a Mac OS X system does all the wonderful stuff I talked about in the original post.

Apprentice Alf's blog entry about all this is:

DeDRM AppleScript for Mac OS X 10.5, 10.6

Since Alf's "retirement," it looks as if there will be no more work done on DeDRM or the other tools.

DeDRM is much, much easier and less problematic than the long procedure I gave in iPhone: Reading Adobe/EPUB eBooks, so I advise all Mac users to try DeDRM first!

Windows users can try the DeDRM_WinApp_v1.6 tool, described this way:

DeDRM_WinApp is a pure python drag and drop application that allows users to drag and drop ebooks or folders of ebooks onto theDeDRM_Drop_Target to have the DRM removed. It repackages the"tools" python software in one easy to use program.

It should work out of the box with Kindle for PC ebooks and Adobe Adept epub and pdf ebooks.

To remove the DRM from standalone Kindle ebooks, eReader pdb ebooks, Barnes and Noble epubs, and Mobipocket ebooks requires the user to double-click the DeDRM_Drop_Target and set some additional Preferences including:

Kindle 16 digit Serial Number
Barnes & Noble key files (bnepubkey.b64)
eReader Social DRM: (Name:Last 8 digits of CC number)
MobiPocket, Kindle for iPhone/iPad/iPodTouch 10 digit PID

Once these preferences have been set, the user can simply drag and drop ebooks onto the DeDRM_Drop_Target to remove the DRM.

This program requires that the proper 32 bit version of Python 2.X (tested with Python 2.5 through Python 2.7) and PyCrypto be installed on your computer before it will work. See below for where to get theese programs for Windows.


Note, though, that Windows users have to install Python and PyCrypto themselves. Users of DeDRM on a Mac don't have to bother with that.

Unknown said...

As of 3/15, it is missing again.
Kindle for Mac has changed, and I cannot find the link -- if someone would be kind enough to point the way

eric said...

The latest version of Apprentice Alf's package of tools is
tools v3.7 and is available here:

http://www.datafilehost.com/download-a0cecfba.html

Eric

Anonymous said...

arrgh, that last link doesn't work either! Great post though, and I'll be referring back to it when I do finally track down this elusive DeDRM program!:)

eric said...

Today I have updated my original post to reflect that you can now download the tools v3.8 ZIP file from here. It contains DeDRM version 2.6.

Anonymous said...

D'oh. That link has gone dead as well...

eric said...

As of June 28, 2011, you can download the tools v3.8 ZIP file from here. It contains DeDRM version 2.6.

Anonymous said...

No, the most recent link is just deDRM 2.0, which often returns errors. Looks like 2.6 is not currently available.

Anonymous said...

Here's 2.7: http://www.datafilehost.com/download-2b574fa7.html

Anonymous said...

I have 2.7 and I still have a couple of new books that will not work. The script says they were successfully dedrmed, but either no file appears or a zipped folder with xml files appear. This is the first I've had failures occur.

Stu Ducklow said...

Thanks for making this script available. It worked beautifully! The only stumbling block I had was that I was trying to deDRM an ascm file which I later learned is a file that manages the downloading of the actual book. Once I found the epub file everything worked perfectly.

Thanks again!

eric said...

Stu Ducklow said...

Thanks for making this script available. It worked beautifully! The only stumbling block I had was that I was trying to deDRM an ascm file which I later learned is a file that manages the downloading of the actual book. Once I found the epub file everything worked perfectly.

Stu,

I'm glad it worked well for you. Your point about acsm files is an excellent one. If you borrow an e-book from the library, what you initially download is not the actual e-book but an acsm file. This file with .acsm as its filename extension is just a link to your actual e-book that allows a program like Adobe Digital Editions to download the actual e-book. You use ADE to download the actual e-book file, and then you run DeDRM on the downloaded actual e-book file ... but never on the acsm file.

Thanks,
Eric