Fix for Kindle problem in Mac app and non-ascii username problem in Windows (plugin and app).

This commit is contained in:
Apprentice Harper
2015-03-25 07:26:33 +00:00
committed by Apprentice Alf
parent 9d9c879413
commit e729ae8904
20 changed files with 97 additions and 683 deletions

View File

@@ -24,7 +24,7 @@
<key>CFBundleExecutable</key>
<string>droplet</string>
<key>CFBundleGetInfoString</key>
<string>DeDRM AppleScript 6.2.0. Written 20102015 by Apprentice Alf et al.</string>
<string>DeDRM AppleScript 6.2.1 Written 20102015 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.2.0</string>
<string>6.2.1</string>
<key>CFBundleSignature</key>
<string>dplt</string>
<key>LSRequiresCarbon</key>

View File

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

View File

@@ -39,13 +39,14 @@ __docformat__ = 'restructuredtext en'
# 6.1.0 - Fixed multiple books import problem and PDF import with no key problem
# 6.2.0 - Support for getting B&N key from nook Study log. Fix for UTF-8 filenames in Adobe ePubs.
# Fix for not copying needed files. Fix for getting default Adobe key for PDFs
# 6.2.1 - Fix for non-ascii Windows user names
"""
Decrypt DRMed ebooks.
"""
PLUGIN_NAME = u"DeDRM"
PLUGIN_VERSION_TUPLE = (6, 2, 0)
PLUGIN_VERSION_TUPLE = (6, 2, 1)
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'
@@ -89,7 +90,7 @@ class DeDRM(FileTypePlugin):
author = u"DiapDealer, Apprentice Alf, 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.
file_types = set(['epub','pdf','pdb','prc','mobi','azw','azw1','azw3','azw4','tpz'])
file_types = set(['epub','pdf','pdb','prc','mobi','pobi','azw','azw1','azw3','azw4','tpz'])
on_import = True
priority = 600

View File

@@ -1,6 +1,14 @@
#!/usr/bin/env python
#fileencoding: utf-8
# android.py
# Copyright © 2013-2015 by Thom and Apprentice Harper
# Revision history:
# 1.0 - AmazonSecureStorage.xml decryption to serial number
# 1.1 - map_data_storage.db decryption to serial number
# 1.2 - BugFix
import os
import sys
import zlib
@@ -80,7 +88,7 @@ def get_serials(path=None):
if path is None and os.path.isfile("backup.ab"):
return get_storage()
if not os.path.isfile(path):
if path is None or not os.path.isfile(path):
return []
storage = parse_preference(path)

View File

@@ -2,6 +2,13 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
# kgenpids.py
# Copyright © 2010-2015 by some_updates, Apprentice Alf and Apprentice Harper
# Revision history:
# 2.0 - Fix for non-ascii Windows user names
import sys
import os, csv
import binascii
@@ -164,7 +171,7 @@ def getKindlePids(rec209, token, serialnum):
pids=[]
if isinstance(serialnum,unicode):
serialnum = serialnum.encode('ascii')
serialnum = serialnum.encode('utf-8')
# Compute book PID
pidHash = SHA1(serialnum+rec209+token)
@@ -190,16 +197,16 @@ def getK4Pids(rec209, token, kindleDatabase):
try:
# Get the Mazama Random number
MazamaRandomNumber = (kindleDatabase[1])['MazamaRandomNumber'].decode('hex').encode('ascii')
MazamaRandomNumber = (kindleDatabase[1])['MazamaRandomNumber'].decode('hex')
# Get the kindle account token
kindleAccountToken = (kindleDatabase[1])['kindle.account.tokens'].decode('hex').encode('ascii')
kindleAccountToken = (kindleDatabase[1])['kindle.account.tokens'].decode('hex')
# Get the IDString used to decode the Kindle Info file
IDString = (kindleDatabase[1])['IDString'].decode('hex').encode('ascii')
IDString = (kindleDatabase[1])['IDString'].decode('hex')
# Get the UserName stored when the Kindle Info file was decoded
UserName = (kindleDatabase[1])['UserName'].decode('hex').encode('ascii')
UserName = (kindleDatabase[1])['UserName'].decode('hex')
except KeyError:
print u"Keys not found in the database {0}.".format(kindleDatabase[0])

View File

@@ -4,9 +4,7 @@
from __future__ import with_statement
# kindlekey.py
# Copyright © 2010-2013 by some_updates and Apprentice Alf
#
# Currently requires alfcrypto.py which requires the alfcrypto library
# Copyright © 2010-2015 by some_updates, Apprentice Alf and Apprentice Harper
# Revision history:
# 1.0 - Kindle info file decryption, extracted from k4mobidedrm, etc.
@@ -20,6 +18,7 @@ from __future__ import with_statement
# 1.7 - Work if TkInter is missing
# 1.8 - Fixes for Kindle for Mac, and non-ascii in Windows user names
# 1.9 - Fixes for Unicode in Windows user names
# 2.0 - Added comments and extra fix for non-ascii Windows user names
"""
@@ -885,6 +884,7 @@ if iswindows:
return "AlternateUserName"
buffer = create_unicode_buffer(len(buffer) * 2)
size.value = len(buffer)
# return low byte of the unicode value of each character of the username
return buffer.value.encode('utf-16-le')[::2]
return GetUserName
GetUserName = GetUserName()
@@ -1161,10 +1161,10 @@ if iswindows:
DB[keyname] = cleartext
if 'kindle.account.tokens' in DB:
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(GetIDString(), GetUserName().decode("latin-1"))
# store values used in decryption
DB['IDString'] = GetIDString()
DB['UserName'] = GetUserName()
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(GetIDString(), GetUserName().encode('hex'))
else:
DB = {}
return DB