Skip to content

Plugin not decrypting PDF with "hardened" DRM (ADE 3.0) #183

Closed

Description

@vectoriser

First of all I would like to say a Big Thank You! to noDRM and a980e066a01 for enabling the decryption of DRM for ADE 3.0.

I have successfully used this plugin with Calibre Portable Edition 5.44.0. to decrypt PDFs with "hardened" DRM (ADE 3.0).

However today I came across a PDF from the same source which fails to decrypt the PDF when added to Calibre.

Question / bug report
Plugin not decrypting PDF with "hardened" DRM (ADE 3.0)

Which version of Calibre are you running?
Calibre Portable v5.44 (also tried 64-bit Calibre v5.44)

Which version of the DeDRM plugin are you running?
v10.0.3

If applicable, which version of the Kindle software are you running?
Not applicable

Log output

C:\Users\redacted my name\Calibre_5.44.0-Portable\Calibre>calibre-debug -g
calibre 5.44 embedded-python: True is64bit: False
Windows-8.1-6.3.9600 Windows ('32bit', 'WindowsPE')
32bit process running on 64bit windows
('Windows', '8.1', '6.3.9600')
Python 3.8.5
Windows: ('8.1', '6.3.9600', '', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: DeDRM (10, 0, 3)
Turning on automatic hidpi scaling
devicePixelRatio: 1.0
logicalDpi: 96.0 x 96.0
physicalDpi: 100.86162790697674 x 101.07357512953367
Using calibre Qt style: True
[0.00] Starting up...
[0.01] Showing splash screen...
[0.70] splash screen shown
[0.70] Initializing db...
[0.72] db initialized
[0.72] Constructing main UI...
[1.86] main UI initialized...
[1.86] Hiding splash screen
Starting QuickView
[2.09] splash screen hidden
[2.11] Started up in 2.11 seconds with 0 books
stdout+stderr from file dialog helper: [b'', b'']
piped data from file dialog helper:
[b'\x84)W\x0fz\x89\xb4\xf0\xe6:b\xf5\x13\xc4\x94\x02\xa3Q&\x1e+\xca\xed\xcf\xaf\x9b\xdf\x19\x1f\xd1Q\x8e',
b'C:\Users\redacted my name\Documents\My Digital Editions\redacted book name.pdf']
DeDRM v10.0.3: Trying to decrypt redacted book name.pdf
DeDRM v10.0.3: redacted book name.pdf is a PDF ebook with encryption EBX_HANDLER
DeDRM v10.0.3: redacted book name.pdf is a PDF ebook (EBX) for UUID 4a04e8d7-74a4-4549-9306-0b51588908df
DeDRM v10.0.3: Looking for new default Adobe Digital Editions Keys after 2.3 seconds
Found 1 keys
DeDRM v10.0.3: Trying a new default key
ineptpdf.py: Unknown bytes element found - guessing.
If this PDF is corrupted and/or doesn't work, please open a bug report.
Note: The above 2 line repeated 60 times...

Incomplete dictionary construct
error writing pdf: Object type <class 'str'> cannot be passed to C code
Traceback (most recent call last):
File "C:\Users\redacted my name\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2299, in decryptBook
File "C:\Users\redacted my name\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2109, in dump
File "C:\Users\redacted my name\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1840, in getobj
File "C:\Users\redacted my name\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 800, in decipher_all
File "C:\Users\redacted my name\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 800, in
File "C:\Users\redacted my name\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 796, in
File "C:\Users\redacted my name\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 795, in decipher_all
File "C:\Users\redacted my name\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1758, in decrypt_rc4
File "Crypto\Cipher\ARC4.py", line 106, in decrypt
File "Crypto\Cipher\ARC4.py", line 89, in encrypt
File "Crypto\Util_raw_api.py", line 243, in c_uint8_ptr
TypeError: Object type <class 'str'> cannot be passed to C code
DeDRM v10.0.3: Failed to decrypt with new default key after 3.7 seconds
DeDRM v10.0.3: Finished after 3.7 seconds
Added redacted book name to db in: 1.6
Added 1 books in 6.4 seconds

I would be really grateful if anyone has an idea about what the issue might be.

Thank you in advance.

Activity

  1. ElleKayEm commented on Oct 13, 2022

    @ElleKayEm

    If it's a larger file, you may have better luck with 64-bit calibre.

  2. vectoriser commented on Oct 13, 2022

    @vectoriser
    Author

    If it's a larger file, you may have better luck with 64-bit calibre.

    Thank you for your suggestion.

    Yes, the PDF is quite big at 93.7 MB.

    Unfortunately, installing 64-bit Calibre (v5.44 for my win 8.1 system) made no difference.

    BTW, I have decrypted ADE 3.0 PDFs up to 150 MB in size earlier using Calibre Portable.

    Also, this is the first undecryptable PDF encountered by me in over 10 years for ADE 2.0/3.0.

    Edit:
    Below is the slightly different error log for the same PDF using Calibre 64-bit (version 5.44 for win 8.1):

    Question / bug report
    Plugin not decrypting PDF with "hardened" DRM (ADE 3.0)

    Which version of Calibre are you running?
    64-bit Calibre v5.44 (also tried Calibre Portable v5.44)

    Which version of the DeDRM plugin are you running?
    v10.0.3

    If applicable, which version of the Kindle software are you running?
    Not applicable

    Log output

    C:\Users\redacted_username>calibre-debug -g
    calibre 5.44 [64bit] embedded-python: True is64bit: True
    Windows-8.1-6.3.9600 Windows ('64bit', 'WindowsPE')
    ('Windows', '8.1', '6.3.9600')
    Python 3.8.5
    Windows: ('8.1', '6.3.9600', '', 'Multiprocessor Free')
    Interface language: None
    Successfully initialized third party plugins: DeDRM (10, 0, 3)
    Turning on automatic hidpi scaling
    devicePixelRatio: 1.0
    logicalDpi: 96.0 x 96.0
    physicalDpi: 100.86162790697674 x 101.07357512953367
    Using calibre Qt style: True
    [0.00] Starting up...
    [0.02] Showing splash screen...
    [0.72] splash screen shown
    [0.72] Initializing db...
    [0.73] db initialized
    [0.73] Constructing main UI...
    [2.25] main UI initialized...
    [2.25] Hiding splash screen
    Starting QuickView
    [2.50] splash screen hidden
    [2.50] Started up in 2.50 seconds with 0 books
    stdout+stderr from file dialog helper: [b'', b'']
    piped data from file dialog helper: [b'\xec\x9b\xa1\xdaR\xa6E6\xb5\xf7$USl4J\x88\xbbE\tu\xa2\x9crP\xa8c\xdai\xba\xbf"',
    b'C:\Users\redacted_username\Documents\My Digital Editions\redacted_book_name.pdf']
    DeDRM v10.0.3: Trying to decrypt redacted_book_name.pdf
    DeDRM v10.0.3: redacted_book_name.pdf is a PDF ebook with encryption EBX_HANDLER
    DeDRM v10.0.3: redacted_book_name.pdf is a PDF ebook (EBX) for UUID 4a04e8d7-74a4-4549-9306-0b51588908df
    DeDRM v10.0.3: Trying UUID-matched encryption key default_ade_key_uuid_4a04e8d7-74a4-4549-9306-0b51588908df_redacted_AdobeID
    ineptpdf.py: Unknown bytes element found - guessing.
    If this PDF is corrupted and/or doesn't work, please open a bug report.
    Note: Above two lines repeated 61 times...

    Incomplete dictionary construct
    error writing pdf: Object type <class 'str'> cannot be passed to C code
    Traceback (most recent call last):
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2299, in decryptBook
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2109, in dump
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1840, in getobj
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 800, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 800, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 796, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 795, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1758, in decrypt_rc4
    File "Crypto\Cipher\ARC4.py", line 106, in decrypt
    File "Crypto\Cipher\ARC4.py", line 89, in encrypt
    File "Crypto\Util_raw_api.py", line 243, in c_uint8_ptr
    TypeError: Object type <class 'str'> cannot be passed to C code
    DeDRM v10.0.3: Trying encryption key default_ade_key_uuid_4a04e8d7-74a4-4549-9306-0b51588908df_redacted_AdobeID
    ineptpdf.py: Unknown bytes element found - guessing.
    If this PDF is corrupted and/or doesn't work, please open a bug report.
    Note: Above two lines repeated 61 times again...

    Incomplete dictionary construct
    error writing pdf: Object type <class 'str'> cannot be passed to C code
    Traceback (most recent call last):
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2299, in decryptBook
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2109, in dump
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1840, in getobj
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 800, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 800, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 796, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 795, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1758, in decrypt_rc4
    File "Crypto\Cipher\ARC4.py", line 106, in decrypt
    File "Crypto\Cipher\ARC4.py", line 89, in encrypt
    File "Crypto\Util_raw_api.py", line 243, in c_uint8_ptr
    TypeError: Object type <class 'str'> cannot be passed to C code
    DeDRM v10.0.3: Failed to decrypt with key default_ade_key_uuid_4a04e8d7-74a4-4549-9306-0b51588908df_redacted_AdobeID after 5.1 seconds
    DeDRM v10.0.3: Looking for new default Adobe Digital Editions Keys after 5.1 seconds
    Found 1 keys
    DeDRM v10.0.3: Trying a new default key
    ineptpdf.py: Unknown bytes element found - guessing.
    If this PDF is corrupted and/or doesn't work, please open a bug report.
    Note: Above two lines repeated 61 times yet again...

    Incomplete dictionary construct
    error writing pdf: Object type <class 'str'> cannot be passed to C code
    Traceback (most recent call last):
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2299, in decryptBook
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2109, in dump
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1840, in getobj
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 800, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 800, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 796, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 795, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1758, in decrypt_rc4
    File "Crypto\Cipher\ARC4.py", line 106, in decrypt
    File "Crypto\Cipher\ARC4.py", line 89, in encrypt
    File "Crypto\Util_raw_api.py", line 243, in c_uint8_ptr
    TypeError: Object type <class 'str'> cannot be passed to C code
    DeDRM v10.0.3: Failed to decrypt with new default key after 6.7 seconds
    DeDRM v10.0.3: Finished after 6.7 seconds
    Added redacted_book_name to db in: 1.6
    Added 1 books in 9.4 seconds

  3. ElleKayEm commented on Oct 13, 2022

    @ElleKayEm

    I suspected it might be more than a memory issue here, but I have seen that solve the issue a number of times so I thought it worth mentioning.

  4. noDRM commented on Oct 16, 2022

    @noDRM
    Owner

    You seem to be using the most up-to-date, master version of the plugin, not the released 10.0.3. Can you try deleting the plugin, re-download 10.0.3 from the Releases page, try again, and if it still doesn't work post a log from that version?

    Also, if possible, it would be great if you could send that PDF and the DER key file to the email address in my GitHub profile so I can take a closer look when I have time.

  5. vectoriser commented on Oct 16, 2022

    @vectoriser
    Author

    You seem to be using the most up-to-date, master version of the plugin, not the released 10.0.3. Can you try deleting the plugin, re-download 10.0.3 from the Releases page, try again, and if it still doesn't work post a log from that version?

    Also, if possible, it would be great if you could send that PDF and the DER key file to the email address in my GitHub profile so I can take a closer look when I have time.

    Thank you.

    I have deleted the plugin, installed the 10.0.3 release and tried again but without any success.

    However the resulting log is much smaller than earlier.

    I have also sent the PDF and the DER key file to your email address.

    Question / bug report

    Plugin not decrypting PDF with "hardened" DRM (ADE 3.0)

    Which version of Calibre are you running?

    64-bit Calibre v5.44

    Which version of the DeDRM plugin are you running?

    v10.0.3

    If applicable, which version of the Kindle software are you running?

    Not applicable

    Log output

    C:\Program Files\Calibre2>calibre-debug -g
    calibre 5.44 [64bit] embedded-python: True is64bit: True
    Windows-8.1-6.3.9600 Windows ('64bit', 'WindowsPE')
    ('Windows', '8.1', '6.3.9600')
    Python 3.8.5
    Windows: ('8.1', '6.3.9600', '', 'Multiprocessor Free')
    Interface language: None
    Successfully initialized third party plugins: DeDRM (10, 0, 3)
    Turning on automatic hidpi scaling
    devicePixelRatio: 1.0
    logicalDpi: 96.0 x 96.0
    physicalDpi: 100.86162790697674 x 101.07357512953367
    Using calibre Qt style: True
    [0.00] Starting up...
    [0.00] Showing splash screen...
    [0.67] splash screen shown
    [0.67] Initializing db...
    [0.69] db initialized
    [0.69] Constructing main UI...
    [2.12] main UI initialized...
    [2.12] Hiding splash screen
    Starting QuickView
    [2.38] splash screen hidden
    [2.38] Started up in 2.38 seconds with 0 books
    stdout+stderr from file dialog helper: [b'', b'']
    piped data from file dialog helper:
    [b'\xfa\x91\x0e)\xeb\xc2\x10\xeb\xd3R\x16\xc6\xc0h\xf9\xf5\x17\xb8\xb9G\x1a\x90\xb3\xc6\xbc\xac\xfcF\xde\xd9=\xf0',
    b'C:\Users\redacted_username\Documents\My Digital Editions\redacted_book_name.pdf']
    DeDRM v10.0.3: Trying to decrypt redacted_book_name.pdf
    DeDRM v10.0.3: redacted_book_name.pdf is a PDF ebook with encryption EBX_HANDLER
    DeDRM v10.0.3: redacted_book_name.pdf is a PDF ebook (EBX) for UUID 4a04e8d7-74a4-4549-9306-0b51588908df
    DeDRM v10.0.3: Trying UUID-matched encryption key
    default_ade_key_uuid_4a04e8d7-74a4-4549-9306-0b51588908df_AdobeID_redacted_email_ID
    Incomplete dictionary construct
    error writing pdf: Object type <class 'str'> cannot be passed to C code
    Traceback (most recent call last):
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2290, in decryptBook
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2118, in dump
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1849, in getobj
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 824, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 824, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 820, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 819, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1767, in decrypt_rc4
    File "Crypto\Cipher\ARC4.py", line 106, in decrypt
    File "Crypto\Cipher\ARC4.py", line 89, in encrypt
    File "Crypto\Util_raw_api.py", line 243, in c_uint8_ptr
    TypeError: Object type <class 'str'> cannot be passed to C code
    DeDRM v10.0.3: Trying encryption key
    default_ade_key_uuid_4a04e8d7-74a4-4549-9306-0b51588908df_AdobeID_redacted_email_ID
    Incomplete dictionary construct
    error writing pdf: Object type <class 'str'> cannot be passed to C code
    Traceback (most recent call last):
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2290, in decryptBook
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2118, in dump
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1849, in getobj
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 824, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 824, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 820, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 819, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1767, in decrypt_rc4
    File "Crypto\Cipher\ARC4.py", line 106, in decrypt
    File "Crypto\Cipher\ARC4.py", line 89, in encrypt
    File "Crypto\Util_raw_api.py", line 243, in c_uint8_ptr
    TypeError: Object type <class 'str'> cannot be passed to C code
    DeDRM v10.0.3: Failed to decrypt with key
    default_ade_key_uuid_4a04e8d7-74a4-4549-9306-0b51588908df_AdobeID_redacted_email_ID after 4.9 seconds
    DeDRM v10.0.3: Looking for new default Adobe Digital Editions Keys after 4.9 seconds
    Found 1 keys
    DeDRM v10.0.3: Trying a new default key
    Incomplete dictionary construct
    error writing pdf: Object type <class 'str'> cannot be passed to C code
    Traceback (most recent call last):
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2290, in decryptBook
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 2118, in dump
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1849, in getobj
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 824, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 824, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 820, in
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 819, in decipher_all
    File "C:\Users\redacted_username\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptpdf.py", line 1767, in decrypt_rc4
    File "Crypto\Cipher\ARC4.py", line 106, in decrypt
    File "Crypto\Cipher\ARC4.py", line 89, in encrypt
    File "Crypto\Util_raw_api.py", line 243, in c_uint8_ptr
    TypeError: Object type <class 'str'> cannot be passed to C code
    DeDRM v10.0.3: Failed to decrypt with new default key after 6.8 seconds
    DeDRM v10.0.3: Finished after 6.8 seconds
    Added redacted_book_name to db in: 1.8
    Added 1 books in 10.5 seconds

  6. noDRM commented on Oct 17, 2022

    @noDRM
    Owner

    Thanks for the PDF. That was a mess to track down. Should be fixed now with the newest commit, you can download that from here: https://github.com/noDRM/DeDRM_tools/suites/8813374946/artifacts/401056236

    Note that your PDF file is very large and complex, for me it took over a minute to import it into Calibre. Let me know if this version fixes your issue.

  7. vectoriser commented on Oct 17, 2022

    @vectoriser
    Author

    That was really brilliant!

    This fixes the problem.

    Thank you very much for contributing your precious time and effort to solve this issue.

    Your help is greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions