noDRM / DeDRM_tools

DeDRM tools for ebooks
7.32k stars 323 forks source link

DeDRM returns blank PDF: Syntax Error: Couldn't find the 'EBX_HANDLER' security handler #250

Open caeochoa opened 1 year ago

caeochoa commented 1 year ago

Question / bug report

I've bought an ebook through Google Play and I'm trying to read it on my kindle. I've downloaded the book as an .acsm file and opened it with Adobe Digital Editions 4.5. Once I open it, I can read it on ADE, but when I locate the file I can only find a blank PDF. I assumed this was due to DRM, so I'm attempting to use deDRM to remove the DRM. I've installed the plugin and loaded my Adobe ID key, but when I import the PDF file into the library it stays blank.

Which version of Calibre are you running?

6.11.0

Which version of the DeDRM plugin are you running?

v10.0.3

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

No response

Log output

Using calibre Qt style: True
calibre Debug log
calibre 6.11  embedded-python: True
macOS-12.5.1-x86_64-i386-64bit Darwin ('64bit', '')
('Darwin', '21.6.0', 'Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64')
Python 3.10.1
OSX: ('12.5.1', ('', '', ''), 'x86_64')
Interface language: None
Successfully initialized third party plugins: DeDRM (10, 0, 3) && Obok DeDRM (10, 0, 3)
calibre 6.11  embedded-python: True
macOS-12.5.1-x86_64-i386-64bit Darwin ('64bit', '')
('Darwin', '21.6.0', 'Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64')
Python 3.10.1
OSX: ('12.5.1', ('', '', ''), 'x86_64')
Interface language: None
Successfully initialized third party plugins: DeDRM (10, 0, 3) && Obok DeDRM (10, 0, 3)
QPA platform: cocoa
devicePixelRatio: 2.0
logicalDpi: 72.0 x 72.0
physicalDpi: 128.00000192236715 x 127.50000191485789
[0.00] Starting up...
[0.05] Showing splash screen...
[0.30] splash screen shown
[0.30] Initializing db...
[0.32] db initialized
[0.32] Constructing main UI...
DEBUG:    0.0 obok::utilities.py - loading translations
DEBUG:    0.0 obok::dialogs.py - loading translations
DEBUG:    0.0 obok::config.py - loading translations
DEBUG:    0.1 obok::action_err.py - loading translations
Screens currently in system:
{'depth': 24,
 'device_pixel_ratio': 2.0,
 'geometry_in_logical_pixels': {'height': 900, 'width': 1440, 'x': 0, 'y': 0},
 'index_in_screens_list': 0,
 'manufacturer': '',
 'model': '',
 'name': 'Color LCD',
 'serial': '',
 'size_in_logical_pixels': {'height': 900, 'width': 1440},
 'virtual_geometry': {'height': 900, 'width': 1440, 'x': 0, 'y': 0}}
Restoring geometry for: calibre_main_window_geometry
{'frame_geometry': {'height': 505, 'width': 1108, 'x': 214, 'y': 52},
 'full_screened': False,
 'geometry': {'height': 477, 'width': 1108, 'x': 214, 'y': 80},
 'maximized': False,
 'normal_geometry': {'height': 477, 'width': 1108, 'x': 214, 'y': 80},
 'screen': {'depth': 24,
            'device_pixel_ratio': 2.0,
            'geometry_in_logical_pixels': {'height': 900,
                                           'width': 1440,
                                           'x': 0,
                                           'y': 0},
            'index_in_screens_list': 0,
            'manufacturer': '',
            'model': '',
            'name': 'Color LCD',
            'serial': '',
            'size_in_logical_pixels': {'height': 900, 'width': 1440},
            'virtual_geometry': {'height': 900, 'width': 1440, 'x': 0, 'y': 0}}}
Matching screen: {'depth': 24,
 'device_pixel_ratio': 2.0,
 'geometry_in_logical_pixels': {'height': 900, 'width': 1440, 'x': 0, 'y': 0},
 'index_in_screens_list': 0,
 'manufacturer': '',
 'model': '',
 'name': 'Color LCD',
 'serial': '',
 'size_in_logical_pixels': {'height': 900, 'width': 1440},
 'virtual_geometry': {'height': 900, 'width': 1440, 'x': 0, 'y': 0}}
Setting widget geometry to: {'height': 477, 'width': 1108, 'x': 214, 'y': 80}
[1.49] main UI initialized...
[1.49] Hiding splash screen
Starting QuickView
2023-01-14 01:39:37.855 calibre-debug[18021:20864474] TSMSendMessageToUIServer: CFMessagePortSendRequest FAILED(-1) to send to port com.apple.tsm.uiserver
DeDRM v10.0.3: Trying to decrypt Games.pdf
DeDRM v10.0.3: Games.pdf is a PDF ebook with encryption EBX_HANDLER
DeDRM v10.0.3: Games.pdf is a PDF ebook (EBX) for UUID 17b85538-2996-44f3-bd30-b741217e40fc
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "encodings/hex_codec.py", line 19, in hex_decode
ValueError: string argument should contain only ASCII characters

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "calibre/customize/ui.py", line 178, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 1063, in run
    decrypted_ebook = self.PDFDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 923, in PDFDecrypt
    return self.PDFIneptDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 718, in PDFIneptDecrypt
    userkey = codecs.decode(userkeyhex,'hex')
ValueError: decoding with 'hex' codec failed (ValueError: string argument should contain only ASCII characters)
[7.16] splash screen hidden
[7.17] Started up in 7.17 seconds with 27 books
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 435, in get_file_type_metadata
  File "calibre/customize/builtins.py", line 324, in get_metadata
  File "calibre/ebooks/metadata/pdf.py", line 124, in get_metadata
ValueError: Could not read info dict from PDF
Syntax Error: Couldn't find the 'EBX_HANDLER' security handler
pdfinfo errored out with return code: 1
2023-01-14 01:39:59.359 calibre-debug[18021:20864474] TSMSendMessageToUIServer: CFMessagePortSendRequest FAILED(-1) to send to port com.apple.tsm.uiserver
2023-01-14 01:39:59.362 calibre-debug[18021:20864474] TSMSendMessageToUIServer: CFMessagePortSendRequest FAILED(-1) to send to port com.apple.tsm.uiserver
Added Games to db in: 0.0
Added 1 books in 1.7 seconds
Restoring geometry for: preferences dialog geometry
{'frame_geometry': {'height': 748, 'width': 930, 'x': 31, 'y': 130},
 'full_screened': False,
 'geometry': {'height': 720, 'width': 930, 'x': 31, 'y': 158},
 'maximized': False,
 'normal_geometry': {'height': 720, 'width': 930, 'x': 31, 'y': 158},
 'screen': {'depth': 24,
            'device_pixel_ratio': 2.0,
            'geometry_in_logical_pixels': {'height': 900,
                                           'width': 1440,
                                           'x': 0,
                                           'y': 0},
            'index_in_screens_list': 0,
            'manufacturer': '',
            'model': '',
            'name': 'Color LCD',
            'serial': '',
            'size_in_logical_pixels': {'height': 900, 'width': 1440},
            'virtual_geometry': {'height': 900, 'width': 1440, 'x': 0, 'y': 0}}}
Matching screen: {'depth': 24,
 'device_pixel_ratio': 2.0,
 'geometry_in_logical_pixels': {'height': 900, 'width': 1440, 'x': 0, 'y': 0},
 'index_in_screens_list': 0,
 'manufacturer': '',
 'model': '',
 'name': 'Color LCD',
 'serial': '',
 'size_in_logical_pixels': {'height': 900, 'width': 1440},
 'virtual_geometry': {'height': 900, 'width': 1440, 'x': 0, 'y': 0}}
Setting widget geometry to: {'height': 720, 'width': 930, 'x': 31, 'y': 158}
Saving geometry for: preferences dialog geometry
{'frame_geometry': {'height': 748, 'width': 930, 'x': 31, 'y': 130},
 'full_screened': False,
 'geometry': {'height': 720, 'width': 930, 'x': 31, 'y': 158},
 'maximized': False,
 'normal_geometry': {'height': 720, 'width': 930, 'x': 31, 'y': 158},
 'screen': {'depth': 24,
            'device_pixel_ratio': 2.0,
            'geometry_in_logical_pixels': {'height': 900,
                                           'width': 1440,
                                           'x': 0,
                                           'y': 0},
            'index_in_screens_list': 0,
            'manufacturer': '',
            'model': '',
            'name': 'Color LCD',
            'serial': '',
            'size_in_logical_pixels': {'height': 900, 'width': 1440},
            'virtual_geometry': {'height': 900, 'width': 1440, 'x': 0, 'y': 0}}}
Saving geometry for: calibre_main_window_geometry
{'frame_geometry': {'height': 505, 'width': 1108, 'x': 214, 'y': 52},
 'full_screened': False,
 'geometry': {'height': 477, 'width': 1108, 'x': 214, 'y': 80},
 'maximized': False,
 'normal_geometry': {'height': 477, 'width': 1108, 'x': 214, 'y': 80},
 'screen': {'depth': 24,
            'device_pixel_ratio': 2.0,
            'geometry_in_logical_pixels': {'height': 900,
                                           'width': 1440,
                                           'x': 0,
                                           'y': 0},
            'index_in_screens_list': 0,
            'manufacturer': '',
            'model': '',
            'name': 'Color LCD',
            'serial': '',
            'size_in_logical_pixels': {'height': 900, 'width': 1440},
            'virtual_geometry': {'height': 900, 'width': 1440, 'x': 0, 'y': 0}}}
ElleKayEm commented 1 year ago

Delete the Adobe key from DeDRM's customization. Re-add the book to calibre letting DeDRM automatically retrieve the key on its own.

caeochoa commented 1 year ago

Thank you! I did that but I'm still having the same problem unfortunately :( -- the pdf appears blank on my calibre library. The error seems different though, so that's promising. Do you know what I can do now?

Using calibre Qt style: True
calibre Debug log
calibre 6.11  embedded-python: True
macOS-12.5.1-x86_64-i386-64bit Darwin ('64bit', '')
('Darwin', '21.6.0', 'Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64')
Python 3.10.1
OSX: ('12.5.1', ('', '', ''), 'x86_64')
Interface language: None
Successfully initialized third party plugins: DeDRM (10, 0, 3) && Obok DeDRM (10, 0, 3)
calibre 6.11  embedded-python: True
macOS-12.5.1-x86_64-i386-64bit Darwin ('64bit', '')
('Darwin', '21.6.0', 'Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64')
Python 3.10.1
OSX: ('12.5.1', ('', '', ''), 'x86_64')
Interface language: None
Successfully initialized third party plugins: DeDRM (10, 0, 3) && Obok DeDRM (10, 0, 3)
QPA platform: cocoa
devicePixelRatio: 2.0
logicalDpi: 72.0 x 72.0
physicalDpi: 128.00000192236715 x 127.50000191485789
[0.00] Starting up...
[0.08] Showing splash screen...
[0.47] splash screen shown
[0.47] Initializing db...
[0.67] db initialized
[0.67] Constructing main UI...
DEBUG:    0.0 obok::utilities.py - loading translations
DEBUG:    0.0 obok::dialogs.py - loading translations
DEBUG:    0.0 obok::config.py - loading translations
DEBUG:    0.2 obok::action_err.py - loading translations
Screens currently in system:
{'depth': 24,
 'device_pixel_ratio': 2.0,
 'geometry_in_logical_pixels': {'height': 900, 'width': 1440, 'x': 0, 'y': 0},
 'index_in_screens_list': 0,
 'manufacturer': '',
 'model': '',
 'name': 'Color LCD',
 'serial': '',
 'size_in_logical_pixels': {'height': 900, 'width': 1440},
 'virtual_geometry': {'height': 900, 'width': 1440, 'x': 0, 'y': 0}}
Restoring geometry for: calibre_main_window_geometry
{'frame_geometry': {'height': 505, 'width': 1108, 'x': 214, 'y': 52},
 'full_screened': False,
 'geometry': {'height': 477, 'width': 1108, 'x': 214, 'y': 80},
 'maximized': False,
 'normal_geometry': {'height': 477, 'width': 1108, 'x': 214, 'y': 80},
 'screen': {'depth': 24,
            'device_pixel_ratio': 2.0,
            'geometry_in_logical_pixels': {'height': 900,
                                           'width': 1440,
                                           'x': 0,
                                           'y': 0},
            'index_in_screens_list': 0,
            'manufacturer': '',
            'model': '',
            'name': 'Color LCD',
            'serial': '',
            'size_in_logical_pixels': {'height': 900, 'width': 1440},
            'virtual_geometry': {'height': 900, 'width': 1440, 'x': 0, 'y': 0}}}
Matching screen: {'depth': 24,
 'device_pixel_ratio': 2.0,
 'geometry_in_logical_pixels': {'height': 900, 'width': 1440, 'x': 0, 'y': 0},
 'index_in_screens_list': 0,
 'manufacturer': '',
 'model': '',
 'name': 'Color LCD',
 'serial': '',
 'size_in_logical_pixels': {'height': 900, 'width': 1440},
 'virtual_geometry': {'height': 900, 'width': 1440, 'x': 0, 'y': 0}}
Setting widget geometry to: {'height': 477, 'width': 1108, 'x': 214, 'y': 80}
[3.48] main UI initialized...
[3.48] Hiding splash screen
Starting QuickView
[31.38] splash screen hidden
[31.38] Started up in 31.38 seconds with 27 books
DeDRM v10.0.3: Trying to decrypt Games.pdf
DeDRM v10.0.3: Games.pdf is a PDF ebook with encryption EBX_HANDLER
DeDRM v10.0.3: Games.pdf is a PDF ebook (EBX) for UUID 17b85538-2996-44f3-bd30-b741217e40fc
DeDRM v10.0.3: Looking for new default Adobe Digital Editions Keys after 0.3 seconds
DeDRM v10.0.3: Trying a new default key
ebx_V is 4  and ebx_type is 6
length is 16 and len(bookkey) is 0
DeDRM v10.0.3: Exception when decrypting after 0.7 seconds
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 795, in PDFIneptDecrypt
    result = ineptpdf.decryptBook(userkey, path_to_ebook, of.name)
  File "/Users/caeochoa/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2286, in decryptBook
    serializer = PDFSerializer(inf, userkey, inept)
  File "/Users/caeochoa/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2094, in __init__
    doc.initialize(userkey, inept)
  File "/Users/caeochoa/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1253, in initialize
    return self.initialize_ebx_inept(password, docid, param)
  File "/Users/caeochoa/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1707, in initialize_ebx_inept
    print("bookkey[0] is %d" % bookkey[0])
IndexError: index out of range
DeDRM v10.0.3: Failed to decrypt with new default key after 0.7 seconds
DeDRM v10.0.3: Finished after 0.7 seconds
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 435, in get_file_type_metadata
  File "calibre/customize/builtins.py", line 324, in get_metadata
  File "calibre/ebooks/metadata/pdf.py", line 124, in get_metadata
ValueError: Could not read info dict from PDF
Syntax Error: Couldn't find the 'EBX_HANDLER' security handler
pdfinfo errored out with return code: 1
Added Games to db in: 0.1
Added 1 books in 4.2 seconds
Saving geometry for: calibre_main_window_geometry
{'frame_geometry': {'height': 505, 'width': 1108, 'x': 214, 'y': 52},
 'full_screened': False,
 'geometry': {'height': 477, 'width': 1108, 'x': 214, 'y': 80},
 'maximized': False,
 'normal_geometry': {'height': 477, 'width': 1108, 'x': 214, 'y': 80},
 'screen': {'depth': 24,
            'device_pixel_ratio': 2.0,
            'geometry_in_logical_pixels': {'height': 900,
                                           'width': 1440,
                                           'x': 0,
                                           'y': 0},
            'index_in_screens_list': 0,
            'manufacturer': '',
            'model': '',
            'name': 'Color LCD',
            'serial': '',
            'size_in_logical_pixels': {'height': 900, 'width': 1440},
            'virtual_geometry': {'height': 900, 'width': 1440, 'x': 0, 'y': 0}}}
ElleKayEm commented 1 year ago

ADE used to download the pdf (and where you can read it) is on the same machine and user as calibre with DeDRM? Was ADE authorized with an Adobe ID?

harenber commented 1 year ago

See the same and can confirm that ADE was authorized (tried both Linux and Mac). An older PDF downloaded by ADE still works, so it seems like something has changed in the PDF format.