noDRM / DeDRM_tools

DeDRM tools for ebooks
7.05k stars 316 forks source link

DeDRM and DeACSM create blank pdf #195

Open SchmidL opened 1 year ago

SchmidL commented 1 year ago

Question / bug report

hi,

I just tried, as several suggested in this issue section, to use deACSM plugin in combination with DeDRM from this repo.

Unfortunately this just loaded a blank pdf, as normally happend when loading a pdf from ADE without removing the DRM.

Also the log show that a IndexError: index out of range is thrown.

Thanks for you support

Which version of Calibre are you running?

6.5

Which version of the DeDRM plugin are you running?

v.10.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.5  embedded-python: True
macOS-12.6-x86_64-i386-64bit Darwin ('64bit', '')
('Darwin', '21.6.0', 'Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64')
Python 3.10.1
OSX: ('12.6', ('', '', ''), 'x86_64')
Interface language: None
Successfully initialized third party plugins: DeACSM (0, 0, 16) && DeDRM (10, 0, 3) && Find Duplicates (1, 9, 7)
calibre 6.5  embedded-python: True
macOS-12.6-x86_64-i386-64bit Darwin ('64bit', '')
('Darwin', '21.6.0', 'Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64')
Python 3.10.1
OSX: ('12.6', ('', '', ''), 'x86_64')
Interface language: None
Successfully initialized third party plugins: DeACSM (0, 0, 16) && DeDRM (10, 0, 3) && Find Duplicates (1, 9, 7)
QPA platform: cocoa
devicePixelRatio: 1.0
logicalDpi: 72.0 x 72.0
physicalDpi: 72.00000108133152 x 72.00000108133152
[0.00] Starting up...
[0.03] Showing splash screen...
[0.27] splash screen shown
[0.27] Initializing db...
[0.35] db initialized
[0.35] Constructing main UI...
[1.35] main UI initialized...
[1.35] Hiding splash screen
Starting QuickView
[5.48] splash screen hidden
[5.48] Started up in 5.48 seconds with 2790 books
DeDRM v10.0.3: Trying to decrypt v4sj3lko.pdf
DeDRM v10.0.3: v4sj3lko.pdf is a PDF ebook with encryption EBX_HANDLER
DeDRM v10.0.3: v4sj3lko.pdf is a PDF ebook (EBX) for UUID 616bc716-fca7-4970-b104-491cd0ea2f98
DeDRM v10.0.3: Trying encryption key 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.1 seconds
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 724, in PDFIneptDecrypt
    result = ineptpdf.decryptBook(userkey, path_to_ebook, of.name)
  File "/Users/lorenz/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2286, in decryptBook
    serializer = PDFSerializer(inf, userkey, inept)
  File "/Users/lorenz/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2094, in __init__
    doc.initialize(userkey, inept)
  File "/Users/lorenz/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1253, in initialize
    return self.initialize_ebx_inept(password, docid, param)
  File "/Users/lorenz/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 key default_key after 0.1 seconds
DeDRM v10.0.3: Looking for new default Adobe Digital Editions Keys after 0.1 seconds
DeDRM v10.0.3: Found new key 'DeACSM_uuid_616bc716-fca7-4970-b104-491cd0ea2f98' in DeACSM plugin
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.3 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/lorenz/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2286, in decryptBook
    serializer = PDFSerializer(inf, userkey, inept)
  File "/Users/lorenz/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2094, in __init__
    doc.initialize(userkey, inept)
  File "/Users/lorenz/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1253, in initialize
    return self.initialize_ebx_inept(password, docid, param)
  File "/Users/lorenz/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.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.4 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/lorenz/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2286, in decryptBook
    serializer = PDFSerializer(inf, userkey, inept)
  File "/Users/lorenz/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2094, in __init__
    doc.initialize(userkey, inept)
  File "/Users/lorenz/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1253, in initialize
    return self.initialize_ebx_inept(password, docid, param)
  File "/Users/lorenz/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.4 seconds
DeDRM v10.0.3: Finished after 0.4 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
DeACSM v0.0.16: Trying to parse file GehirnGeist032022.acsm
DeACSM v0.0.16: Try to fulfill ...
Notifying server ...
Notifying server https://acs6.onleihe.de/fulfillment/FulfillmentNotification
Fulfillment notification successful.
Notifying optional server https://ws.onleihe.de/acs6-return
Fulfillment notification successful (204).
DeACSM v0.0.16: Downloading book ...
DeACSM v0.0.16: Loading book from https://dp1.onleihe.de/downloadprovider/epub/20220204/9d375dc8-1ed5-33b9-973d-276290acda70.pdf
Download took 3410 ms (HTTP 200)
That's a PDF file
DeACSM v0.0.16: Downloaded PDF, adding encryption config ...
Searching for startxref ...
Got startxref: 8883863
Found ENC after 5 attempts - took 1 ms
Found EBX after 2062 attempts - took 4 ms

Encryption handler:
<</Root 1 0 R/Info 5 0 R/Encrypt 2051 0 R/ID[<05339E570442487CB736AB79F76DDE58><A56123FCE4CBD0477D31148C634E625F>]/Size 2052>>
EBX handler:
<</EBX_PUBLISHER(Spektrum der Wissenschaft Verlagsgesellschaft mbH)/Filter/EBX_HANDLER/Length 128/ADEPT_ID(urn:uuid:a08ebdff-6bae-4a13-92c2-0ab28d1021ff)/V 4/EBX_TITLE(Gehirn & Geist \\\(03/2022\\\))/EBX_AUTHOR()>>
Trimmed encryption handler:
<</Root 1 0 R/Info 5 0 R/Encrypt 2051 0 R/ID[<05339E570442487CB736AB79F76DDE58><A56123FCE4CBD0477D31148C634E625F>]/Size 2052>>
Updated EBX handler not logged due to sensitive data
Whole DRM patching took 25 milliseconds.
DeACSM v0.0.16: File successfully fulfilled ...
DeACSM v0.0.16: Executing plugin DeDRM ...
DeACSM v0.0.16: Plugin returned nothing - skipping
Syntax Error: Couldn't find the 'EBX_HANDLER' security handler
pdfinfo errored out with return code: 1
ElleKayEm commented 1 year ago

Are you able to read it with ADE authorized with your Adobe ID?

SchmidL commented 1 year ago

Yes if I load an acsm first in my ADE and then in calibre it works fine (that is what i do right now, but i wanted to remove the manual opening in ADE)Am 28.10.2022 um 00:03 schrieb ElleKayEm @.***>: Are you able to read it with ADE authorized with your Adobe ID?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

ElleKayEm commented 1 year ago

So if you add the PDF downloaded with ADE to calibre, the DRM is removed? And DeACSM is setup with the same Adobe ID?

SchmidL commented 1 year ago

Yes. When the ACSM is opend in ADE -> the PDF gets imported into calibre -> DeDRM removes the DRM. What not works is: ACSM directly opened in calibre -> PDF gets downloaded by DeACSM > DRM not removed.

First I used an anonymous authorization, but also tried it now with my original Adobe ID. So maybe it is an DeACSM problem, but just the error is then detected in by DeDRM

ElleKayEm commented 1 year ago

In the log above, it looks like DeDRM totally ignores the pdf downloaded by DeACSM. So I would guess that DeACSM isn't tieing the PDF to your Adobe ID. (Since we know DeDRM can decrypt the PDF from ADE.) I'm actually surprised DeACSM can download it at all if it was orginally downloaded with a different Adobe ID. I haven't used DeACSM myself so this is just speculation and I don't know how to resolve it.

noDRM commented 1 year ago

Where in the log do you see DeDRM ignoring the file? It's just that because DeDRM and the DeACSM plugin apparently use different ways to implement their log that the log entries aren't always in the correct order.

Though, I can't see any reason why that decryption would fail. The user UUID in the encrypted book file and the user UUID extracted from the DeACSM plugin are identical in your log - 616bc716-fca7-4970-b104-491cd0ea2f98.

Do you happen to have an ADE installation with the same AdobeID? Can ADE open the PDF file (with DRM) that was created by the DeACSM plugin? That was what ElleKayEm tried to ask twice - not what happens when you open the ACSM in ADE, but what happens when you open the PDF with DRM - so, after it runs through DeACSM but before it runs through DeDRM - in ADE.

ElleKayEm commented 1 year ago

@noDRM This is where I thought DeDRM didn't do anything. Thanks for explaining.

DeACSM v0.0.16: File successfully fulfilled ... DeACSM v0.0.16: Executing plugin DeDRM ... DeACSM v0.0.16: Plugin returned nothing - skipping