diff --git a/calibre-plugin/__init__.py b/calibre-plugin/__init__.py index ea2a0f7..ec3cca8 100644 --- a/calibre-plugin/__init__.py +++ b/calibre-plugin/__init__.py @@ -61,7 +61,7 @@ __version__ = PLUGIN_VERSION = ".".join([str(x)for x in PLUGIN_VERSION_TUPLE]) from calibre.utils.config import config_dir # type: ignore -from calibre.constants import isosx, iswindows, islinux # type: ignore +from calibre.constants import islinux # type: ignore import os, shutil, traceback, sys, time, io, random import zipfile @@ -71,7 +71,7 @@ from lxml import etree class ACSMInput(FileTypePlugin): name = PLUGIN_NAME - description = "ACSM Input Plugin - Takes an Adobe ACSM file and converts that into a useable EPUB or PDF file. Python reimplementation of libgourou by Grégory Soutadé" + description = "Takes an Adobe ACSM file and converts that into a useable EPUB or PDF file. Formerly known as DeACSM. Based on the libgourou library by Grégory Soutadé" supported_platforms = ['linux', 'osx', 'windows'] author = "Leseratte10" version = PLUGIN_VERSION_TUPLE @@ -229,32 +229,8 @@ class ACSMInput(FileTypePlugin): print("{0} v{1}: Exception when copying needed library files".format(PLUGIN_NAME, PLUGIN_VERSION)) traceback.print_exc() pass - - if islinux: - # Also extract EXE files needed for WINE ADE key extraction - # EXE files are obfuscated with base64 so that stupid AV programs - # don't flag this whole plugin as malicious. - # See keyextractDecryptor.py and the folder "keyextract" for more information. - try: - print("{0} v{1}: Extracting WINE key tools ...".format(PLUGIN_NAME, PLUGIN_VERSION)) - from keyextractDecryptor import get_win32_data, get_win64_data - - file32 = os.path.join(rand_path, "decrypt_win32.exe") - f = open(file32, "wb") - f.write(get_win32_data()) - f.close() - - file64 = os.path.join(rand_path, "decrypt_win64.exe") - f = open(file64, "wb") - f.write(get_win64_data()) - f.close() - except: - print("{0} v{1}: Error while extracting packed WINE ADE key extraction EXE files ".format(PLUGIN_NAME, PLUGIN_VERSION)) - traceback.print_exc() - - # Write module ID if id_plugin is not None: mod_file = os.path.join(rand_path, "module_id.txt") @@ -296,9 +272,6 @@ class ACSMInput(FileTypePlugin): config_widget.save_settings() def ADE_sanity_check(self): - import calibre_plugins.deacsm.prefs as prefs # type: ignore - deacsmprefs = prefs.ACSMInput_Prefs() - from libadobe import get_activation_xml_path container = None @@ -343,7 +316,6 @@ class ACSMInput(FileTypePlugin): adobe_fulfill_response = etree.fromstring(replyData) - NSMAP = { "adept" : "http://ns.adobe.com/adept" } adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag) @@ -409,7 +381,6 @@ class ACSMInput(FileTypePlugin): elif filetype == ".pdf": adobe_fulfill_response = etree.fromstring(rights_xml_str) - NSMAP = { "adept" : "http://ns.adobe.com/adept" } adNS = lambda tag: '{%s}%s' % ('http://ns.adobe.com/adept', tag) resource = adobe_fulfill_response.find("./%s/%s" % (adNS("licenseToken"), adNS("resource"))).text @@ -457,10 +428,6 @@ class ACSMInput(FileTypePlugin): print("{0} v{1}: Try to fulfill ...".format(PLUGIN_NAME, PLUGIN_VERSION)) - import calibre_plugins.deacsm.prefs as prefs # type: ignore - deacsmprefs = prefs.ACSMInput_Prefs() - - success, replyData = fulfill(path_to_ebook, deacsmprefs["notify_fulfillment"]) if (success is False): diff --git a/calibre-plugin/getEncryptionKeyLinux.py b/calibre-plugin/getEncryptionKeyLinux.py index 400f6a7..eebf5a0 100644 --- a/calibre-plugin/getEncryptionKeyLinux.py +++ b/calibre-plugin/getEncryptionKeyLinux.py @@ -3,7 +3,7 @@ #@@CALIBRE_COMPAT_CODE@@ -import sys, binascii +import sys, binascii, traceback def GetMasterKey(wineprefix): import subprocess, os, re @@ -64,6 +64,35 @@ def GetMasterKey(wineprefix): import os moddir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "keyextract") + + # extract the EXE file from Python code: + # EXE files are obfuscated with base64 so that stupid AV programs + # don't flag this whole plugin as malicious. + # See keyextractDecryptor.py and the folder "keyextract" for more information. + + try: + print("Extracting WINE key tools ...") + from keyextractDecryptor import get_win32_data, get_win64_data + + if winearch == "win32": + file32 = os.path.join(moddir, "decrypt_win32.exe") + f = open(file32, "wb") + f.write(get_win32_data()) + f.close() + + elif winearch == "win64": + file64 = os.path.join(moddir, "decrypt_win64.exe") + f = open(file64, "wb") + f.write(get_win64_data()) + f.close() + + else: + print("Invalid winearch: " + str(winearch)) + + except: + print("Error while extracting packed WINE ADE key extraction EXE files ") + traceback.print_exc() + # calls decrypt_win32.exe or decrypt_win64.exe proc = subprocess.Popen(["wine", "decrypt_" + winearch + ".exe"], shell=False, cwd=moddir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) prog_stdout, prog_stderr = proc.communicate() diff --git a/calibre-plugin/libadobeFulfill.py b/calibre-plugin/libadobeFulfill.py index f30657c..33dd826 100644 --- a/calibre-plugin/libadobeFulfill.py +++ b/calibre-plugin/libadobeFulfill.py @@ -574,6 +574,7 @@ def addLoanRecordToConfigFile(new_loan_record): error_counter = 0 last_token = None + random_identifier = None while True: