tools v6.1.0

This commit is contained in:
Apprentice Alf 2014-12-08 21:23:07 +00:00
parent a30aace99c
commit c4fc10395b
8 changed files with 100 additions and 69 deletions

View file

@ -24,19 +24,19 @@
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>droplet</string> <string>droplet</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
<string>DeDRM AppleScript 6.0.9. Written 20102013 by Apprentice Alf and others.</string> <string>DeDRM AppleScript 6.1.0. Written 20102014 by Apprentice Alf and others.</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>DeDRM</string> <string>DeDRM</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.apple.ScriptEditor.id.707CCCD5-0C6C-4BEB-B67C-B6E866ADE85A</string> <string>com.apple.ScriptEditor.id.707CCCD5-0C6C-4BEB-B67C-B6E866ADE85A</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0.9</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>DeDRM</string> <string>DeDRM</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>6.0.9</string> <string>6.1.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>dplt</string> <string>dplt</string>
<key>LSRequiresCarbon</key> <key>LSRequiresCarbon</key>

View file

@ -21,7 +21,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. 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.0.0/DeDRM_Application_Windows to your "My Documents" folder. 1. Drag the DeDRM_App folder from tools_v6.1.0/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. 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.

View file

@ -22,7 +22,18 @@ li {margin-top: 0.5em}
<p>If you have upgraded from an earlier version of the plugin, any existing Barnes and Noble keys will have been automatically imported, so you might not need to do any more configuration. Continue reading for key generation and management instructions.</p> <p>If you have upgraded from an earlier version of the plugin, any existing Barnes and Noble keys will have been automatically imported, so you might not need to do any more configuration. Continue reading for key generation and management instructions.</p>
<h3>Creating New Keys:</h3> <h3>Changes at Barnes & Noble</h3>
<p>In mid-2014, Barnes & Noble changed the way they generated encryption keys. Instead of deriving the key from the user's name and credit card number, they started generating a random key themselves, sending that key through to devices when they connected to the B&N servers. This means that some users will find that no combination of their name and CC# will work in decrypting their ebooks.</p>
<p>There is a work-around. B&N's desktop apps for Mac and Windows (nook for Mac/PC, nookStudy) generate a log file that contains the encryption key. For Mac the log file can be found somewhere in [user folder]/Library/Application Support/Barnes & Noble/ and for Windows the log file can be found somewhere in C:\Users\admin\AppData\Roaming\Barnes & Noble\</p>
<p>In both cases, the log file will be called BNClientLog.txt</p>
<p>You will need to open the application, sign in to your account, and download your books, checking that you can read them in the application, and then quit the application.</p>
<p>Then you must open the log file in a text editor and search for CCHashResponseV1. Immediately after that text should be some more text, similar to ccHash: "rLYiGD+vcPoXvsj/87kDAb1AkBy="<p>
<p>Copy the text after ccHash, include the " marks. Save it in a new text file, with file name extension .b64</p>
<p>Follow the instructions below "Importing Existing Keyfiles:" to import that newly saved file into the preferences.</p>
<h3>Old instructions: Creating New Keys:</h3>
<p>On the right-hand side of the plugins customization dialog, you will see a button with an icon that looks like a green plus sign (+). Clicking this button will open a new dialog for entering the necessary data to generate a new key.</p> <p>On the right-hand side of the plugins customization dialog, you will see a button with an icon that looks like a green plus sign (+). Clicking this button will open a new dialog for entering the necessary data to generate a new key.</p>
<ul> <ul>
@ -48,7 +59,7 @@ li {margin-top: 0.5em}
<h3>Importing Existing Keyfiles:</h3> <h3>Importing Existing Keyfiles:</h3>
<p>At the bottom-left of the plugins customization dialog, you will see a button labeled "Import Existing Keyfiles". Use this button to import existing .b64 key files. Key files might come from being exported from this or older plugins, or may have been generated using the original i♥cabbages script.</p> <p>At the bottom-left of the plugins customization dialog, you will see a button labeled "Import Existing Keyfiles". Use this button to import existing .b64 key files. Key files might come from being exported from this or older plugins, or may have been generated using the original i♥cabbages script, or you may have made it by following the instructions above.</p>
<p>Once done creating/deleting/renaming/importing decryption keys, click Close to exit the customization dialogue. Your changes wil only be saved permanently when you click OK in the main configuration dialog.</p> <p>Once done creating/deleting/renaming/importing decryption keys, click Close to exit the customization dialogue. Your changes wil only be saved permanently when you click OK in the main configuration dialog.</p>

View file

@ -17,7 +17,7 @@ p {margin-top: 0}
<body> <body>
<h1>DeDRM Plugin <span class="version">(v6.0.9)</span></h1> <h1>DeDRM Plugin <span class="version">(v6.1.0)</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> <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>

View file

@ -36,13 +36,14 @@ __docformat__ = 'restructuredtext en'
# 6.0.7 - Error handling for incomplete PDF metadata # 6.0.7 - Error handling for incomplete PDF metadata
# 6.0.8 - Fixes a Wine key issue and topaz support # 6.0.8 - Fixes a Wine key issue and topaz support
# 6.0.9 - Ported to work with newer versions of Calibre (moved to Qt5). Still supports older Qt4 versions. # 6.0.9 - Ported to work with newer versions of Calibre (moved to Qt5). Still supports older Qt4 versions.
# 6.1.0 - Fixed multiple books import problem and PDF import with no key problem
""" """
Decrypt DRMed ebooks. Decrypt DRMed ebooks.
""" """
PLUGIN_NAME = u"DeDRM" PLUGIN_NAME = u"DeDRM"
PLUGIN_VERSION_TUPLE = (6, 0, 9) PLUGIN_VERSION_TUPLE = (6, 1, 0)
PLUGIN_VERSION = u".".join([unicode(str(x)) for x in PLUGIN_VERSION_TUPLE]) 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. # Include an html helpfile in the plugin's zipfile with the following name.
RESOURCE_NAME = PLUGIN_NAME + '_Help.htm' RESOURCE_NAME = PLUGIN_NAME + '_Help.htm'
@ -90,21 +91,22 @@ class DeDRM(FileTypePlugin):
on_import = True on_import = True
priority = 600 priority = 600
def initialize(self): def load_resources(self, names):
# convert old preferences, if necessary. print u"{0} v{1}: In load_resources".format(PLUGIN_NAME, PLUGIN_VERSION)
try: return {}
from calibre_plugins.dedrm.prefs import convertprefs
convertprefs()
except:
traceback.print_exc()
def __init__(self, plugin_path):
print u"{0} v{1}: In __init__".format(PLUGIN_NAME, PLUGIN_VERSION)
super(DeDRM, self).__init__(plugin_path)
""" """
Dynamic modules can't be imported/loaded from a zipfile... so this routine Dynamic modules can't be imported/loaded from a zipfile.
runs whenever the plugin gets initialized. This will extract the appropriate So this routine will extract the appropriate
library for the target OS and copy it to the 'alfcrypto' subdirectory of library for the target OS and copy it to the 'alfcrypto' subdirectory of
calibre's configuration directory. That 'alfcrypto' directory is then calibre's configuration directory. That 'alfcrypto' directory is then
inserted into the syspath (as the very first entry) in the run function inserted into the syspath (as the very first entry) in the run function
so the CDLL stuff will work in the alfcrypto.py script. so the CDLL stuff will work in the alfcrypto.py script.
The extraction only happens once per version of the plugin
""" """
try: try:
if iswindows: if iswindows:
@ -126,13 +128,31 @@ class DeDRM(FileTypePlugin):
self.alfdir = os.path.join(self.maindir,u"libraryfiles") self.alfdir = os.path.join(self.maindir,u"libraryfiles")
if not os.path.exists(self.alfdir): if not os.path.exists(self.alfdir):
os.mkdir(self.alfdir) os.mkdir(self.alfdir)
for entry, data in lib_dict.items(): # only continue if we've never run this version of the plugin before
file_path = os.path.join(self.alfdir, entry) self.verdir = os.path.join(self.maindir,PLUGIN_VERSION)
open(file_path,'wb').write(data) print u"{0} v{1}: verdir {2}".format(PLUGIN_NAME, PLUGIN_VERSION, self.verdir)
if not os.path.exists(self.verdir):
print u"{0} v{1}: Copying needed libraries from zip".format(PLUGIN_NAME, PLUGIN_VERSION)
os.mkdir(self.verdir)
for entry, data in lib_dict.items():
file_path = os.path.join(self.alfdir, entry)
os.remove(file_path)
open(file_path,'wb').write(data)
except Exception, e: except Exception, e:
traceback.print_exc() traceback.print_exc()
raise raise
def initialize(self):
print u"{0} v{1}: In initialize".format(PLUGIN_NAME, PLUGIN_VERSION)
# convert old preferences, if necessary.
try:
from calibre_plugins.dedrm.prefs import convertprefs
convertprefs()
except:
traceback.print_exc()
def ePubDecrypt(self,path_to_ebook): def ePubDecrypt(self,path_to_ebook):
# Create a TemporaryPersistent file to work with. # Create a TemporaryPersistent file to work with.
# Check original epub archive for zip errors. # Check original epub archive for zip errors.
@ -298,63 +318,63 @@ class DeDRM(FileTypePlugin):
# Return the modified PersistentTemporary file to calibre. # Return the modified PersistentTemporary file to calibre.
return of.name return of.name
# perhaps we need to get a new default ADE key # perhaps we need to get a new default ADE key
print u"{0} v{1}: Looking for new default Adobe Digital Editions Keys after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime) print u"{0} v{1}: Looking for new default Adobe Digital Editions Keys after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION, time.time()-self.starttime)
# get the default Adobe keys # get the default Adobe keys
defaultkeys = [] defaultkeys = []
if iswindows or isosx: if iswindows or isosx:
import calibre_plugins.dedrm.adobekey as adobe import calibre_plugins.dedrm.adobekey as adobe
try: try:
defaultkeys = adobe.adeptkeys() defaultkeys = adobe.adeptkeys()
except: except:
pass pass
else: else:
# linux # linux
try: try:
from wineutils import WineGetKeys from wineutils import WineGetKeys
scriptpath = os.path.join(self.alfdir,u"adobekey.py") scriptpath = os.path.join(self.alfdir,u"adobekey.py")
defaultkeys = WineGetKeys(scriptpath, u".der",dedrmprefs['adobewineprefix']) defaultkeys = WineGetKeys(scriptpath, u".der",dedrmprefs['adobewineprefix'])
except: except:
pass pass
newkeys = [] newkeys = []
for keyvalue in defaultkeys: for keyvalue in defaultkeys:
if keyvalue.encode('hex') not in dedrmprefs['adeptkeys'].values(): if keyvalue.encode('hex') not in dedrmprefs['adeptkeys'].values():
newkeys.append(keyvalue) newkeys.append(keyvalue)
if len(newkeys) > 0: if len(newkeys) > 0:
try: try:
for i,userkey in enumerate(newkeys): for i,userkey in enumerate(newkeys):
print u"{0} v{1}: Trying a new default key".format(PLUGIN_NAME, PLUGIN_VERSION) print u"{0} v{1}: Trying a new default key".format(PLUGIN_NAME, PLUGIN_VERSION)
of = self.temporary_file(u".pdf") of = self.temporary_file(u".pdf")
# Give the user key, ebook and TemporaryPersistent file to the decryption function. # Give the user key, ebook and TemporaryPersistent file to the decryption function.
try:
result = ineptepdf.decryptBook(userkey, inf.name, of.name)
except:
result = 1
of.close()
if result == 0:
# Decryption was a success
# Store the new successful key in the defaults
print u"{0} v{1}: Saving a new default key".format(PLUGIN_NAME, PLUGIN_VERSION)
try: try:
result = ineptepdf.decryptBook(userkey, inf.name, of.name) dedrmprefs.addnamedvaluetoprefs('adeptkeys','default_key',keyvalue.encode('hex'))
dedrmprefs.writeprefs()
except: except:
result = 1 traceback.print_exc()
# Return the modified PersistentTemporary file to calibre.
return of.name
of.close() print u"{0} v{1}: Failed to decrypt with new default key after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime)
except Exception, e:
if result == 0: pass
# Decryption was a success
# Store the new successful key in the defaults
print u"{0} v{1}: Saving a new default key".format(PLUGIN_NAME, PLUGIN_VERSION)
try:
dedrmprefs.addnamedvaluetoprefs('adeptkeys','default_key',keyvalue.encode('hex'))
dedrmprefs.writeprefs()
except:
traceback.print_exc()
# Return the modified PersistentTemporary file to calibre.
return of.name
print u"{0} v{1}: Failed to decrypt with new default key after {2:.1f} seconds".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime)
except Exception, e:
pass
# Something went wrong with decryption. # Something went wrong with decryption.
print u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds.\nRead the FAQs at Alf's blog: http://apprenticealf.wordpress.com/".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime) print u"{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds.\nRead the FAQs at Alf's blog: http://apprenticealf.wordpress.com/".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime)

View file

@ -1,7 +1,7 @@
Welcome to the tools! Welcome to the tools!
===================== =====================
This ReadMe_First.txt is meant to give users a quick overview of what is available and how to get started. This document is part of the Tools v6.0.5 archive from Apprentice Alf's Blog: http://apprenticealf.wordpress.com/ This ReadMe_First.txt is meant to give users a quick overview of what is available and how to get started. This document is part of the Tools v6.1.0 archive from Apprentice Alf's Blog: http://apprenticealf.wordpress.com/
The is archive includes tools to remove DRM from: The is archive includes tools to remove DRM from:
@ -71,7 +71,7 @@ For more detailed instructions, see the DeDRM_App_ReadMe.txt file in the DeDRM_W
Other_Tools Other_Tools
----------- -----------
This folder includes other tools that may be useful for DRMed ebooks from certain sources or for Linux users. Most users won't need any of these tools. This is now a separate archive and includes other tools that may be useful for DRMed ebooks from certain sources or for Linux users. Most users won't need any of these tools.
Key_Generation_Scripts Key_Generation_Scripts
This folder contains python scripts that creates a keyfiles for Barnes and Noble ePubs, Adobe Digital Editions ePubs and Kindle for Mac/PC ebooks. This folder contains python scripts that creates a keyfiles for Barnes and Noble ePubs, Adobe Digital Editions ePubs and Kindle for Mac/PC ebooks.