]> xmof Git - DeDRM.git/commitdiff
Explicitly warn about KFX files. Bump version number to 6.5.3
authorApprentice Harper <apprenticeharper@gmail.com>
Thu, 12 Jan 2017 07:24:42 +0000 (07:24 +0000)
committerApprentice Harper <apprenticeharper@gmail.com>
Thu, 12 Jan 2017 07:24:42 +0000 (07:24 +0000)
DeDRM_Macintosh_Application/DeDRM.app/Contents/Info.plist
DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/__init__.py
DeDRM_Macintosh_Application/DeDRM.app/Contents/Resources/k4mobidedrm.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/k4mobidedrm.py
DeDRM_Windows_Application/DeDRM_App_ReadMe.txt
DeDRM_calibre_plugin/DeDRM_plugin.zip
DeDRM_calibre_plugin/DeDRM_plugin/__init__.py
DeDRM_calibre_plugin/DeDRM_plugin/k4mobidedrm.py
Other_Tools/Kobo/obok.py

index a079e5aa43cff3764942727bceeeab18378fecb5..898ac045078a3cdb3c7df58f481bb0d23e5dfc94 100644 (file)
@@ -24,7 +24,7 @@
        <key>CFBundleExecutable</key>
        <string>droplet</string>
        <key>CFBundleGetInfoString</key>
-       <string>DeDRM AppleScript 6.5.2 Written 2010–2016 by Apprentice Alf et al.</string>
+       <string>DeDRM AppleScript 6.5.3 Written 2010–2017 by Apprentice Alf et al.</string>
        <key>CFBundleIconFile</key>
        <string>DeDRM</string>
        <key>CFBundleIdentifier</key>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
-       <string>6.5.2</string>
+       <string>6.5.3</string>
        <key>CFBundleSignature</key>
        <string>dplt</string>
        <key>LSRequiresCarbon</key>
        <true/>
        <key>NSHumanReadableCopyright</key>
-       <string>Copyright © 2010–2016 Apprentice Alf and Apprentice Harper</string>
+       <string>Copyright © 2010–2017 Apprentice Alf</string>
        <key>WindowState</key>
        <dict>
                <key>bundleDividerCollapsed</key>
index b3594510f79d77b4bb3eb71d6e16d866a0764cc1..6fffb409c6ba3c90b8742d8ecb2d6ae8bdc04ba6 100644 (file)
@@ -56,6 +56,7 @@ __docformat__ = 'restructuredtext en'
 #           Fix an error in wineutils.py
 #   6.5.1 - Updated version number, added PDF check for DRM-free documents
 #   6.5.2 - Another Topaz fix
+#   6.5.3 - Warn about KFX files explicitly
 
 
 """
@@ -63,7 +64,7 @@ Decrypt DRMed ebooks.
 """
 
 PLUGIN_NAME = u"DeDRM"
-PLUGIN_VERSION_TUPLE = (6, 5, 2)
+PLUGIN_VERSION_TUPLE = (6, 5, 3)
 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'
index 67eb4cbf3d6b8d180272f7d5090907a2954c6e0c..c3e475cdfeb854d6e3a6c3202514805dd0ec468f 100644 (file)
@@ -56,8 +56,9 @@ from __future__ import with_statement
 #  5.1 - moved unicode_argv call inside main for Windows DeDRM compatibility
 #  5.2 - Fixed error in command line processing of unicode arguments
 #  5.3 - Changed Android support to allow passing of backup .ab files
+#  5.4 - Recognise KFX files masquerading as azw, even if we can't decrypt them yet.
 
-__version__ = '5.3'
+__version__ = '5.4'
 
 
 import sys, os, re
@@ -194,7 +195,11 @@ def GetDecryptedBook(infile, kDatabases, androidFiles, serials, pids, starttime
         raise DrmException(u"Input file does not exist.")
 
     mobi = True
-    magic3 = open(infile,'rb').read(3)
+    magic8 = open(infile,'rb').read(8)
+    if magic8 == '\xeaDRMION\xee':
+        raise DrmException(u"KFX format detected. This format cannot be decrypted yet.")
+        
+    magic3 = magic8[:3]
     if magic3 == 'TPZ':
         mobi = False
 
@@ -215,8 +220,9 @@ def GetDecryptedBook(infile, kDatabases, androidFiles, serials, pids, starttime
     md1, md2 = mb.getPIDMetaInfo()
     totalpids.extend(kgenpids.getPidList(md1, md2, serials, kDatabases))
     # remove any duplicates
-    totalpid = list(set(totalpids))
+    totalpids = list(set(totalpids))
     print u"Found {1:d} keys to try after {0:.1f} seconds".format(time.time()-starttime, len(totalpids))
+    #print totalpids
 
     try:
         mb.processBook(totalpids)
index c3a40d4766512eaa6797233a89c9b3694e2049be..f4864f8e51bda88c275766cf083f5df7972a4997 100644 (file)
@@ -28,8 +28,9 @@
 #   6.5.0 - Fix for some new tags in Topaz ebooks
 #   6.5.1 - Version bump to match plugin & Mac app
 #   6.5.2 - Fix for a new tag in Topaz ebooks
+#   6.5.3 - Explicitly warn about KFX files
 
-__version__ = '6.5.2'
+__version__ = '6.5.3'
 
 import sys
 import os, os.path
index b3594510f79d77b4bb3eb71d6e16d866a0764cc1..6fffb409c6ba3c90b8742d8ecb2d6ae8bdc04ba6 100644 (file)
@@ -56,6 +56,7 @@ __docformat__ = 'restructuredtext en'
 #           Fix an error in wineutils.py
 #   6.5.1 - Updated version number, added PDF check for DRM-free documents
 #   6.5.2 - Another Topaz fix
+#   6.5.3 - Warn about KFX files explicitly
 
 
 """
@@ -63,7 +64,7 @@ Decrypt DRMed ebooks.
 """
 
 PLUGIN_NAME = u"DeDRM"
-PLUGIN_VERSION_TUPLE = (6, 5, 2)
+PLUGIN_VERSION_TUPLE = (6, 5, 3)
 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'
index 67eb4cbf3d6b8d180272f7d5090907a2954c6e0c..c3e475cdfeb854d6e3a6c3202514805dd0ec468f 100644 (file)
@@ -56,8 +56,9 @@ from __future__ import with_statement
 #  5.1 - moved unicode_argv call inside main for Windows DeDRM compatibility
 #  5.2 - Fixed error in command line processing of unicode arguments
 #  5.3 - Changed Android support to allow passing of backup .ab files
+#  5.4 - Recognise KFX files masquerading as azw, even if we can't decrypt them yet.
 
-__version__ = '5.3'
+__version__ = '5.4'
 
 
 import sys, os, re
@@ -194,7 +195,11 @@ def GetDecryptedBook(infile, kDatabases, androidFiles, serials, pids, starttime
         raise DrmException(u"Input file does not exist.")
 
     mobi = True
-    magic3 = open(infile,'rb').read(3)
+    magic8 = open(infile,'rb').read(8)
+    if magic8 == '\xeaDRMION\xee':
+        raise DrmException(u"KFX format detected. This format cannot be decrypted yet.")
+        
+    magic3 = magic8[:3]
     if magic3 == 'TPZ':
         mobi = False
 
@@ -215,8 +220,9 @@ def GetDecryptedBook(infile, kDatabases, androidFiles, serials, pids, starttime
     md1, md2 = mb.getPIDMetaInfo()
     totalpids.extend(kgenpids.getPidList(md1, md2, serials, kDatabases))
     # remove any duplicates
-    totalpid = list(set(totalpids))
+    totalpids = list(set(totalpids))
     print u"Found {1:d} keys to try after {0:.1f} seconds".format(time.time()-starttime, len(totalpids))
+    #print totalpids
 
     try:
         mb.processBook(totalpids)
index 056dc3fc59b5d0c8d48297cbacfc7b72ef629247..772b946b7dba92780180d091c3fe316c776248a5 100644 (file)
@@ -20,7 +20,7 @@ Installation
 ------------
 0. If you don't already have a correct version of Python and PyCrypto installed, follow the "Installing Python on Windows" and "Installing PyCrypto on Windows" sections below before continuing.
 
-1. Drag the DeDRM_App folder from tools_v6.3.4a/DeDRM_Application_Windows to your "My Documents" folder.
+1. Drag the DeDRM_App folder from DeDRM_Application_Windows to your "My Documents" folder.
 
 2. Open the DeDRM_App folder you've just dragged, and make a short-cut of the DeDRM_Drop_Target.bat file (right-click/Create Shortcut). Drag the shortcut file onto your Desktop.
 
index 9dcade7fc8bd304923fff2757f8d6bd02108b8d8..16233372f66c20325dacb1ce8c55131fecbdbc49 100644 (file)
Binary files a/DeDRM_calibre_plugin/DeDRM_plugin.zip and b/DeDRM_calibre_plugin/DeDRM_plugin.zip differ
index b3594510f79d77b4bb3eb71d6e16d866a0764cc1..6fffb409c6ba3c90b8742d8ecb2d6ae8bdc04ba6 100644 (file)
@@ -56,6 +56,7 @@ __docformat__ = 'restructuredtext en'
 #           Fix an error in wineutils.py
 #   6.5.1 - Updated version number, added PDF check for DRM-free documents
 #   6.5.2 - Another Topaz fix
+#   6.5.3 - Warn about KFX files explicitly
 
 
 """
@@ -63,7 +64,7 @@ Decrypt DRMed ebooks.
 """
 
 PLUGIN_NAME = u"DeDRM"
-PLUGIN_VERSION_TUPLE = (6, 5, 2)
+PLUGIN_VERSION_TUPLE = (6, 5, 3)
 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'
index 67eb4cbf3d6b8d180272f7d5090907a2954c6e0c..c3e475cdfeb854d6e3a6c3202514805dd0ec468f 100644 (file)
@@ -56,8 +56,9 @@ from __future__ import with_statement
 #  5.1 - moved unicode_argv call inside main for Windows DeDRM compatibility
 #  5.2 - Fixed error in command line processing of unicode arguments
 #  5.3 - Changed Android support to allow passing of backup .ab files
+#  5.4 - Recognise KFX files masquerading as azw, even if we can't decrypt them yet.
 
-__version__ = '5.3'
+__version__ = '5.4'
 
 
 import sys, os, re
@@ -194,7 +195,11 @@ def GetDecryptedBook(infile, kDatabases, androidFiles, serials, pids, starttime
         raise DrmException(u"Input file does not exist.")
 
     mobi = True
-    magic3 = open(infile,'rb').read(3)
+    magic8 = open(infile,'rb').read(8)
+    if magic8 == '\xeaDRMION\xee':
+        raise DrmException(u"KFX format detected. This format cannot be decrypted yet.")
+        
+    magic3 = magic8[:3]
     if magic3 == 'TPZ':
         mobi = False
 
@@ -215,8 +220,9 @@ def GetDecryptedBook(infile, kDatabases, androidFiles, serials, pids, starttime
     md1, md2 = mb.getPIDMetaInfo()
     totalpids.extend(kgenpids.getPidList(md1, md2, serials, kDatabases))
     # remove any duplicates
-    totalpid = list(set(totalpids))
+    totalpids = list(set(totalpids))
     print u"Found {1:d} keys to try after {0:.1f} seconds".format(time.time()-starttime, len(totalpids))
+    #print totalpids
 
     try:
         mb.processBook(totalpids)
index 149d09c8bde96b3c77754d9d64ea8cc168a5566c..d2188e36e0859b853ce10a0a1a1a43171c344037 100644 (file)
@@ -1,6 +1,12 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+# Version 3.2.5 December 2016
+# Improve detection of good text decryption.
+#
+# Version 3.2.4 December 2016
+# Remove incorrect support for Kobo Desktop under Wine
+#
 # Version 3.2.3 October 2016
 # Fix for windows network user and more xml fixes
 #
 #
 """Manage all Kobo books, either encrypted or DRM-free."""
 
-__version__ = '3.2.3'
+__version__ = '3.2.4'
 __about__ =  u"Obok v{0}\nCopyright © 2012-2016 Physisticated et al.".format(__version__)
 
 import sys
@@ -351,9 +357,9 @@ class KoboLibrary(object):
                 self.kobodir = os.path.join(self.kobodir, u"Kobo", u"Kobo Desktop Edition")
             elif sys.platform.startswith('darwin'):
                 self.kobodir = os.path.join(os.environ['HOME'], u"Library", u"Application Support", u"Kobo", u"Kobo Desktop Edition")
-            elif linux_path != None:
+            #elif linux_path != None:
                 # Probably Linux, let's get the wine prefix and path to Kobo.
-                self.kobodir = os.path.join(linux_path, u"Local Settings", u"Application Data", u"Kobo", u"Kobo Desktop Edition")
+            #   self.kobodir = os.path.join(linux_path, u"Local Settings", u"Application Data", u"Kobo", u"Kobo Desktop Edition")
             # desktop versions use Kobo.sqlite
             kobodb = os.path.join(self.kobodir, u"Kobo.sqlite")
             # check for existence of file
@@ -582,6 +588,36 @@ class KoboFile(object):
         Returns True if the content was checked, False if it was not
         checked."""
         if self.mimetype == 'application/xhtml+xml':
+            # assume utf-8 with no BOM
+            textoffset = 0
+            stride = 1
+            print u"Checking text:{0}:".format(contents[:10])
+            # check for byte order mark
+            if contents[:3]=="\xef\xbb\xbf":
+                # seems to be utf-8 with BOM
+                print u"Could be utf-8 with BOM"
+                textoffset = 3
+            elif contents[:2]=="\xfe\xff":
+                # seems to be utf-16BE
+                print u"Could be  utf-16BE"
+                textoffset = 3
+                stride = 2
+            elif contents[:2]=="\xff\xfe":
+                # seems to be utf-16LE
+                print u"Could be  utf-16LE"
+                textoffset = 2
+                stride = 2
+            else:
+                print u"Perhaps utf-8 without BOM"
+                
+            # now check that the first few characters are in the ASCII range
+            for i in xrange(textoffset,textoffset+5*stride,stride):
+                if ord(contents[i])<32 or ord(contents[i])>127:
+                    # Non-ascii, so decryption probably failed
+                    print u"Bad character at {0}, value {1}".format(i,ord(contents[i]))
+                    raise ValueError
+            print u"Seems to be good text"
+            return True
             if contents[:5]=="<?xml" or contents[:8]=="\xef\xbb\xbf<?xml":
                 # utf-8
                 return True