Remove DRM from Adobe Digital Editions – Background

adobe-pdf-encr-slideThree years ago I wrote an article about breaking of Adobe Digital Editions DRM protection on books purchased legally, when you want, for example, to access your books with alernative PDF readers like Foxit. Or some people simply say that we should not be treated like criminals. Since then Digital Editions hit version 1.7.2 and I’m curious to see if that Open Source method with Python source files ineptkey.pyw and ineptpdf.pyw still valid. At least I saw newer versions of those files in the internet (ineptkey.pyw — version 5.4, ineptpdf.pyw — version 8.4.50, and ineptepub.pyw (to use for EPUB books instead of PDF) — version 5.2). Let’s have a look.

DRM in your book
Vanished like a sigh
Of weakening wind in the sunrise

BACKGROUND

It is all started by a guy (or a girl) under nickname I love cabbages or i♥cabbages or i-u2665-cabbages :)) — you can find his blog here. He found a way to unlock Adobe ADEPT-encrypted PDF files and ADEPT-encrypted EPUB books. There were two steps to follow:

  1. Key retrieval (for that key-retrieval Python script should be used: ineptkey (version 5.4))
  2. Decryption (for that two decryption Python scripts should be used: ineptepub for EPUB books (version 5.2) and ineptpdf for ebooks in PDF (version 8.4.50)

It is very easy to find those scripts in the Internet. Try Pastie or Pastebin, or Google of course. I am not publishing them here to avoid stupid DMCA complaints. To give you an idea of what kind of development it was, please see the change log below for these three files:

# ineptkey.pyw Revision history:
#   v1 - Initial release, for Adobe Digital Editions 1.7
#   v2 - Better algorithm for finding pLK; improved error handling
#   v3 - Rename to INEPT
#   v4 - Series of changes by joblack (and others?) --
#   v4.1 - quick beta fix for ADE 1.7.2 (anon)
#   v4.2 - added old 1.7.1 processing
#   v4.3 - better key search
#   v4.4 - Make it working on 64-bit Python
#   v5 - Clean up and improve 4.x changes
#       Clean up and merge OS X support by unknown
#   v5.1 - add support for using OpenSSL on Windows in place of PyCrypto
#   v5.2 - added support for output of key to a particular file
#   v5.3 - On Windows try PyCrypto first, OpenSSL next
#   v5.4 - Modify interface to allow use of import
# ineptepub.pyw Revision history:
#   v1 - Initial release
#   v2 - Rename to INEPT, fix exit code
#   v5 - Version bump to avoid (?) confusion;
#       Improve OS X support by using OpenSSL when available
#   v5.1 - Improve OpenSSL error checking
#   v5.2 - Fix ctypes error causing segfaults on some systems
# ineptpdf.pyw Revision history:
#   1 - Initial release
#   2 - Improved determination of key-generation algorithm
#   3 - Correctly handle PDF >=1.5 cross-reference streams
#   4 - Removal of ciando's personal ID (anon)
#   5 - removing small bug with V3 ebooks (anon)
#   6 - changed to adeptkey4.der format for 1.7.2 support (anon)
#   6.1 - backward compatibility for 1.7.1 and old adeptkey.der (anon)
#   7 - Get cross reference streams and object streams working for input.
#       Not yet supported on output but this only effects file size,
#       not functionality. (anon2)
#   7.1 - Correct a problem when an old trailer is not followed by startxref (anon2)
#   7.2 - Correct malformed Mac OS resource forks for Stanza
#       - Support for cross ref streams on output (decreases file size) (anon2)
#   7.3 - Correct bug in trailer with cross ref stream that caused the error (anon2)
#         "The root object is missing or invalid" in Adobe Reader.
#   7.4 - Force all generation numbers in output file to be 0, like in v6.
#         Fallback code for wrong xref improved (search till last trailer
#         instead of first) (anon2)
#   8 - fileopen user machine identifier support (Tetrachroma)
#   8.1 - fileopen user cookies support (Tetrachroma)
#   8.2 - fileopen user name/password support (Tetrachroma)
#   8.3 - fileopen session cookie support (Tetrachroma)
#   8.3.1 - fix for the "specified key file does not exist" error (Tetrachroma)
#   8.3.2 - improved server result parsing (Tetrachroma)
#   8.4 - Ident4D and encrypted Uuid support (Tetrachroma)
#   8.4.1 - improved MAC address processing (Tetrachroma)
#   8.4.2 - FowP3Uuid fallback file processing (Tetrachroma)
#   8.4.3 - improved user/password pdf file detection (Tetrachroma)
#   8.4.4 - small bugfix (Tetrachroma)
#   8.4.5 - improved cookie host searching (Tetrachroma)
#   8.4.6 - STRICT parsing disabled (non-standard pdf processing) (Tetrachroma)
#   8.4.7 - UTF-8 input file conversion (Tetrachroma)
#   8.4.8 - fix for more rare utf8 problems (Tetrachroma)
#   8.4.9 - solution for utf8 in comination with
#           ident4id method (Tetrachroma)
#   8.4.10 - line feed processing, non c system drive patch, nrbook support (Tetrachroma)
#   8.4.11 - alternative ident4id calculation (Tetrachroma)
#   8.4.12 - fix for capital username characters and
#            other unusual user login names (Tetrachroma & ZeroPoint)
#   8.4.13 - small bug fixes (Tetrachroma)
#   8.4.14 - fix for non-standard-conform fileopen pdfs (Tetrachroma)
#   8.4.15 - 'bad file descriptor'-fix (Tetrachroma)
#   8.4.16 - improves user/pass detection (Tetrachroma)
#   8.4.17 - fix for several '=' chars in a DPRM entity (Tetrachroma)
#   8.4.18 - follow up bug fix for the DPRM problem,
#            more readable error messages (Tetrachroma)
#   8.4.19 - 2nd fix for 'bad file descriptor' problem (Tetrachroma)
#   8.4.20 - follow up patch (Tetrachroma)
#   8.4.21 - 3rd patch for 'bad file descriptor' (Tetrachroma)
#   8.4.22 - disable prints for exception prevention (Tetrachroma)
#   8.4.23 - check for additional security attributes (Tetrachroma)
#   8.4.24 - improved cookie session support (Tetrachroma)
#   8.4.25 - more compatibility with unicode files (Tetrachroma)
#   8.4.26 - automated session/user cookie request function (works
#            only with Firefox 3.x+) (Tetrachroma)
#   8.4.27 - user/password fallback
#   8.4.28 - AES decryption, improved misconfigured pdf handling,
#            limited experimental APS support (Tetrachroma & Neisklar)
#   8.4.29 - backport for bad formatted rc4 encrypted pdfs (Tetrachroma)
#   8.4.30 - extended authorization attributes support (Tetrachroma)
#   8.4.31 - improved session cookie and better server response error
#            handling (Tetrachroma)
#   8.4.33 - small cookie optimizations (Tetrachroma)
#   8.4.33 - debug output option (Tetrachroma)
#   8.4.34 - better user/password management
#            handles the 'AskUnp' response) (Tetrachroma)
#   8.4.35 - special handling for non-standard systems (Tetrachroma)
#   8.4.36 - previous machine/disk handling [PrevMach/PrevDisk] (Tetrachroma)
#   8.4.36 - FOPN_flock support (Tetrachroma)
#   8.4.37 - patch for unicode paths/filenames (Tetrachroma)
#   8.4.38 - small fix for user/password dialog (Tetrachroma)
#   8.4.39 - sophisticated request mode differentiation, forced
#            uuid calculation (Tetrachroma)
#   8.4.40 - fix for non standard server responses (Tetrachroma)
#   8.4.41 - improved user/password request windows,
#            better server response tolerance (Tetrachroma)
#   8.4.42 - improved nl/cr server response parsing (Tetrachroma)
#   8.4.43 - fix for user names longer than 13 characters and special
#            uuid encryption (Tetrachroma)
#   8.4.44 - another fix for ident4d problem (Tetrachroma)
#   8.4.45 - 2nd fix for ident4d problem (Tetrachroma)
#   8.4.46 - script cleanup and optimizations (Tetrachroma)
#   8.4.47 - script identification change to Adobe Reader (Tetrachroma)
#   8.4.48 - improved tolerance for false file/registry entries (Tetrachroma)
#   8.4.49 - improved username encryption (Tetrachroma)
#   8.4.50 - improved (experimental) APS support (Tetrachroma & Neisklar)

As you see you can also run these scripts in Mac OS X like Snow Leopard.

To run this scripts you should install Python 2.7 (but not version 3!), it is recommended to use the 32-Bit Python Windows version (even with a 64-bit Windows system), PyCrypto dedicated version for Python 2.7, and PyWin Extension (Win32API module).

I will show exactly how to use these tools in sequence.

Some very interesting links:

http://tetrachroma.wordpress.com/ — Tetrachroma’s Blog

http://apprenticealf.wordpress.com/ — Apprentice Alf’s Blog

i♥cabbages blog

Here’s a link to HOW-TO Guide!

6 thoughts on “Remove DRM from Adobe Digital Editions – Background

  1. markm

    It seems Adobe have found a way around this removal method in newer digitial editions (books released in 2011). The method works on older books but not newest releases.

    Reply
  2. freereader

    well, I do agree : with pdf released in 2012, all work until the very last step. I press the “decrypt” button and I get a “Error: Invalid object Spec: offset=2957″ message. Too bad.
    Just a question : if a person I know has access to this file and can print it and print it with the virtual PDF printer, will he get a DRM-free PDF ? at least, a less technical solution would be to simply “screen-print” the pdf… I m not a developer, just a practical guy.

    Reply
  3. freereader

    further remarks : I tried pdf drm remover found at http://www.ebook-converter.com/pdf-epub-drm-removal.htm (Updated : March 9th, 2012 ) and I got almost the same error message :

    Key successfully retrieved to H:\Documents and Settings\…..\epubkey.der
    Finish
    waiting ….
    Traceback (most recent call last):
    File “”, line 3, in
    File “C:\Python27\ade\pdfdrm.py”, line 2202, in decryptBook
    File “C:\Python27\ade\pdfdrm.py”, line 1913, in __init__
    File “C:\Python27\ade\pdfdrm.py”, line 1721, in __init__
    File “C:\Python27\ade\pdfdrm.py”, line 1359, in set_parser
    File “C:\Python27\ade\pdfdrm.py”, line 1015, in dict_value
    File “C:\Python27\ade\pdfdrm.py”, line 941, in resolve1
    File “C:\Python27\ade\pdfdrm.py”, line 931, in resolve
    File “C:\Python27\ade\pdfdrm.py”, line 1694, in getobj
    pdfdrm.PDFSyntaxError: Invalid object spec: offset=2957

    Reply

Leave a Reply