mirror of
https://github.com/noDRM/DeDRM_tools
synced 2024-12-27 21:59:11 +01:00
First try at a fix for the Kindle for PC encryption update
This commit is contained in:
parent
d67e05cf04
commit
8cd4be6fb0
12 changed files with 158 additions and 37 deletions
|
@ -24,7 +24,7 @@
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>droplet</string>
|
<string>droplet</string>
|
||||||
<key>CFBundleGetInfoString</key>
|
<key>CFBundleGetInfoString</key>
|
||||||
<string>DeDRM AppleScript 6.3.6 Written 2010–2016 by Apprentice Alf et al.</string>
|
<string>DeDRM AppleScript 6.4.0 Written 2010–2016 by Apprentice Alf et al.</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string>DeDRM</string>
|
<string>DeDRM</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
|
@ -36,13 +36,13 @@
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>6.3.6</string>
|
<string>6.4.0</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>dplt</string>
|
<string>dplt</string>
|
||||||
<key>LSRequiresCarbon</key>
|
<key>LSRequiresCarbon</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>Copyright © 2010–2015 Apprentice Alf and Apprentice Harper</string>
|
<string>Copyright © 2010–2016 Apprentice Alf and Apprentice Harper</string>
|
||||||
<key>WindowState</key>
|
<key>WindowState</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>bundleDividerCollapsed</key>
|
<key>bundleDividerCollapsed</key>
|
||||||
|
|
|
@ -48,6 +48,7 @@ __docformat__ = 'restructuredtext en'
|
||||||
# 6.3.4 - Fixes for Kindle for Android, Linux, and Kobo 3.17
|
# 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
|
# 6.3.5 - Fixes for Linux, and Kobo 3.19 and more logging
|
||||||
# 6.3.6 - Fixes for ADE ePub and PDF introduced in 6.3.5
|
# 6.3.6 - Fixes for ADE ePub and PDF introduced in 6.3.5
|
||||||
|
# 6.4.0 - Updated for new Kindle for PC encryption
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -55,7 +56,7 @@ Decrypt DRMed ebooks.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
PLUGIN_NAME = u"DeDRM"
|
PLUGIN_NAME = u"DeDRM"
|
||||||
PLUGIN_VERSION_TUPLE = (6, 3, 6)
|
PLUGIN_VERSION_TUPLE = (6, 4, 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'
|
||||||
|
|
|
@ -199,9 +199,6 @@ def getK4Pids(rec209, token, kindleDatabase):
|
||||||
# Get the Mazama Random number
|
# Get the Mazama Random number
|
||||||
MazamaRandomNumber = (kindleDatabase[1])['MazamaRandomNumber'].decode('hex')
|
MazamaRandomNumber = (kindleDatabase[1])['MazamaRandomNumber'].decode('hex')
|
||||||
|
|
||||||
# Get the kindle account token
|
|
||||||
kindleAccountToken = (kindleDatabase[1])['kindle.account.tokens'].decode('hex')
|
|
||||||
|
|
||||||
# Get the IDString used to decode the Kindle Info file
|
# Get the IDString used to decode the Kindle Info file
|
||||||
IDString = (kindleDatabase[1])['IDString'].decode('hex')
|
IDString = (kindleDatabase[1])['IDString'].decode('hex')
|
||||||
|
|
||||||
|
@ -212,6 +209,14 @@ def getK4Pids(rec209, token, kindleDatabase):
|
||||||
print u"Keys not found in the database {0}.".format(kindleDatabase[0])
|
print u"Keys not found in the database {0}.".format(kindleDatabase[0])
|
||||||
return pids
|
return pids
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Get the kindle account token, if present
|
||||||
|
kindleAccountToken = (kindleDatabase[1])['kindle.account.tokens'].decode('hex')
|
||||||
|
|
||||||
|
except KeyError:
|
||||||
|
kindleAccountToken=""
|
||||||
|
pass
|
||||||
|
|
||||||
# Get the ID string used
|
# Get the ID string used
|
||||||
encodedIDString = encodeHash(IDString,charMap1)
|
encodedIDString = encodeHash(IDString,charMap1)
|
||||||
|
|
||||||
|
|
|
@ -993,7 +993,22 @@ if iswindows:
|
||||||
# determine type of kindle info provided and return a
|
# determine type of kindle info provided and return a
|
||||||
# database of keynames and values
|
# database of keynames and values
|
||||||
def getDBfromFile(kInfoFile):
|
def getDBfromFile(kInfoFile):
|
||||||
names = ['kindle.account.tokens','kindle.cookie.item','eulaVersionAccepted','login_date','kindle.token.item','login','kindle.key.item','kindle.name.info','kindle.device.info', 'MazamaRandomNumber', 'max_date', 'SIGVERIF']
|
names = [\
|
||||||
|
'kindle.account.tokens',\
|
||||||
|
'kindle.cookie.item',\
|
||||||
|
'eulaVersionAccepted',\
|
||||||
|
'login_date',\
|
||||||
|
'kindle.token.item',\
|
||||||
|
'login',\
|
||||||
|
'kindle.key.item',\
|
||||||
|
'kindle.name.info',\
|
||||||
|
'kindle.device.info',\
|
||||||
|
'MazamaRandomNumber',\
|
||||||
|
'max_date',\
|
||||||
|
'SIGVERIF',\
|
||||||
|
'build_version',\
|
||||||
|
]
|
||||||
|
|
||||||
DB = {}
|
DB = {}
|
||||||
with open(kInfoFile, 'rb') as infoReader:
|
with open(kInfoFile, 'rb') as infoReader:
|
||||||
hdr = infoReader.read(1)
|
hdr = infoReader.read(1)
|
||||||
|
@ -1134,6 +1149,8 @@ if iswindows:
|
||||||
if encodeHash(name,testMap8) == keyhash:
|
if encodeHash(name,testMap8) == keyhash:
|
||||||
keyname = name
|
keyname = name
|
||||||
break
|
break
|
||||||
|
if keyname == "unknown":
|
||||||
|
keyname = keyhash
|
||||||
|
|
||||||
# the testMap8 encoded contents data has had a length
|
# the testMap8 encoded contents data has had a length
|
||||||
# of chars (always odd) cut off of the front and moved
|
# of chars (always odd) cut off of the front and moved
|
||||||
|
@ -1158,14 +1175,17 @@ if iswindows:
|
||||||
# decode using new testMap8 to get the original CryptProtect Data
|
# decode using new testMap8 to get the original CryptProtect Data
|
||||||
encryptedValue = decode(encdata,testMap8)
|
encryptedValue = decode(encdata,testMap8)
|
||||||
cleartext = CryptUnprotectData(encryptedValue, entropy, 1)
|
cleartext = CryptUnprotectData(encryptedValue, entropy, 1)
|
||||||
DB[keyname] = cleartext
|
if len(cleartext)>0:
|
||||||
|
DB[keyname] = cleartext
|
||||||
|
#print keyname, cleartext
|
||||||
|
|
||||||
if 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
# store values used in decryption
|
# store values used in decryption
|
||||||
DB['IDString'] = GetIDString()
|
DB['IDString'] = GetIDString()
|
||||||
DB['UserName'] = GetUserName()
|
DB['UserName'] = GetUserName()
|
||||||
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(GetIDString(), GetUserName().encode('hex'))
|
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(GetIDString(), GetUserName().encode('hex'))
|
||||||
else:
|
else:
|
||||||
|
print u"Couldn't decrypt file."
|
||||||
DB = {}
|
DB = {}
|
||||||
return DB
|
return DB
|
||||||
elif isosx:
|
elif isosx:
|
||||||
|
@ -1577,7 +1597,21 @@ elif isosx:
|
||||||
# determine type of kindle info provided and return a
|
# determine type of kindle info provided and return a
|
||||||
# database of keynames and values
|
# database of keynames and values
|
||||||
def getDBfromFile(kInfoFile):
|
def getDBfromFile(kInfoFile):
|
||||||
names = ['kindle.account.tokens','kindle.cookie.item','eulaVersionAccepted','login_date','kindle.token.item','login','kindle.key.item','kindle.name.info','kindle.device.info', 'MazamaRandomNumber', 'max_date', 'SIGVERIF']
|
names = [\
|
||||||
|
'kindle.account.tokens',\
|
||||||
|
'kindle.cookie.item',\
|
||||||
|
'eulaVersionAccepted',\
|
||||||
|
'login_date',\
|
||||||
|
'kindle.token.item',\
|
||||||
|
'login',\
|
||||||
|
'kindle.key.item',\
|
||||||
|
'kindle.name.info',\
|
||||||
|
'kindle.device.info',\
|
||||||
|
'MazamaRandomNumber',\
|
||||||
|
'max_date',\
|
||||||
|
'SIGVERIF',\
|
||||||
|
'build_version',\
|
||||||
|
]
|
||||||
with open(kInfoFile, 'rb') as infoReader:
|
with open(kInfoFile, 'rb') as infoReader:
|
||||||
filehdr = infoReader.read(1)
|
filehdr = infoReader.read(1)
|
||||||
filedata = infoReader.read()
|
filedata = infoReader.read()
|
||||||
|
@ -1683,7 +1717,7 @@ elif isosx:
|
||||||
if len(cleartext) > 0:
|
if len(cleartext) > 0:
|
||||||
DB[keyname] = cleartext
|
DB[keyname] = cleartext
|
||||||
|
|
||||||
if 'MazamaRandomNumber' in DB and 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# the latest .kinf2011 version for K4M 1.9.1
|
# the latest .kinf2011 version for K4M 1.9.1
|
||||||
|
@ -1772,11 +1806,11 @@ elif isosx:
|
||||||
if len(cleartext) > 0:
|
if len(cleartext) > 0:
|
||||||
DB[keyname] = cleartext
|
DB[keyname] = cleartext
|
||||||
|
|
||||||
if 'MazamaRandomNumber' in DB and 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
# store values used in decryption
|
# store values used in decryption
|
||||||
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(IDString, GetUserName())
|
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(IDString, GetUserName())
|
||||||
DB['IDString'] = IDString
|
DB['IDString'] = IDString
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
# 6.3.4 - Version bump to match plugin
|
# 6.3.4 - Version bump to match plugin
|
||||||
# 6.3.5 - Version bump to match plugin
|
# 6.3.5 - Version bump to match plugin
|
||||||
# 6.3.6 - Version bump to match plugin
|
# 6.3.6 - Version bump to match plugin
|
||||||
|
# 6.4.0 - Fix for Kindle for PC encryption change
|
||||||
|
|
||||||
__version__ = '6.3.6'
|
__version__ = '6.4.0'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os, os.path
|
import os, os.path
|
||||||
|
|
|
@ -48,6 +48,7 @@ __docformat__ = 'restructuredtext en'
|
||||||
# 6.3.4 - Fixes for Kindle for Android, Linux, and Kobo 3.17
|
# 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
|
# 6.3.5 - Fixes for Linux, and Kobo 3.19 and more logging
|
||||||
# 6.3.6 - Fixes for ADE ePub and PDF introduced in 6.3.5
|
# 6.3.6 - Fixes for ADE ePub and PDF introduced in 6.3.5
|
||||||
|
# 6.4.0 - Updated for new Kindle for PC encryption
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -55,7 +56,7 @@ Decrypt DRMed ebooks.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
PLUGIN_NAME = u"DeDRM"
|
PLUGIN_NAME = u"DeDRM"
|
||||||
PLUGIN_VERSION_TUPLE = (6, 3, 6)
|
PLUGIN_VERSION_TUPLE = (6, 4, 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'
|
||||||
|
|
|
@ -199,9 +199,6 @@ def getK4Pids(rec209, token, kindleDatabase):
|
||||||
# Get the Mazama Random number
|
# Get the Mazama Random number
|
||||||
MazamaRandomNumber = (kindleDatabase[1])['MazamaRandomNumber'].decode('hex')
|
MazamaRandomNumber = (kindleDatabase[1])['MazamaRandomNumber'].decode('hex')
|
||||||
|
|
||||||
# Get the kindle account token
|
|
||||||
kindleAccountToken = (kindleDatabase[1])['kindle.account.tokens'].decode('hex')
|
|
||||||
|
|
||||||
# Get the IDString used to decode the Kindle Info file
|
# Get the IDString used to decode the Kindle Info file
|
||||||
IDString = (kindleDatabase[1])['IDString'].decode('hex')
|
IDString = (kindleDatabase[1])['IDString'].decode('hex')
|
||||||
|
|
||||||
|
@ -212,6 +209,14 @@ def getK4Pids(rec209, token, kindleDatabase):
|
||||||
print u"Keys not found in the database {0}.".format(kindleDatabase[0])
|
print u"Keys not found in the database {0}.".format(kindleDatabase[0])
|
||||||
return pids
|
return pids
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Get the kindle account token, if present
|
||||||
|
kindleAccountToken = (kindleDatabase[1])['kindle.account.tokens'].decode('hex')
|
||||||
|
|
||||||
|
except KeyError:
|
||||||
|
kindleAccountToken=""
|
||||||
|
pass
|
||||||
|
|
||||||
# Get the ID string used
|
# Get the ID string used
|
||||||
encodedIDString = encodeHash(IDString,charMap1)
|
encodedIDString = encodeHash(IDString,charMap1)
|
||||||
|
|
||||||
|
|
|
@ -993,7 +993,22 @@ if iswindows:
|
||||||
# determine type of kindle info provided and return a
|
# determine type of kindle info provided and return a
|
||||||
# database of keynames and values
|
# database of keynames and values
|
||||||
def getDBfromFile(kInfoFile):
|
def getDBfromFile(kInfoFile):
|
||||||
names = ['kindle.account.tokens','kindle.cookie.item','eulaVersionAccepted','login_date','kindle.token.item','login','kindle.key.item','kindle.name.info','kindle.device.info', 'MazamaRandomNumber', 'max_date', 'SIGVERIF']
|
names = [\
|
||||||
|
'kindle.account.tokens',\
|
||||||
|
'kindle.cookie.item',\
|
||||||
|
'eulaVersionAccepted',\
|
||||||
|
'login_date',\
|
||||||
|
'kindle.token.item',\
|
||||||
|
'login',\
|
||||||
|
'kindle.key.item',\
|
||||||
|
'kindle.name.info',\
|
||||||
|
'kindle.device.info',\
|
||||||
|
'MazamaRandomNumber',\
|
||||||
|
'max_date',\
|
||||||
|
'SIGVERIF',\
|
||||||
|
'build_version',\
|
||||||
|
]
|
||||||
|
|
||||||
DB = {}
|
DB = {}
|
||||||
with open(kInfoFile, 'rb') as infoReader:
|
with open(kInfoFile, 'rb') as infoReader:
|
||||||
hdr = infoReader.read(1)
|
hdr = infoReader.read(1)
|
||||||
|
@ -1134,6 +1149,8 @@ if iswindows:
|
||||||
if encodeHash(name,testMap8) == keyhash:
|
if encodeHash(name,testMap8) == keyhash:
|
||||||
keyname = name
|
keyname = name
|
||||||
break
|
break
|
||||||
|
if keyname == "unknown":
|
||||||
|
keyname = keyhash
|
||||||
|
|
||||||
# the testMap8 encoded contents data has had a length
|
# the testMap8 encoded contents data has had a length
|
||||||
# of chars (always odd) cut off of the front and moved
|
# of chars (always odd) cut off of the front and moved
|
||||||
|
@ -1158,14 +1175,17 @@ if iswindows:
|
||||||
# decode using new testMap8 to get the original CryptProtect Data
|
# decode using new testMap8 to get the original CryptProtect Data
|
||||||
encryptedValue = decode(encdata,testMap8)
|
encryptedValue = decode(encdata,testMap8)
|
||||||
cleartext = CryptUnprotectData(encryptedValue, entropy, 1)
|
cleartext = CryptUnprotectData(encryptedValue, entropy, 1)
|
||||||
DB[keyname] = cleartext
|
if len(cleartext)>0:
|
||||||
|
DB[keyname] = cleartext
|
||||||
|
#print keyname, cleartext
|
||||||
|
|
||||||
if 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
# store values used in decryption
|
# store values used in decryption
|
||||||
DB['IDString'] = GetIDString()
|
DB['IDString'] = GetIDString()
|
||||||
DB['UserName'] = GetUserName()
|
DB['UserName'] = GetUserName()
|
||||||
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(GetIDString(), GetUserName().encode('hex'))
|
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(GetIDString(), GetUserName().encode('hex'))
|
||||||
else:
|
else:
|
||||||
|
print u"Couldn't decrypt file."
|
||||||
DB = {}
|
DB = {}
|
||||||
return DB
|
return DB
|
||||||
elif isosx:
|
elif isosx:
|
||||||
|
@ -1577,7 +1597,21 @@ elif isosx:
|
||||||
# determine type of kindle info provided and return a
|
# determine type of kindle info provided and return a
|
||||||
# database of keynames and values
|
# database of keynames and values
|
||||||
def getDBfromFile(kInfoFile):
|
def getDBfromFile(kInfoFile):
|
||||||
names = ['kindle.account.tokens','kindle.cookie.item','eulaVersionAccepted','login_date','kindle.token.item','login','kindle.key.item','kindle.name.info','kindle.device.info', 'MazamaRandomNumber', 'max_date', 'SIGVERIF']
|
names = [\
|
||||||
|
'kindle.account.tokens',\
|
||||||
|
'kindle.cookie.item',\
|
||||||
|
'eulaVersionAccepted',\
|
||||||
|
'login_date',\
|
||||||
|
'kindle.token.item',\
|
||||||
|
'login',\
|
||||||
|
'kindle.key.item',\
|
||||||
|
'kindle.name.info',\
|
||||||
|
'kindle.device.info',\
|
||||||
|
'MazamaRandomNumber',\
|
||||||
|
'max_date',\
|
||||||
|
'SIGVERIF',\
|
||||||
|
'build_version',\
|
||||||
|
]
|
||||||
with open(kInfoFile, 'rb') as infoReader:
|
with open(kInfoFile, 'rb') as infoReader:
|
||||||
filehdr = infoReader.read(1)
|
filehdr = infoReader.read(1)
|
||||||
filedata = infoReader.read()
|
filedata = infoReader.read()
|
||||||
|
@ -1683,7 +1717,7 @@ elif isosx:
|
||||||
if len(cleartext) > 0:
|
if len(cleartext) > 0:
|
||||||
DB[keyname] = cleartext
|
DB[keyname] = cleartext
|
||||||
|
|
||||||
if 'MazamaRandomNumber' in DB and 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# the latest .kinf2011 version for K4M 1.9.1
|
# the latest .kinf2011 version for K4M 1.9.1
|
||||||
|
@ -1772,11 +1806,11 @@ elif isosx:
|
||||||
if len(cleartext) > 0:
|
if len(cleartext) > 0:
|
||||||
DB[keyname] = cleartext
|
DB[keyname] = cleartext
|
||||||
|
|
||||||
if 'MazamaRandomNumber' in DB and 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
# store values used in decryption
|
# store values used in decryption
|
||||||
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(IDString, GetUserName())
|
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(IDString, GetUserName())
|
||||||
DB['IDString'] = IDString
|
DB['IDString'] = IDString
|
||||||
|
|
Binary file not shown.
|
@ -48,6 +48,7 @@ __docformat__ = 'restructuredtext en'
|
||||||
# 6.3.4 - Fixes for Kindle for Android, Linux, and Kobo 3.17
|
# 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
|
# 6.3.5 - Fixes for Linux, and Kobo 3.19 and more logging
|
||||||
# 6.3.6 - Fixes for ADE ePub and PDF introduced in 6.3.5
|
# 6.3.6 - Fixes for ADE ePub and PDF introduced in 6.3.5
|
||||||
|
# 6.4.0 - Updated for new Kindle for PC encryption
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -55,7 +56,7 @@ Decrypt DRMed ebooks.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
PLUGIN_NAME = u"DeDRM"
|
PLUGIN_NAME = u"DeDRM"
|
||||||
PLUGIN_VERSION_TUPLE = (6, 3, 6)
|
PLUGIN_VERSION_TUPLE = (6, 4, 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'
|
||||||
|
|
|
@ -199,9 +199,6 @@ def getK4Pids(rec209, token, kindleDatabase):
|
||||||
# Get the Mazama Random number
|
# Get the Mazama Random number
|
||||||
MazamaRandomNumber = (kindleDatabase[1])['MazamaRandomNumber'].decode('hex')
|
MazamaRandomNumber = (kindleDatabase[1])['MazamaRandomNumber'].decode('hex')
|
||||||
|
|
||||||
# Get the kindle account token
|
|
||||||
kindleAccountToken = (kindleDatabase[1])['kindle.account.tokens'].decode('hex')
|
|
||||||
|
|
||||||
# Get the IDString used to decode the Kindle Info file
|
# Get the IDString used to decode the Kindle Info file
|
||||||
IDString = (kindleDatabase[1])['IDString'].decode('hex')
|
IDString = (kindleDatabase[1])['IDString'].decode('hex')
|
||||||
|
|
||||||
|
@ -212,6 +209,14 @@ def getK4Pids(rec209, token, kindleDatabase):
|
||||||
print u"Keys not found in the database {0}.".format(kindleDatabase[0])
|
print u"Keys not found in the database {0}.".format(kindleDatabase[0])
|
||||||
return pids
|
return pids
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Get the kindle account token, if present
|
||||||
|
kindleAccountToken = (kindleDatabase[1])['kindle.account.tokens'].decode('hex')
|
||||||
|
|
||||||
|
except KeyError:
|
||||||
|
kindleAccountToken=""
|
||||||
|
pass
|
||||||
|
|
||||||
# Get the ID string used
|
# Get the ID string used
|
||||||
encodedIDString = encodeHash(IDString,charMap1)
|
encodedIDString = encodeHash(IDString,charMap1)
|
||||||
|
|
||||||
|
|
|
@ -993,7 +993,22 @@ if iswindows:
|
||||||
# determine type of kindle info provided and return a
|
# determine type of kindle info provided and return a
|
||||||
# database of keynames and values
|
# database of keynames and values
|
||||||
def getDBfromFile(kInfoFile):
|
def getDBfromFile(kInfoFile):
|
||||||
names = ['kindle.account.tokens','kindle.cookie.item','eulaVersionAccepted','login_date','kindle.token.item','login','kindle.key.item','kindle.name.info','kindle.device.info', 'MazamaRandomNumber', 'max_date', 'SIGVERIF']
|
names = [\
|
||||||
|
'kindle.account.tokens',\
|
||||||
|
'kindle.cookie.item',\
|
||||||
|
'eulaVersionAccepted',\
|
||||||
|
'login_date',\
|
||||||
|
'kindle.token.item',\
|
||||||
|
'login',\
|
||||||
|
'kindle.key.item',\
|
||||||
|
'kindle.name.info',\
|
||||||
|
'kindle.device.info',\
|
||||||
|
'MazamaRandomNumber',\
|
||||||
|
'max_date',\
|
||||||
|
'SIGVERIF',\
|
||||||
|
'build_version',\
|
||||||
|
]
|
||||||
|
|
||||||
DB = {}
|
DB = {}
|
||||||
with open(kInfoFile, 'rb') as infoReader:
|
with open(kInfoFile, 'rb') as infoReader:
|
||||||
hdr = infoReader.read(1)
|
hdr = infoReader.read(1)
|
||||||
|
@ -1134,6 +1149,8 @@ if iswindows:
|
||||||
if encodeHash(name,testMap8) == keyhash:
|
if encodeHash(name,testMap8) == keyhash:
|
||||||
keyname = name
|
keyname = name
|
||||||
break
|
break
|
||||||
|
if keyname == "unknown":
|
||||||
|
keyname = keyhash
|
||||||
|
|
||||||
# the testMap8 encoded contents data has had a length
|
# the testMap8 encoded contents data has had a length
|
||||||
# of chars (always odd) cut off of the front and moved
|
# of chars (always odd) cut off of the front and moved
|
||||||
|
@ -1158,14 +1175,17 @@ if iswindows:
|
||||||
# decode using new testMap8 to get the original CryptProtect Data
|
# decode using new testMap8 to get the original CryptProtect Data
|
||||||
encryptedValue = decode(encdata,testMap8)
|
encryptedValue = decode(encdata,testMap8)
|
||||||
cleartext = CryptUnprotectData(encryptedValue, entropy, 1)
|
cleartext = CryptUnprotectData(encryptedValue, entropy, 1)
|
||||||
DB[keyname] = cleartext
|
if len(cleartext)>0:
|
||||||
|
DB[keyname] = cleartext
|
||||||
|
#print keyname, cleartext
|
||||||
|
|
||||||
if 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
# store values used in decryption
|
# store values used in decryption
|
||||||
DB['IDString'] = GetIDString()
|
DB['IDString'] = GetIDString()
|
||||||
DB['UserName'] = GetUserName()
|
DB['UserName'] = GetUserName()
|
||||||
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(GetIDString(), GetUserName().encode('hex'))
|
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(GetIDString(), GetUserName().encode('hex'))
|
||||||
else:
|
else:
|
||||||
|
print u"Couldn't decrypt file."
|
||||||
DB = {}
|
DB = {}
|
||||||
return DB
|
return DB
|
||||||
elif isosx:
|
elif isosx:
|
||||||
|
@ -1577,7 +1597,21 @@ elif isosx:
|
||||||
# determine type of kindle info provided and return a
|
# determine type of kindle info provided and return a
|
||||||
# database of keynames and values
|
# database of keynames and values
|
||||||
def getDBfromFile(kInfoFile):
|
def getDBfromFile(kInfoFile):
|
||||||
names = ['kindle.account.tokens','kindle.cookie.item','eulaVersionAccepted','login_date','kindle.token.item','login','kindle.key.item','kindle.name.info','kindle.device.info', 'MazamaRandomNumber', 'max_date', 'SIGVERIF']
|
names = [\
|
||||||
|
'kindle.account.tokens',\
|
||||||
|
'kindle.cookie.item',\
|
||||||
|
'eulaVersionAccepted',\
|
||||||
|
'login_date',\
|
||||||
|
'kindle.token.item',\
|
||||||
|
'login',\
|
||||||
|
'kindle.key.item',\
|
||||||
|
'kindle.name.info',\
|
||||||
|
'kindle.device.info',\
|
||||||
|
'MazamaRandomNumber',\
|
||||||
|
'max_date',\
|
||||||
|
'SIGVERIF',\
|
||||||
|
'build_version',\
|
||||||
|
]
|
||||||
with open(kInfoFile, 'rb') as infoReader:
|
with open(kInfoFile, 'rb') as infoReader:
|
||||||
filehdr = infoReader.read(1)
|
filehdr = infoReader.read(1)
|
||||||
filedata = infoReader.read()
|
filedata = infoReader.read()
|
||||||
|
@ -1683,7 +1717,7 @@ elif isosx:
|
||||||
if len(cleartext) > 0:
|
if len(cleartext) > 0:
|
||||||
DB[keyname] = cleartext
|
DB[keyname] = cleartext
|
||||||
|
|
||||||
if 'MazamaRandomNumber' in DB and 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# the latest .kinf2011 version for K4M 1.9.1
|
# the latest .kinf2011 version for K4M 1.9.1
|
||||||
|
@ -1772,11 +1806,11 @@ elif isosx:
|
||||||
if len(cleartext) > 0:
|
if len(cleartext) > 0:
|
||||||
DB[keyname] = cleartext
|
DB[keyname] = cleartext
|
||||||
|
|
||||||
if 'MazamaRandomNumber' in DB and 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if 'kindle.account.tokens' in DB:
|
if len(DB)>4:
|
||||||
# store values used in decryption
|
# store values used in decryption
|
||||||
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(IDString, GetUserName())
|
print u"Decrypted key file using IDString '{0:s}' and UserName '{1:s}'".format(IDString, GetUserName())
|
||||||
DB['IDString'] = IDString
|
DB['IDString'] = IDString
|
||||||
|
|
Loading…
Reference in a new issue