Porównaj commity

...

4 Commity

Autor SHA1 Wiadomość Data
NoDRM e82d2b5c9c Fix PDF decryption for 256-bit AES with V=5 2023-08-02 18:13:42 +02:00
NoDRM 7f6dd84389 Fix PDF decryption of ancient 40-bit RC4 with R=2 2023-08-02 16:55:41 +02:00
NoDRM b9bad26d4b Prepare release candidate v10.0.9 2023-08-02 07:39:35 +02:00
NoDRM 2a1413297e Add warning to the standalone code 2023-08-02 07:30:39 +02:00
13 zmienionych plików z 98 dodań i 23 usunięć

Wyświetl plik

@ -10,16 +10,16 @@ body:
id: calibre-version
attributes:
label: Which version of Calibre are you running?
description: "Example: 5.32"
placeholder: "5.32"
description: "Example: 6.23"
placeholder: "6.23"
validations:
required: true
- type: input
id: plugin-version
attributes:
label: Which version of the DeDRM plugin are you running?
description: "Example: v10.0.0"
placeholder: "v10.0.0"
description: "Example: v10.0.2"
placeholder: "v10.0.2"
validations:
required: true
- type: input

Wyświetl plik

@ -67,7 +67,11 @@ List of changes since the fork of Apprentice Harper's repository:
- Fix Nook Study key retrieval code (partially fixes #50).
- Make the plugin work on Calibre 6 (Qt 6). (fixes #54 and #98) If you're running Calibre 6 and you notice any issues, please open a bug report.
## Fixes on master (not yet released):
## Fixes in v10.0.9 (RC for v10.1.0, 2023-08-02):
Note that versions v10.0.4(s), v10.0.5(s) and v10.0.6(s) were released by other people in various forks, so I have decided to make a larger version jump so there are no conflicting version numbers / different builds with the same version number.
This is v10.0.9, a release candidate for v10.1.0. I don't expect there to be major issues / bugs, but since a lot of code has changed in the last year I wanted to get some "extended testing" before this becomes v10.1.0.
- Fix a bug introduced with #48 that breaks DeDRM'ing on Calibre 4 (fixes #101).
- Fix some more Calibre-6 bugs in the Obok plugin (should fix #114).
@ -92,3 +96,8 @@ List of changes since the fork of Apprentice Harper's repository:
- Two bugfixes for Amazon DeDRM from Satuoni ( https://github.com/noDRM/DeDRM_tools/issues/315#issuecomment-1508305428 ) and andrewc12 ( https://github.com/andrewc12/DeDRM_tools/commit/d9233d61f00d4484235863969919059f4d0b2057 ) that might make the plugin work with newer versions.
- Fix font decryption not working with some books (fixes #347), thanks for the patch @bydioeds.
- Fix a couple unicode errors for Python2 in Kindle and Nook code.
## Fixes on master (not yet released):
- Fix a bug where decrypting a 40-bit RC4 pdf with R=2 didn't work.
- Fix a bug where decrypting a 256-bit AES pdf with V=5 didn't work.

Wyświetl plik

@ -17,7 +17,7 @@ p {margin-top: 0}
<body>
<h1>DeDRM Plugin <span class="version">(v10.0.3)</span></h1>
<h1>DeDRM Plugin <span class="version">(v10.0.9 / v10.1.0 RC1)</span></h1>
<p>This plugin removes DRM from ebooks when they are imported into calibre. If you already have DRMed ebooks in your calibre library, you will need to remove them and import them again.</p>
@ -26,6 +26,8 @@ p {margin-top: 0}
<h3>Installation</h3>
<p>You have obviously managed to install the plugin, as otherwise you wouldnt be reading this help file. However, you should also delete any older DRM removal plugins, as this DeDRM plugin replaces the five older plugins: Kindle and Mobipocket DeDRM (K4MobiDeDRM), Ignoble Epub DeDRM (ignobleepub), Inept Epub DeDRM (ineptepub), Inept PDF DeDRM (ineptepub) and eReader PDB 2 PML (eReaderPDB2PML).</p>
<p>This plugin (in versions v10.0.0 and above) will automatically replace the older 7.X and below versions from Apprentice Alf and Apprentice Harper.</p>
<h3>Configuration</h3>
<p>On Windows and Mac, the keys for ebooks downloaded for Kindle for Mac/PC and Adobe Digital Editions are automatically generated. If all your DRMed ebooks can be opened and read in Kindle for Mac/PC and/or Adobe Digital Editions on the same computer on which you are running calibre, you do not need to do any configuration of this plugin. On Linux, keys for Kindle for PC and Adobe Digital Editions need to be generated separately (see the Linux section below).</p>
@ -60,7 +62,7 @@ p {margin-top: 0}
<li>And probably many more.</li>
</ul>
<h3>For additional help read the <a href="https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md">FAQs</a> at <a href="https://github.com/noDRM/DeDRM_tools">NoDRM's GitHub repository</a> (or the corresponding <a href="https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md">FAQs</a> at <a href="https://github.com/apprenticeharper/DeDRM_tools/">Apprentice Harperss GitHub repository</a>). You can <a href="https://github.com/noDRM/DeDRM_tools/issues">open issue reports</a>related to this fork at NoDRM's GitHub repository.</h3>
<h4>For additional help read the <a href="https://github.com/noDRM/DeDRM_tools/blob/master/FAQs.md">FAQs</a> at <a href="https://github.com/noDRM/DeDRM_tools">NoDRM's GitHub repository</a> (or the corresponding <a href="https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md">FAQs</a> at <a href="https://github.com/apprenticeharper/DeDRM_tools/">Apprentice Harperss GitHub repository</a>). You can <a href="https://github.com/noDRM/DeDRM_tools/issues">open issue reports</a> related to this fork at NoDRM's GitHub repository.</h4>
<h2>Linux Systems Only</h2>

Wyświetl plik

@ -5,7 +5,7 @@ from __future__ import print_function
# __init__.py for DeDRM_plugin
# Copyright © 2008-2020 Apprentice Harper et al.
# Copyright © 2021 NoDRM
# Copyright © 2021-2023 NoDRM
__license__ = 'GPL v3'
__docformat__ = 'restructuredtext en'
@ -82,6 +82,7 @@ __docformat__ = 'restructuredtext en'
# 10.0.0 - First forked version by NoDRM. See CHANGELOG.md for details.
# 10.0.1 - Fixes a bug in the watermark code.
# 10.0.2 - Fix Kindle for Mac & update Adobe key retrieval
# For changes made in 10.0.3 and above, see the CHANGELOG.md file
"""
Decrypt DRMed ebooks.

Wyświetl plik

@ -4,7 +4,7 @@
#@@CALIBRE_COMPAT_CODE@@
PLUGIN_NAME = "DeDRM"
__version__ = '10.0.3'
__version__ = '10.0.9'
PLUGIN_VERSION_TUPLE = tuple([int(x) for x in __version__.split(".")])
PLUGIN_VERSION = ".".join([str(x)for x in PLUGIN_VERSION_TUPLE])

Wyświetl plik

@ -1366,14 +1366,14 @@ class PDFDocument(object):
def process_with_aes(self, key, encrypt, data, repetitions = 1, iv = None):
if iv is None:
keylen = len(key)
iv = bytes([0x00]*keylen)
iv = bytes(bytearray(16))
aes = AES.new(key, AES.MODE_CBC, iv)
if not encrypt:
plaintext = AES.new(key,AES.MODE_CBC,iv, True).decrypt(data)
plaintext = aes.decrypt(data)
return plaintext
else:
aes = AES.new(key, AES.MODE_CBC, iv, False)
new_data = bytes(data * repetitions)
crypt = aes.encrypt(new_data)
return crypt
@ -1394,10 +1394,18 @@ class PDFDocument(object):
raise Exception("K1 < 32 ...")
#def process_with_aes(self, key: bytes, encrypt: bool, data: bytes, repetitions: int = 1, iv: bytes = None):
E = self.process_with_aes(K[:16], True, K1, 64, K[16:32])
K = (hashlib.sha256, hashlib.sha384, hashlib.sha512)[sum(E) % 3](E).digest()
E = bytearray(E)
E_mod_3 = 0
for i in range(16):
E_mod_3 += E[i]
E_mod_3 %= 3
K = (hashlib.sha256, hashlib.sha384, hashlib.sha512)[E_mod_3](E).digest()
if round_number >= 64:
ch = int.from_bytes(E[-1:], "big", signed=False)
ch = E[-1:][0] # get last byte
if ch <= round_number - 32:
done = True
@ -1478,14 +1486,23 @@ class PDFDocument(object):
EncMetadata = b'True'
if (EncMetadata == ('False' or 'false') or V < 4) and R >= 4:
hash.update(codecs.decode(b'ffffffff','hex'))
# Finish hash:
hash = hash.digest()
if R >= 3:
# 8
for _ in range(50):
hash = hashlib.md5(hash.digest()[:length//8])
key = hash.digest()[:length//8]
hash = hashlib.md5(hash[:length//8]).digest()
if R == 2:
# R=2 only uses first five bytes.
key = hash[:5]
else:
key = hash[:length//8]
if R == 2:
# Algorithm 3.4
u1 = ARC4.new(key).decrypt(password)
u1 = ARC4.new(key).decrypt(self.PASSWORD_PADDING)
elif R >= 3:
# Algorithm 3.5
hash = hashlib.md5(self.PASSWORD_PADDING) # 2
@ -1498,6 +1515,7 @@ class PDFDocument(object):
k = b''.join(bytes([c ^ i]) for c in key )
x = ARC4.new(k).decrypt(x)
u1 = x+x # 32bytes total
if R == 2:
is_authenticated = (u1 == U)
else:

Wyświetl plik

@ -7,6 +7,18 @@ from __future__ import absolute_import, print_function
# Copyright © 2021 NoDRM
"""
NOTE: This code is not functional (yet). I started working on it a while ago
to make a standalone version of the plugins that could work without Calibre,
too, but for now there's only a rough code structure and no working code yet.
Currently, to use these plugins, you will need to use Calibre. Hopwfully that'll
change in the future.
"""
OPT_SHORT_TO_LONG = [
["c", "config"],
["e", "extract"],

Wyświetl plik

@ -8,6 +8,17 @@ from __future__ import absolute_import, print_function
# Taken from Calibre code - Copyright © 2008, Kovid Goyal kovid@kovidgoyal.net, GPLv3
"""
NOTE: This code is not functional (yet). I started working on it a while ago
to make a standalone version of the plugins that could work without Calibre,
too, but for now there's only a rough code structure and no working code yet.
Currently, to use these plugins, you will need to use Calibre. Hopwfully that'll
change in the future.
"""
#@@CALIBRE_COMPAT_CODE@@
import sys, os, codecs, json

Wyświetl plik

@ -8,6 +8,17 @@ from __future__ import absolute_import, print_function
# Copyright © 2021 NoDRM
"""
NOTE: This code is not functional (yet). I started working on it a while ago
to make a standalone version of the plugins that could work without Calibre,
too, but for now there's only a rough code structure and no working code yet.
Currently, to use these plugins, you will need to use Calibre. Hopwfully that'll
change in the future.
"""
#@@CALIBRE_COMPAT_CODE@@
import os, sys

Wyświetl plik

@ -8,6 +8,17 @@ from __future__ import absolute_import, print_function
# Copyright © 2021 NoDRM
"""
NOTE: This code is not functional (yet). I started working on it a while ago
to make a standalone version of the plugins that could work without Calibre,
too, but for now there's only a rough code structure and no working code yet.
Currently, to use these plugins, you will need to use Calibre. Hopwfully that'll
change in the future.
"""
#@@CALIBRE_COMPAT_CODE@@
import os, sys

Wyświetl plik

@ -3,7 +3,7 @@ from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3'
__version__ = '10.0.3'
__version__ = '10.0.9'
__docformat__ = 'restructuredtext en'
#####################################################################
@ -20,7 +20,7 @@ except NameError:
PLUGIN_NAME = 'Obok DeDRM'
PLUGIN_SAFE_NAME = PLUGIN_NAME.strip().lower().replace(' ', '_')
PLUGIN_DESCRIPTION = _('Removes DRM from Kobo kepubs and adds them to the library.')
PLUGIN_VERSION_TUPLE = (10, 0, 3)
PLUGIN_VERSION_TUPLE = (10, 0, 9)
PLUGIN_VERSION = '.'.join([str(x) for x in PLUGIN_VERSION_TUPLE])
HELPFILE_NAME = PLUGIN_SAFE_NAME + '_Help.htm'
PLUGIN_AUTHORS = 'Anon'

Wyświetl plik

@ -168,8 +168,8 @@
"""Manage all Kobo books, either encrypted or DRM-free."""
from __future__ import print_function
__version__ = '10.0.1'
__about__ = "Obok v{0}\nCopyright © 2012-2022 Physisticated et al.".format(__version__)
__version__ = '10.0.9'
__about__ = "Obok v{0}\nCopyright © 2012-2023 Physisticated et al.".format(__version__)
import sys
import os

Wyświetl plik

@ -8,7 +8,7 @@
<body>
<h1>Obok DeDRM Plugin</h1>
<h3>(version 10.0.2)</h3>
<h3>(version 10.0.9 / 10.1.0 RC1)</h3>
<h3>Installation:</h3>