Tuesday, February 16, 2010

Decrypting Adobe Digital Editions 1.7.2 eBooks on Windows

Readers,

My original post, which is preserved below for historical purposes but has its text struck through, was wrong in certain important details and quickly outdated in others, for which I humbly apologize. It was an attempt to help you cope with the release of the 1.7.2 update to Adobe Digital Editions. ADE 1.7.2 changed the way a crucial decryption key is stored when the ADE activation takes place — when, that is, you "authorize" your computer to use your Adobe ID and password.


Here is the latest (hopefully correct) information, which is fleshed out in iPhone: Reading Adobe/EPUB eBooks:

There is now (see Step 4 in iPhone: Reading Adobe/EPUB eBooks) a new version (v.4.3) of the ineptkey Python script for Windows users, the purpose of which is to derive a key to decrypt Adobe eBooks, and also a brand new ineptkeymac Python script (v.1) for Mac users, the purpose of which is the same.

Either the ineptkey v.4.3 Python script for Windows users or the new ineptkeymac v.1 script for Mac users will produce an adeptkey.der output file that can be input to version 2 of the ineptepub script. v.2 has been the "standard" ineptepub version for a long time now, and it is again. The purpose of ineptepub is to use the key generated by either ineptkey or ineptkeymac to decrypt Adobe eBooks.


Windows or Mac users can alternatively use ineptepub_auto_version3.pyw (v.3 of ineptepub) or aineptepub.pyw (v.4.1 of ineptepub, which is different from v.4), both of which decrypt whole folders/directories of Adobe eBooks rather than just a single Adobe/EPUB file.

Version 4 of ineptepub does not
work with ineptkey v.4.3, the latest ineptkey version, but only with ineptkey v.4.2, which is already obsolete ... as ineptepub v.4 is likewise already obsolete.

While ineptkey v.4.2 was current, it generated an adeptkey4.der (not adeptkey.der) file in a different internal format than adeptkey.der. That file was intended for ineptepub v.4. When ineptkey v.4.3 came out, I mistakenly told readers in my original post below to input its output file to ineptepub v.4, which led to "index out of range" errors.

Any adeptkey.der file that was generated prior to ADE version 1.7.2 is no longer usable with eBooks downloaded with ADE 1.7.2. Even though it's the right format for ineptepub v.2, it will produce a "problem decrypting session key" error when used with ADE 1.7.2-downloaded books. It will work only with books downloaded with ADE 1.7.1 or earlier.

Users that have an old adeptkey.der file that was generated while ADE 1.7.1 was active can, if they wish, hold onto it and use it to decrypt books that they downloaded before the ADE 1.7.2 update. Or they can re-download those books in ADE 1.7.2 and use a newly generated adeptkey.der file, from ineptkey v.4.3 or ineptkeymac v.1, to decrypt the newly downloaded books in any version of ineptepub other than v.4. I recommend the latter course, as it avoids having to keep track of which books were downloaded with which ADE versions.


Again, sorry for all the mix-ups,

Eric


* * *


The original post:

Adobe Digital Editions 1.7.2 tosses a monkey wrench into the procedure for decrypting Adobe eBooks that I described in iPhone: Reading Adobe/EPUB eBooks. Using that procedure as originally described can produce

Error: problem decrypting session key



instead of decrypting an eBook.


First I'll give the remedy, then I'll explain.


This post applies, by the way, to Windows platforms, not Macs. Although ADE 1.7.2 can cause similar problems for Mac users, I will publish a general solution for them in a later post. Neither of the two new Python scripts I am about to discuss works on a Mac.


The remedy for Windows users is to download and use ineptkey.pyw version 4.3 and ineptepub.pyw version 4 instead of earlier versions of the Python scripts ineptkey.pyw and ineptepub.pyw, respectively. To get the new versions, just click on the two links just given. Each will download a zipped version that, if your browser doesn't unzip them, must be unzipped manually to yield the files ineptkey_v43.pyw and ineptepub_v4.pyw.


Version 4.3 of ineptkey can cope with the changes made by ADE 1.7.2 with respect to what cryptographic encryption/decryption keys are stored in the Windows registry, and how they are stored. Working in tandem with ineptkey version 4.3 is the new ineptepub version 4. These two new Python scripts allow you to decrypt Adobe eBooks that you have downloaded using either ADE 1.7.1 (the older version) or ADE 1.7.2 (the current version).


If you followed the instructions in my earlier iPhone: Reading Adobe/EPUB eBooks post, you already have Python 2.6 installed in C:\Python26\python.exe. You need to open ineptkey_v43.pyw in that app. It will produce a file called adeptkey.der in the same folder as ineptkey_v43.pyw. (An adeptkey.der file from an earlier version of ineptkey will not work with the new version of ineptepub.)


adeptkey.der contains more than one candidate decryption key for ineptepub_v4.pyw to try, any time you open ineptepub_v4.pyw in C:\Python26\python.exe to decrypt a particular eBook. The new version of ineptepub figures out which candidate key works, and uses that one.


Keep in mind that you need to run ineptkey_v43.pyw2 just once, to generate adeptkey.der. You then run ineptepub_v4.pyw every time you want to decrypt a new eBook.


* * *



Now for a more detailed explanation: On or about Feb. 1, 2010, Adobe Digital Editions 1.7.2 replaced 1.7.1 as the version that new users received. At the same time existing 1.7.1 users started to get dialog boxes warning that they had 44 days to upgrade. If they clicked "Upgrade Now," then tried to use ineptkey.pyw and then ineptepub.pyw, they got


Error: problem decrypting session key


from the latter. (If they already had saved an adeptkey.der output file from ineptkey version 3, ineptepub version 2 still worked with that saved adeptkey.der file. In fact, you can continue to use that saved adeptkey.der file indefinitely with any version of ineptepub prior to version 4.)


Existing ADE users could, of course, delay upgrading to 1.7.2, but they had no way of knowing not to upgrade if they had not previously tucked away a copy of the adeptkey.der file. New users had no choice but to get ADE 1.7.2 right off. (You can tell what version of ADE you have by launching ADE and, assuming you do not get a dialog box telling you that you need to upgrade, going into Library View and choosing the About Adobe Digital Editions menu item. In the box that appears you will see a version number such as 1.7.2.xxxx.)


Adding to the confusion, there were many reasons why the "problem decrypting session key" error could crop up. For instance, if you generated adeptkey.der and then re-authorized ADE using a different Adobe ID, your new eBooks would not decrypt using the existing adeptkey.der. Instead, ineptepub would produce the same "problem decrypting session key" error. Figuring out what was causing the "problem decrypting session key" error when ADE 1.7.2 arrived was tough.


Thanks to the anonymous author of the new Python script versions, the problem has now been solved. The problem has to do with the fact that in the Windows registry, there is a bunch of ADE activation data stored for each authorization of ADE that is done. Prior to ADE 1.7.2, a crucial key, privateLicenseKey, was itself encrypted a certain way. Earlier versions of ineptkey simply decrypted it the same way and stored that single result in adeptkey.der.


As of 1.7.2, privateLicenseKey is encrypted a different way. The anonymous author of the new ineptkey script didn't know how to modify how it is decrypted, but he found another key in the registry, pkcs12, that could be used as privateLicenseKey had originally been used. So he simply passed both keys into the adeptkey.der file. The first key is correct for ADE 1.7.1, while the second works for ADE 1.7.2. The new ineptepub script can tell which one is working, and uses that one.

21 comments:

Anonymous said...

Adobe just uses an obfuscation technique - it has several keys and the wrong ones are labeled with a Cyrillic C instead of a latin one (credentials). The scripts are improved again so it uses the old adeptkey.der format again and a mac version of the ineptkey was released as well.

Hazelnut said...

This is a terrific post. I read a lot of e-books on various platforms- phone, laptop etc. Hence I need to convert the ebooks I buy into various formats convenient to each platform. I have been using Python and Pycrypt to strip DRM from my ebooks so I can convert and use them. However, with 1.7.2, they just did not work! I kept getting Error:"problem decrypting session key"

So I downloaded the ineptkey and ineptepub links you'd given and tried it once again. Now It get an error message that says: Error list assignment index out of range

Is there something I am doing wrong?

eric said...

Veena,

You said:

I have been using Python and Pycrypt to strip DRM from my ebooks so I can convert and use them. However, with 1.7.2, they just did not work! I kept getting Error:"problem decrypting session key"

So I downloaded the ineptkey and ineptepub links you'd given and tried it once again. Now It get an error message that says: Error list assignment index out of range

Is there something I am doing wrong?


The error you are getting: does it come when you run ineptkey, or ineptepub?

Neither script seems to have that particular error message in it, but it is possible that the error comes from code that the main script imports and uses. I did not write either script, and I am not an expert on Python code, but the error sounds like a common type of software error ("index out of range") that usually can be traced to a bug somewhere.

If you will contact me by e-mail at epstewart2004@yahoo.com, I will try to help you figure this out.

Also, did you get the same result with more than one e-Book?

Anonymous said...

I had the same problem as Veena. A workaround might be to use aineptepub.pyw, version 4.1
that decrypts full directories:
http://pastie.org/pastes/829751

I saw this mentioned as a solution on a forum, and it worked for me.

marc-spirit said...

What about removing DRM from PDF with with the INEPTPDF ? I use Version 6.1 and this doesnt work with 1.72 on my machine :-(
What can i do ?

btw, ineptepub wit ebooks is working perfectly with removing drm (my machine with 1.72)!! so great work & thousand thanks !! ;-)

marc-spirit said...

Ok, i went a huge step forward..
My mistake was:
-I tried to convert a kind of pdf, which is protected with "Adobe Policy Server" and NOT by "Adobe Digital Editions".

-When i try to open the pdfs in ADE there comes a message:
This Version of Digital Editions is not supporting documents, which are protected with "Adobe Policy Server". So these PDFs i can just and only open in Adobe Reader. So for these pfds, the convertation doesnt work.

- But now, when i open PDFS which are protected by ADE ( and openable by ADE) it WORKS with the script perfectly !!!
THANKS

But now my question... how can i convert these kind of PDFs which aren't using ADE ?? (and instead the Adobe Policy Server)
????

eric said...

Anonymous,

You said:

I had the same problem as Veena. A workaround might be to use aineptepub.pyw, version 4.1
that decrypts full directories:
http://pastie.org/pastes/829751

I saw this mentioned as a solution on a forum, and it worked for me.


I looked at the source code for aineptepub.pyw. It looks like it will work only for anyone who already has a usable adeptkey.der file. Windows users (not Mac users) would have to activate the previous version 1.7.1 of ADE, run ineptkey version 3 (not version 4.x) to generate adeptkey.der, then allow ADE to upgrade itself to 1.7.2.

At least, this is my best guess, because right now I cannot activate ADE at all(!), having used up some unknown number of activations in the process of testing. ADE now gives me a "too many activations" error and won't carry on, period. I contacted customer support four days ago, but other than ask me for a screen shot of the error message, they have not solved the problem.

Going back to 1.7.1 worked for me, prior to this latest trouble, but unfortunately the link I had to that version (http://drop.io/a1bdxlq) has stopped working. I can't legitimately recommend this workaround to any of my readers until I find another source of ADE 1.7.1 for Windows.

I will also consult the person who wrote ineptkey version 4.x/ineptepub version 4 and ask him for help with the "Error: list assignment index out of range" problem. Because this looks like a difficult thing to debug, would you kindly e-mail me at epstewart2004@yahoo.com with further details such as which script generated the error. I'd like to also ask that you attach to the e-mail a copy of the problematic eBook as originally downloaded, and also a copy of your adeptkey.der file.

Finally, I wonder if you have tried unzipping and then rezipping the eBook file before trying to decrypt it, as that seems to help in some cases.

Later,
Eric

Anonymous said...

Regarding the workaround, I should have left more info.
To be precise, I've been using ADE 1.7.2 all along (not 1.7.1). I obtained the adeptkey.der using ineptkey.pyw version 4.3 on 1.7.2, then successfully decrypted using aineptepub.pyw, version 4.1 (using the ineptepub_v4.pyw that you linked gave me the "index out of range" error).

eric said...

Anonymous,

You said:

Regarding the workaround, I should have left more info.

To be precise, I've been using ADE 1.7.2 all along (not 1.7.1). I obtained the adeptkey.der using ineptkey.pyw version 4.3 on 1.7.2, then successfully decrypted using aineptepub.pyw, version 4.1 (using the ineptepub_v4.pyw that you linked gave me the "index out of range" error).


Thanks for the clarification. I see that I have to rework my original post above, as version 4.3 of ineptkey has gone back to the original way of making the adeptkey.der file, and I didn't catch that fact. Version 4.2 (already obsolete!) was cramming two separate keys into adeptkey.der and letting ineptepub figure out which actually worked.

I'm going to cogitate about this some more, but I believe the problem with getting "index out of range" errors in ineptepub version 4 might be due to it expecting multiple keys in adeptkey.der ... which aineptepub v. 4.1 does not.

Likewise, it might be the case that venerable ineptepub v. 2 will now work (again!) with an adeptkey.der file generated by ineptkey v. 4.3.

Tomorrow I hope to do some testing to see if that's right, but I'm going to have to work around not being able to activate ADE on Windows right now using my accustomed Adobe ID/password, since I have apparently tripped over a land mine that Adobe doesn't tell people about: "too many activations," due to my extensive testing of all this stuff!

Booker said...

http://download.macr
omedia.com/pub/developer/digitalpublishing/digitaleditions1_7_setup.exe

a standalone download. I haven't downloaded it though, so not 100% sure it is 1.7.1

Anonymous said...

ineptpdf 7.2 released - use with ineptkey 4.3 or higher

Anonymous said...

Why'd you stop posting? I liked reading your posts on the different types of eReaders.

Anonymous said...

I run Snow Leopard 10.6.4. ADE v1.7.2.1131.

After updating latest Python 2.7 over 2.6.1 and installingpycrypto-2.1.0 I then used Terminal and ran the following commands.

pythonw ineptkeymac_v1.py

this produced my adeptkey.der. Then I ran

pythonw ineptpdf74.pyw
link: http://pastebin.com/qqWJCRX6

and my DRM Books (legally purchased) in pdf format, were un DRM'd.

I have no intention of sharing my books, but like many others I have been buying books over the years only to watch online business go under, losing my ability to update files that have been lost. Also I have just received my iPad and wanted my ebooks on that for obvious reasons.

Can't tell you how wonderful it feels to see them there. I felt like I was being held to ransom by the Adobe DRM system.

Thanks everyone who had a hand in putting this together.

very happy eBook owner

eric said...

RandomizeME, you said...

Why'd you stop posting? I liked reading your posts on the different types of eReaders.

Whoops, I guess I just got "heavy into" other stuff. I'll try to do better ...

Cheers,
Eric

eric said...

Anonymous, you said...

I run Snow Leopard 10.6.4. ADE v1.7.2.1131.

After updating latest Python 2.7 over 2.6.1 and installingpycrypto-2.1.0 I then used Terminal and ran the following commands.

pythonw ineptkeymac_v1.py

this produced my adeptkey.der. Then I ran

pythonw ineptpdf74.pyw
link: http://pastebin.com/qqWJCRX6

and my DRM Books (legally purchased) in pdf format, were un DRM'd.

I have no intention of sharing my books, but like many others I have been buying books over the years only to watch online business go under, losing my ability to update files that have been lost. Also I have just received my iPad and wanted my ebooks on that for obvious reasons.

Can't tell you how wonderful it feels to see them there. I felt like I was being held to ransom by the Adobe DRM system.

Thanks everyone who had a hand in putting this together.

very happy eBook owner


You're welcome! Of course, I am just the guy who took it on himself to try to explain how to use these pieces of software. There are many others who deserve credit for developing them in the first place.

I am glad to hear that you were able to figure out what to do to decrypt PDF-format Adobe eBooks in Snow Leopard, as I am still on Leopard and cannot test various candidate methodologies.

Happy reading ...

Eric

Jolly est Roger said...

Good day Eric.

I keep getting

Traceback (most recent call last):
File "C:\Python26\inept\ineptkey_v43.pyw", line 230, in main
retrieve_key(keypath)
File "C:\Python26\inept\ineptkey_v43.pyw", line 149, in retrieve_key
vendor = cpuid0()
File "C:\Python26\inept\ineptkey_v43.pyw", line 112, in cpuid0
cpuid0__(buffer)
WindowsError: exception: access violation writing 0x00BE4F88

at step 4
so there are no adeptkey.der created.

what can I do?

Roger

eric said...

Roger Gravel said...

I keep getting

Traceback (most recent call last):
File "C:\Python26\inept\ineptkey_v43.pyw", line 230, in main
retrieve_key(keypath)
File "C:\Python26\inept\ineptkey_v43.pyw", line 149, in retrieve_key
vendor = cpuid0()
File "C:\Python26\inept\ineptkey_v43.pyw", line 112, in cpuid0
cpuid0__(buffer)
WindowsError: exception: access violation writing 0x00BE4F88

at step 4
so there are no adeptkey.der created.

what can I do?


Roger,

I'll refer you to this online discussion which seems to offer the solution!

It looks like all you need to do is get more recent versions of the ineptkey and ineptepub scripts:

ineptkey: http://pastie.org/1030386

ineptepub: http://pastie.org/1032773

I haven't tried the new versions and can't be 100% sure they'll fix your problem, but they're worth a try!

Best of luck,
Eric

ivan said...

Any way to disable updater in ADE, to avoid updating from 1.7.1 to 1.7.2 ? Simple reset of the timer, or something like this ?

eric said...

Ivan,

I don't think there exists any such trick to prevent ADE from updating to the latest version ... but I think you may be able to:

(1) If you are already using the older ADE version but haven't upgraded yet, you can generate an associated adeptkey.der file that you can then use to unlock any books you may have already downloaded. To do that, go to my post iPhone: Reading Adobe/EPUB eBooks and (skipping Step 1) do Steps 2 through 4.

(2) Look at Apprentice Alf's DeDRM AppleScript for Mac OS X 10.5, 10.6 to find out how to use DeDRM. (I'm assuming you have a Mac. If not, then you can just do the rest of the steps in the post I mentioned above.) DeDRM is a general-purpose AppleScript droplet that (once you've told it where one or more adeptkey.der files are) will use those files to decrypt ADE book files that you have dropped the icons of onto the droplet icon. It will try all the adeptkey files you've specified, so if you have one adeptkey file that goes with ADE 1.7.1 and one that goes with ADE 1.7.2, then all books you've downloaded with either version ought to work.

However, if you have no 1.7.1-compatible adeptkey file and have already upgraded ADE to 1.7.2, then your best bet may be to re-download all of your legacy ADE books. They will arrive re-encrypted, and your 1.7.2-compatible adeptkey file will successfully decrypt them. Even better, DeDRM will generate that adeptkey file for you, on the fly, so you don't have to fool with the steps in my post which I mentioned earlier.

ivan said...

Eric, thank you very much for your suggestions.
My OS is Win XP,
Actually I use at the moment ADE1.7.1, but I have 9 days left.
I use ActivePython_v2.7.1.4; pywin32_b216; PCCrypto_v2.3; ineptkey_v5.4; ineptepub_v5.6; ineptpdf_v8.4.51 and I have extracted “adeptkey.der”.
Everything works fine with ADE1.7.1
I was afraid that I will get a problem after updating to v1.7.2, but if it is not a case, I will just update.

eric said...

Ivan,

I think you ought to decrypt all the books you already have, using the adeptkey.der file you now have. Then, before buying more books, upgrade to ADE 1.7.2. Then generate a new adeptkey.der file which you will use for all the books you buy from now on. That will allow you to have "open" EPUBs for every book you have, now and into the future.