]> xmof Git - DeDRM.git/commitdiff
Update to DeDRM to try to fix Linux python problem, and improve Adobe logging
authorapprenticeharper <apprenticeharper@gmail.com>
Mon, 11 Jan 2016 06:44:44 +0000 (06:44 +0000)
committerapprenticeharper <apprenticeharper@gmail.com>
Mon, 11 Jan 2016 06:44:44 +0000 (06:44 +0000)
17 files changed:
DeDRM_Macintosh_Application/DeDRM.app.txt
DeDRM_Macintosh_Application/DeDRM.app/Contents/Info.plist
DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/__init__.py
DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/ineptepub.py
DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/ineptpdf.py
DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/wineutils.py
DeDRM_Windows_Application/DeDRM_App/DeDRM_lib/DeDRM_App.pyw
DeDRM_Windows_Application/DeDRM_App/DeDRM_lib/lib/__init__.py
DeDRM_Windows_Application/DeDRM_App/DeDRM_lib/lib/ineptepub.py
DeDRM_Windows_Application/DeDRM_App/DeDRM_lib/lib/ineptpdf.py
DeDRM_Windows_Application/DeDRM_App/DeDRM_lib/lib/wineutils.py
DeDRM_calibre_plugin/DeDRM_plugin.zip
DeDRM_calibre_plugin/DeDRM_plugin/__init__.py
DeDRM_calibre_plugin/DeDRM_plugin/ineptepub.py
DeDRM_calibre_plugin/DeDRM_plugin/ineptpdf.py
DeDRM_calibre_plugin/DeDRM_plugin/wineutils.py
ReadMe_First.txt

index fdf0a43220ef5c2fd329a192dd56235a8282ff2b..ade0d1c9b720bb910e74d34e182a238fccf31971 100644 (file)
Binary files a/DeDRM_Macintosh_Application/DeDRM.app.txt and b/DeDRM_Macintosh_Application/DeDRM.app.txt differ
index a18d8e4e51eade4b3f7f992fd2ec265d6714a773..c9919f8e1b502a8613f663dbad09369964b760a1 100644 (file)
@@ -24,7 +24,7 @@
        <key>CFBundleExecutable</key>
        <string>droplet</string>
        <key>CFBundleGetInfoString</key>
-       <string>DeDRM AppleScript 6.3.4 Written 2010–2015 by Apprentice Alf et al.</string>
+       <string>DeDRM AppleScript 6.3.5 Written 2010–2016 by Apprentice Alf et al.</string>
        <key>CFBundleIconFile</key>
        <string>DeDRM</string>
        <key>CFBundleIdentifier</key>
@@ -36,7 +36,7 @@
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
-       <string>6.3.4</string>
+       <string>6.3.5</string>
        <key>CFBundleSignature</key>
        <string>dplt</string>
        <key>LSRequiresCarbon</key>
index 53b1200c97cd9117f57dfb2b0ca6516316cd0605..3254222f9509b8b04b7244c6370dc9f25a9a7783 100644 (file)
@@ -46,6 +46,7 @@ __docformat__ = 'restructuredtext en'
 #   6.3.2 - Fixed Kindle for Android help file
 #   6.3.3 - Bug fix for Kindle for PC support
 #   6.3.4 - Fixes for Kindle for Android, Linux, and Kobo 3.17
+#   6.3.5 - Fixes for Linux, and Kobo 3.19 and more logging
 
 
 """
@@ -53,7 +54,7 @@ Decrypt DRMed ebooks.
 """
 
 PLUGIN_NAME = u"DeDRM"
-PLUGIN_VERSION_TUPLE = (6, 3, 4)
+PLUGIN_VERSION_TUPLE = (6, 3, 5)
 PLUGIN_VERSION = u".".join([unicode(str(x)) for x in PLUGIN_VERSION_TUPLE])
 # Include an html helpfile in the plugin's zipfile with the following name.
 RESOURCE_NAME = PLUGIN_NAME + '_Help.htm'
@@ -96,7 +97,7 @@ class DeDRM(FileTypePlugin):
     supported_platforms     = ['linux', 'osx', 'windows']
     author                  = u"Apprentice Alf, Aprentice Harper, The Dark Reverser and i♥cabbages"
     version                 = PLUGIN_VERSION_TUPLE
-    minimum_calibre_version = (0, 7, 55)  # Compiled python libraries cannot be imported in earlier versions.
+    minimum_calibre_version = (1, 0, 0)  # Compiled python libraries cannot be imported in earlier versions.
     file_types              = set(['epub','pdf','pdb','prc','mobi','pobi','azw','azw1','azw3','azw4','tpz'])
     on_import               = True
     priority                = 600
@@ -296,11 +297,15 @@ class DeDRM(FileTypePlugin):
                     traceback.print_exc()
                     result = 1
 
-                of.close()
+                try:
+                    of.close()
+                except:
+                    print u"{0} v{1}: Exception closing temporary file after {2:.1f} seconds. Ignored.".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime)
 
                 if  result == 0:
                     # Decryption was successful.
                     # Return the modified PersistentTemporary file to calibre.
+                    print u"{0} v{1}: Decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,keyname,time.time()-self.starttime)
                     return of.name
 
                 print u"{0} v{1}: Failed to decrypt with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,keyname,time.time()-self.starttime)
@@ -360,6 +365,7 @@ class DeDRM(FileTypePlugin):
                             except:
                                 print u"{0} v{1}: Exception when saving a new default key after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime)
                                 traceback.print_exc()
+                            print u"{0} v{1}: Decrypted with new default key after {3:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime)
                             # Return the modified PersistentTemporary file to calibre.
                             return of.name
 
index e116a6e986578e3fdad036d89c982c2cde394950..5987b8c8ef061985075d6b52a8ba430cae5fea00 100644 (file)
@@ -3,18 +3,19 @@
 
 from __future__ import with_statement
 
-# ineptepub.pyw, version 6.1
+# ineptepub.pyw, version 6.3
 # Copyright © 2009-2010 by i♥cabbages
 
 # Released under the terms of the GNU General Public Licence, version 3
 # <http://www.gnu.org/licenses/>
 
 # Modified 2010–2013 by some_updates, DiapDealer and Apprentice Alf
+# Modified 2015–2016 by Apprentice Harper
 
-# Windows users: Before running this program, you must first install Python 2.6
+# Windows users: Before running this program, you must first install Python 2.7
 #   from <http://www.python.org/download/> and PyCrypto from
 #   <http://www.voidspace.org.uk/python/modules.shtml#pycrypto> (make sure to
-#   install the version for Python 2.6).  Save this script file as
+#   install the version for Python 2.7).  Save this script file as
 #   ineptepub.pyw and double-click on it to run it.
 #
 # Mac OS X users: Save this script file as ineptepub.pyw.  You can run this
@@ -38,13 +39,14 @@ from __future__ import with_statement
 #   6.0 - moved unicode_argv call inside main for Windows DeDRM compatibility
 #   6.1 - Work if TkInter is missing
 #   6.2 - Handle UTF-8 file names inside an ePub, fix by Jose Luis
+#   6.3 - Add additional check on DER file sanity
 
 """
 Decrypt Adobe Digital Editions encrypted ePub books.
 """
 
 __license__ = 'GPL v3'
-__version__ = "6.2"
+__version__ = "6.3"
 
 import sys
 import os
@@ -169,9 +171,14 @@ def _load_crypto_libcrypto():
         def __init__(self, der):
             buf = create_string_buffer(der)
             pp = c_char_pp(cast(buf, c_char_p))
-            rsa = self._rsa = d2i_RSAPrivateKey(None, pp, len(der))
+            rsa = self._rsa = d2i_RSAPrivateKey(None, pp, len(der)) 
             if rsa is None:
                 raise ADEPTError('Error parsing ADEPT user key DER')
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
 
         def decrypt(self, from_):
             rsa = self._rsa
@@ -313,6 +320,12 @@ def _load_crypto_pycrypto():
             key = [key.getChild(x).value for x in xrange(1, 4)]
             key = [self.bytesToNumber(v) for v in key]
             self._rsa = _RSA.construct(key)
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
+
 
         def bytesToNumber(self, bytes):
             total = 0L
index 1986e20249e8bb98abed5ede47290c5f1fc6906b..3967647aa9e5dcb1a307822ffe8f4e9692667845 100644 (file)
@@ -3,18 +3,19 @@
 
 from __future__ import with_statement
 
-# ineptpdf.pyw, version 7.11
+# ineptpdf.pyw, version 8.0.2
 # Copyright © 2009-2010 by i♥cabbages
 
 # Released under the terms of the GNU General Public Licence, version 3
 # <http://www.gnu.org/licenses/>
 
 # Modified 2010–2012 by some_updates, DiapDealer and Apprentice Alf
+# Modified 2015-2016 by Apprentice Harper
 
-# Windows users: Before running this program, you must first install Python 2.6
+# Windows users: Before running this program, you must first install Python 2.7
 #   from <http://www.python.org/download/> and PyCrypto from
 #   <http://www.voidspace.org.uk/python/modules.shtml#pycrypto> (make sure to
-#   install the version for Python 2.6).  Save this script file as
+#   install the version for Python 2.7).  Save this script file as
 #   ineptpdf.pyw and double-click on it to run it.
 #
 # Mac OS X users: Save this script file as ineptpdf.pyw.  You can run this
@@ -53,13 +54,15 @@ from __future__ import with_statement
 #   7.14 - moved unicode_argv call inside main for Windows DeDRM compatibility
 #   8.0  - Work if TkInter is missing
 #   8.0.1 - Broken Metadata fix.
+#   8.0.2 - Add additional check on DER file sanity
+
 
 """
 Decrypts Adobe ADEPT-encrypted PDF files.
 """
 
 __license__ = 'GPL v3'
-__version__ = "8.0.1"
+__version__ = "8.0.2"
 
 import sys
 import os
@@ -198,6 +201,11 @@ def _load_crypto_libcrypto():
             rsa = self._rsa = d2i_RSAPrivateKey(None, pp, len(der))
             if rsa is None:
                 raise ADEPTError('Error parsing ADEPT user key DER')
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
 
         def decrypt(self, from_):
             rsa = self._rsa
@@ -383,6 +391,11 @@ def _load_crypto_pycrypto():
             key = [key.getChild(x).value for x in xrange(1, 4)]
             key = [self.bytesToNumber(v) for v in key]
             self._rsa = _RSA.construct(key)
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
 
         def bytesToNumber(self, bytes):
             total = 0L
index b54db8043a0b998e7f666309812a2edeb70c7a52..f2f8edc12a0dac45981fd535fccb23aadf4ef6d3 100644 (file)
@@ -26,6 +26,7 @@ def WineGetKeys(scriptpath, extension, wineprefix=""):
     if not os.path.exists(outdirpath):
         os.makedirs(outdirpath)
 
+    wineprefix = os.path.abspath(os.path.expanduser(os.path.expandvars(wineprefix)))
     if wineprefix != "" and os.path.exists(wineprefix):
          cmdline = u"WINEPREFIX=\"{2}\" wine python.exe \"{0}\" \"{1}\"".format(scriptpath,outdirpath,wineprefix)
     else:
@@ -38,8 +39,20 @@ def WineGetKeys(scriptpath, extension, wineprefix=""):
         result = p2.wait("wait")
     except Exception, e:
         print u"{0} v{1}: Wine subprocess call error: {2}".format(PLUGIN_NAME, PLUGIN_VERSION, e.args[0])
-        return []
+        if wineprefix != "" and os.path.exists(wineprefix):
+            cmdline = u"WINEPREFIX=\"{2}\" wine C:\\Python27\\python.exe \"{0}\" \"{1}\"".format(scriptpath,outdirpath,wineprefix)
+       else:
+           cmdline = u"wine C:\\Python27\\python.exe \"{0}\" \"{1}\"".format(scriptpath,outdirpath)
+       print u"{0} v{1}: Command line: “{2}”".format(PLUGIN_NAME, PLUGIN_VERSION, cmdline)
 
+       try:
+           cmdline = cmdline.encode(sys.getfilesystemencoding())
+           p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=sys.stdout, stderr=STDOUT, close_fds=False)
+           result = p2.wait("wait")
+       except Exception, e:
+           print u"{0} v{1}: Wine subprocess call error: {2}".format(PLUGIN_NAME, PLUGIN_VERSION, e.args[0])
+
+    # try finding winekeys anyway, even if above code errored
     winekeys = []
     # get any files with extension in the output dir
     files = [f for f in os.listdir(outdirpath) if f.endswith(extension)]
index 87b863466a28423edd739389aef5153681fd8d35..0aa55d33e902bb4d17082683e995636c851c124d 100644 (file)
@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 
 # DeDRM.pyw
-# Copyright 2010-2015 some_updates, Apprentice Alf and Apprentice Harper
+# Copyright 2010-2016 some_updates, Apprentice Alf and Apprentice Harper
 
 # Revision history:
 #   6.0.0 - Release along with unified plugin
@@ -19,8 +19,9 @@
 #   6.3.2 - Version bump to match plugin
 #   6.3.3 - Version bump to match plugin
 #   6.3.4 - Version bump to match plugin
+#   6.3.5 - Version bump to match plugin
 
-__version__ = '6.3.4'
+__version__ = '6.3.5'
 
 import sys
 import os, os.path
index 53b1200c97cd9117f57dfb2b0ca6516316cd0605..3254222f9509b8b04b7244c6370dc9f25a9a7783 100644 (file)
@@ -46,6 +46,7 @@ __docformat__ = 'restructuredtext en'
 #   6.3.2 - Fixed Kindle for Android help file
 #   6.3.3 - Bug fix for Kindle for PC support
 #   6.3.4 - Fixes for Kindle for Android, Linux, and Kobo 3.17
+#   6.3.5 - Fixes for Linux, and Kobo 3.19 and more logging
 
 
 """
@@ -53,7 +54,7 @@ Decrypt DRMed ebooks.
 """
 
 PLUGIN_NAME = u"DeDRM"
-PLUGIN_VERSION_TUPLE = (6, 3, 4)
+PLUGIN_VERSION_TUPLE = (6, 3, 5)
 PLUGIN_VERSION = u".".join([unicode(str(x)) for x in PLUGIN_VERSION_TUPLE])
 # Include an html helpfile in the plugin's zipfile with the following name.
 RESOURCE_NAME = PLUGIN_NAME + '_Help.htm'
@@ -96,7 +97,7 @@ class DeDRM(FileTypePlugin):
     supported_platforms     = ['linux', 'osx', 'windows']
     author                  = u"Apprentice Alf, Aprentice Harper, The Dark Reverser and i♥cabbages"
     version                 = PLUGIN_VERSION_TUPLE
-    minimum_calibre_version = (0, 7, 55)  # Compiled python libraries cannot be imported in earlier versions.
+    minimum_calibre_version = (1, 0, 0)  # Compiled python libraries cannot be imported in earlier versions.
     file_types              = set(['epub','pdf','pdb','prc','mobi','pobi','azw','azw1','azw3','azw4','tpz'])
     on_import               = True
     priority                = 600
@@ -296,11 +297,15 @@ class DeDRM(FileTypePlugin):
                     traceback.print_exc()
                     result = 1
 
-                of.close()
+                try:
+                    of.close()
+                except:
+                    print u"{0} v{1}: Exception closing temporary file after {2:.1f} seconds. Ignored.".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime)
 
                 if  result == 0:
                     # Decryption was successful.
                     # Return the modified PersistentTemporary file to calibre.
+                    print u"{0} v{1}: Decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,keyname,time.time()-self.starttime)
                     return of.name
 
                 print u"{0} v{1}: Failed to decrypt with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,keyname,time.time()-self.starttime)
@@ -360,6 +365,7 @@ class DeDRM(FileTypePlugin):
                             except:
                                 print u"{0} v{1}: Exception when saving a new default key after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime)
                                 traceback.print_exc()
+                            print u"{0} v{1}: Decrypted with new default key after {3:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime)
                             # Return the modified PersistentTemporary file to calibre.
                             return of.name
 
index e116a6e986578e3fdad036d89c982c2cde394950..5987b8c8ef061985075d6b52a8ba430cae5fea00 100644 (file)
@@ -3,18 +3,19 @@
 
 from __future__ import with_statement
 
-# ineptepub.pyw, version 6.1
+# ineptepub.pyw, version 6.3
 # Copyright © 2009-2010 by i♥cabbages
 
 # Released under the terms of the GNU General Public Licence, version 3
 # <http://www.gnu.org/licenses/>
 
 # Modified 2010–2013 by some_updates, DiapDealer and Apprentice Alf
+# Modified 2015–2016 by Apprentice Harper
 
-# Windows users: Before running this program, you must first install Python 2.6
+# Windows users: Before running this program, you must first install Python 2.7
 #   from <http://www.python.org/download/> and PyCrypto from
 #   <http://www.voidspace.org.uk/python/modules.shtml#pycrypto> (make sure to
-#   install the version for Python 2.6).  Save this script file as
+#   install the version for Python 2.7).  Save this script file as
 #   ineptepub.pyw and double-click on it to run it.
 #
 # Mac OS X users: Save this script file as ineptepub.pyw.  You can run this
@@ -38,13 +39,14 @@ from __future__ import with_statement
 #   6.0 - moved unicode_argv call inside main for Windows DeDRM compatibility
 #   6.1 - Work if TkInter is missing
 #   6.2 - Handle UTF-8 file names inside an ePub, fix by Jose Luis
+#   6.3 - Add additional check on DER file sanity
 
 """
 Decrypt Adobe Digital Editions encrypted ePub books.
 """
 
 __license__ = 'GPL v3'
-__version__ = "6.2"
+__version__ = "6.3"
 
 import sys
 import os
@@ -169,9 +171,14 @@ def _load_crypto_libcrypto():
         def __init__(self, der):
             buf = create_string_buffer(der)
             pp = c_char_pp(cast(buf, c_char_p))
-            rsa = self._rsa = d2i_RSAPrivateKey(None, pp, len(der))
+            rsa = self._rsa = d2i_RSAPrivateKey(None, pp, len(der)) 
             if rsa is None:
                 raise ADEPTError('Error parsing ADEPT user key DER')
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
 
         def decrypt(self, from_):
             rsa = self._rsa
@@ -313,6 +320,12 @@ def _load_crypto_pycrypto():
             key = [key.getChild(x).value for x in xrange(1, 4)]
             key = [self.bytesToNumber(v) for v in key]
             self._rsa = _RSA.construct(key)
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
+
 
         def bytesToNumber(self, bytes):
             total = 0L
index 1986e20249e8bb98abed5ede47290c5f1fc6906b..3967647aa9e5dcb1a307822ffe8f4e9692667845 100644 (file)
@@ -3,18 +3,19 @@
 
 from __future__ import with_statement
 
-# ineptpdf.pyw, version 7.11
+# ineptpdf.pyw, version 8.0.2
 # Copyright © 2009-2010 by i♥cabbages
 
 # Released under the terms of the GNU General Public Licence, version 3
 # <http://www.gnu.org/licenses/>
 
 # Modified 2010–2012 by some_updates, DiapDealer and Apprentice Alf
+# Modified 2015-2016 by Apprentice Harper
 
-# Windows users: Before running this program, you must first install Python 2.6
+# Windows users: Before running this program, you must first install Python 2.7
 #   from <http://www.python.org/download/> and PyCrypto from
 #   <http://www.voidspace.org.uk/python/modules.shtml#pycrypto> (make sure to
-#   install the version for Python 2.6).  Save this script file as
+#   install the version for Python 2.7).  Save this script file as
 #   ineptpdf.pyw and double-click on it to run it.
 #
 # Mac OS X users: Save this script file as ineptpdf.pyw.  You can run this
@@ -53,13 +54,15 @@ from __future__ import with_statement
 #   7.14 - moved unicode_argv call inside main for Windows DeDRM compatibility
 #   8.0  - Work if TkInter is missing
 #   8.0.1 - Broken Metadata fix.
+#   8.0.2 - Add additional check on DER file sanity
+
 
 """
 Decrypts Adobe ADEPT-encrypted PDF files.
 """
 
 __license__ = 'GPL v3'
-__version__ = "8.0.1"
+__version__ = "8.0.2"
 
 import sys
 import os
@@ -198,6 +201,11 @@ def _load_crypto_libcrypto():
             rsa = self._rsa = d2i_RSAPrivateKey(None, pp, len(der))
             if rsa is None:
                 raise ADEPTError('Error parsing ADEPT user key DER')
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
 
         def decrypt(self, from_):
             rsa = self._rsa
@@ -383,6 +391,11 @@ def _load_crypto_pycrypto():
             key = [key.getChild(x).value for x in xrange(1, 4)]
             key = [self.bytesToNumber(v) for v in key]
             self._rsa = _RSA.construct(key)
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
 
         def bytesToNumber(self, bytes):
             total = 0L
index b54db8043a0b998e7f666309812a2edeb70c7a52..f2f8edc12a0dac45981fd535fccb23aadf4ef6d3 100644 (file)
@@ -26,6 +26,7 @@ def WineGetKeys(scriptpath, extension, wineprefix=""):
     if not os.path.exists(outdirpath):
         os.makedirs(outdirpath)
 
+    wineprefix = os.path.abspath(os.path.expanduser(os.path.expandvars(wineprefix)))
     if wineprefix != "" and os.path.exists(wineprefix):
          cmdline = u"WINEPREFIX=\"{2}\" wine python.exe \"{0}\" \"{1}\"".format(scriptpath,outdirpath,wineprefix)
     else:
@@ -38,8 +39,20 @@ def WineGetKeys(scriptpath, extension, wineprefix=""):
         result = p2.wait("wait")
     except Exception, e:
         print u"{0} v{1}: Wine subprocess call error: {2}".format(PLUGIN_NAME, PLUGIN_VERSION, e.args[0])
-        return []
+        if wineprefix != "" and os.path.exists(wineprefix):
+            cmdline = u"WINEPREFIX=\"{2}\" wine C:\\Python27\\python.exe \"{0}\" \"{1}\"".format(scriptpath,outdirpath,wineprefix)
+       else:
+           cmdline = u"wine C:\\Python27\\python.exe \"{0}\" \"{1}\"".format(scriptpath,outdirpath)
+       print u"{0} v{1}: Command line: “{2}”".format(PLUGIN_NAME, PLUGIN_VERSION, cmdline)
 
+       try:
+           cmdline = cmdline.encode(sys.getfilesystemencoding())
+           p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=sys.stdout, stderr=STDOUT, close_fds=False)
+           result = p2.wait("wait")
+       except Exception, e:
+           print u"{0} v{1}: Wine subprocess call error: {2}".format(PLUGIN_NAME, PLUGIN_VERSION, e.args[0])
+
+    # try finding winekeys anyway, even if above code errored
     winekeys = []
     # get any files with extension in the output dir
     files = [f for f in os.listdir(outdirpath) if f.endswith(extension)]
index a64da23e1b9ded09f241d3e95a1b81e7993917df..05cfb8fececaf3a57d4484e4d5371b4309303eb3 100644 (file)
Binary files a/DeDRM_calibre_plugin/DeDRM_plugin.zip and b/DeDRM_calibre_plugin/DeDRM_plugin.zip differ
index 53b1200c97cd9117f57dfb2b0ca6516316cd0605..3254222f9509b8b04b7244c6370dc9f25a9a7783 100644 (file)
@@ -46,6 +46,7 @@ __docformat__ = 'restructuredtext en'
 #   6.3.2 - Fixed Kindle for Android help file
 #   6.3.3 - Bug fix for Kindle for PC support
 #   6.3.4 - Fixes for Kindle for Android, Linux, and Kobo 3.17
+#   6.3.5 - Fixes for Linux, and Kobo 3.19 and more logging
 
 
 """
@@ -53,7 +54,7 @@ Decrypt DRMed ebooks.
 """
 
 PLUGIN_NAME = u"DeDRM"
-PLUGIN_VERSION_TUPLE = (6, 3, 4)
+PLUGIN_VERSION_TUPLE = (6, 3, 5)
 PLUGIN_VERSION = u".".join([unicode(str(x)) for x in PLUGIN_VERSION_TUPLE])
 # Include an html helpfile in the plugin's zipfile with the following name.
 RESOURCE_NAME = PLUGIN_NAME + '_Help.htm'
@@ -96,7 +97,7 @@ class DeDRM(FileTypePlugin):
     supported_platforms     = ['linux', 'osx', 'windows']
     author                  = u"Apprentice Alf, Aprentice Harper, The Dark Reverser and i♥cabbages"
     version                 = PLUGIN_VERSION_TUPLE
-    minimum_calibre_version = (0, 7, 55)  # Compiled python libraries cannot be imported in earlier versions.
+    minimum_calibre_version = (1, 0, 0)  # Compiled python libraries cannot be imported in earlier versions.
     file_types              = set(['epub','pdf','pdb','prc','mobi','pobi','azw','azw1','azw3','azw4','tpz'])
     on_import               = True
     priority                = 600
@@ -296,11 +297,15 @@ class DeDRM(FileTypePlugin):
                     traceback.print_exc()
                     result = 1
 
-                of.close()
+                try:
+                    of.close()
+                except:
+                    print u"{0} v{1}: Exception closing temporary file after {2:.1f} seconds. Ignored.".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime)
 
                 if  result == 0:
                     # Decryption was successful.
                     # Return the modified PersistentTemporary file to calibre.
+                    print u"{0} v{1}: Decrypted with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,keyname,time.time()-self.starttime)
                     return of.name
 
                 print u"{0} v{1}: Failed to decrypt with key {2:s} after {3:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,keyname,time.time()-self.starttime)
@@ -360,6 +365,7 @@ class DeDRM(FileTypePlugin):
                             except:
                                 print u"{0} v{1}: Exception when saving a new default key after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime)
                                 traceback.print_exc()
+                            print u"{0} v{1}: Decrypted with new default key after {3:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime)
                             # Return the modified PersistentTemporary file to calibre.
                             return of.name
 
index e116a6e986578e3fdad036d89c982c2cde394950..5987b8c8ef061985075d6b52a8ba430cae5fea00 100644 (file)
@@ -3,18 +3,19 @@
 
 from __future__ import with_statement
 
-# ineptepub.pyw, version 6.1
+# ineptepub.pyw, version 6.3
 # Copyright © 2009-2010 by i♥cabbages
 
 # Released under the terms of the GNU General Public Licence, version 3
 # <http://www.gnu.org/licenses/>
 
 # Modified 2010–2013 by some_updates, DiapDealer and Apprentice Alf
+# Modified 2015–2016 by Apprentice Harper
 
-# Windows users: Before running this program, you must first install Python 2.6
+# Windows users: Before running this program, you must first install Python 2.7
 #   from <http://www.python.org/download/> and PyCrypto from
 #   <http://www.voidspace.org.uk/python/modules.shtml#pycrypto> (make sure to
-#   install the version for Python 2.6).  Save this script file as
+#   install the version for Python 2.7).  Save this script file as
 #   ineptepub.pyw and double-click on it to run it.
 #
 # Mac OS X users: Save this script file as ineptepub.pyw.  You can run this
@@ -38,13 +39,14 @@ from __future__ import with_statement
 #   6.0 - moved unicode_argv call inside main for Windows DeDRM compatibility
 #   6.1 - Work if TkInter is missing
 #   6.2 - Handle UTF-8 file names inside an ePub, fix by Jose Luis
+#   6.3 - Add additional check on DER file sanity
 
 """
 Decrypt Adobe Digital Editions encrypted ePub books.
 """
 
 __license__ = 'GPL v3'
-__version__ = "6.2"
+__version__ = "6.3"
 
 import sys
 import os
@@ -169,9 +171,14 @@ def _load_crypto_libcrypto():
         def __init__(self, der):
             buf = create_string_buffer(der)
             pp = c_char_pp(cast(buf, c_char_p))
-            rsa = self._rsa = d2i_RSAPrivateKey(None, pp, len(der))
+            rsa = self._rsa = d2i_RSAPrivateKey(None, pp, len(der)) 
             if rsa is None:
                 raise ADEPTError('Error parsing ADEPT user key DER')
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
 
         def decrypt(self, from_):
             rsa = self._rsa
@@ -313,6 +320,12 @@ def _load_crypto_pycrypto():
             key = [key.getChild(x).value for x in xrange(1, 4)]
             key = [self.bytesToNumber(v) for v in key]
             self._rsa = _RSA.construct(key)
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
+
 
         def bytesToNumber(self, bytes):
             total = 0L
index 1986e20249e8bb98abed5ede47290c5f1fc6906b..3967647aa9e5dcb1a307822ffe8f4e9692667845 100644 (file)
@@ -3,18 +3,19 @@
 
 from __future__ import with_statement
 
-# ineptpdf.pyw, version 7.11
+# ineptpdf.pyw, version 8.0.2
 # Copyright © 2009-2010 by i♥cabbages
 
 # Released under the terms of the GNU General Public Licence, version 3
 # <http://www.gnu.org/licenses/>
 
 # Modified 2010–2012 by some_updates, DiapDealer and Apprentice Alf
+# Modified 2015-2016 by Apprentice Harper
 
-# Windows users: Before running this program, you must first install Python 2.6
+# Windows users: Before running this program, you must first install Python 2.7
 #   from <http://www.python.org/download/> and PyCrypto from
 #   <http://www.voidspace.org.uk/python/modules.shtml#pycrypto> (make sure to
-#   install the version for Python 2.6).  Save this script file as
+#   install the version for Python 2.7).  Save this script file as
 #   ineptpdf.pyw and double-click on it to run it.
 #
 # Mac OS X users: Save this script file as ineptpdf.pyw.  You can run this
@@ -53,13 +54,15 @@ from __future__ import with_statement
 #   7.14 - moved unicode_argv call inside main for Windows DeDRM compatibility
 #   8.0  - Work if TkInter is missing
 #   8.0.1 - Broken Metadata fix.
+#   8.0.2 - Add additional check on DER file sanity
+
 
 """
 Decrypts Adobe ADEPT-encrypted PDF files.
 """
 
 __license__ = 'GPL v3'
-__version__ = "8.0.1"
+__version__ = "8.0.2"
 
 import sys
 import os
@@ -198,6 +201,11 @@ def _load_crypto_libcrypto():
             rsa = self._rsa = d2i_RSAPrivateKey(None, pp, len(der))
             if rsa is None:
                 raise ADEPTError('Error parsing ADEPT user key DER')
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
 
         def decrypt(self, from_):
             rsa = self._rsa
@@ -383,6 +391,11 @@ def _load_crypto_pycrypto():
             key = [key.getChild(x).value for x in xrange(1, 4)]
             key = [self.bytesToNumber(v) for v in key]
             self._rsa = _RSA.construct(key)
+            # check if pointer is not NULL
+            try:
+                c = self._rsa.contents
+            except ValueError:   
+                raise ADEPTError('Error parsing ADEPT user key DER')
 
         def bytesToNumber(self, bytes):
             total = 0L
index 6d79c9bbbf68a922d783bc8a7bf87952724fe1c4..f2f8edc12a0dac45981fd535fccb23aadf4ef6d3 100644 (file)
@@ -39,8 +39,20 @@ def WineGetKeys(scriptpath, extension, wineprefix=""):
         result = p2.wait("wait")
     except Exception, e:
         print u"{0} v{1}: Wine subprocess call error: {2}".format(PLUGIN_NAME, PLUGIN_VERSION, e.args[0])
-        return []
+        if wineprefix != "" and os.path.exists(wineprefix):
+            cmdline = u"WINEPREFIX=\"{2}\" wine C:\\Python27\\python.exe \"{0}\" \"{1}\"".format(scriptpath,outdirpath,wineprefix)
+       else:
+           cmdline = u"wine C:\\Python27\\python.exe \"{0}\" \"{1}\"".format(scriptpath,outdirpath)
+       print u"{0} v{1}: Command line: “{2}”".format(PLUGIN_NAME, PLUGIN_VERSION, cmdline)
 
+       try:
+           cmdline = cmdline.encode(sys.getfilesystemencoding())
+           p2 = Process(cmdline, shell=True, bufsize=1, stdin=None, stdout=sys.stdout, stderr=STDOUT, close_fds=False)
+           result = p2.wait("wait")
+       except Exception, e:
+           print u"{0} v{1}: Wine subprocess call error: {2}".format(PLUGIN_NAME, PLUGIN_VERSION, e.args[0])
+
+    # try finding winekeys anyway, even if above code errored
     winekeys = []
     # get any files with extension in the output dir
     files = [f for f in os.listdir(outdirpath) if f.endswith(extension)]
index beb72870e382cc8bf23c11b75ecda970d6abe46a..10d04782ddb58c793683cf018e02ab5e6ca48793 100644 (file)
@@ -12,7 +12,7 @@ The is archive includes tools to remove DRM from:
  - Adobe Digital Editions PDFs
  - Mobipocket ebooks
  - eReader PDB books
- - Scuolabooks (Windows only solution by Hex)
+ - Scuolabooks (Link to solution by Hex)
 
 These tools do NOT work with Apple's iBooks FairPlay DRM (see end of this file.)
 
@@ -78,7 +78,7 @@ Rocket_ebooks
 Information about the now-obsolete Rocket ebook format and DRM, along with source for a tool to remove the DRM.
 
 Scuolabook_DRM
-A windows-only application (including source code) for removing DRM from ScuolaBooks PDFs, created by "Hex" and included with permission.
+A link to the tool for removing DRM from ScuolaBooks PDFs, created by "Hex".
 
 
 Windows and Python