|
|
@ -4,7 +4,7 @@
|
|
|
|
from __future__ import with_statement
|
|
|
|
from __future__ import with_statement
|
|
|
|
|
|
|
|
|
|
|
|
# kindlekey.py
|
|
|
|
# kindlekey.py
|
|
|
|
# Copyright © 2010-2015 by some_updates, Apprentice Alf and Apprentice Harper
|
|
|
|
# Copyright © 2010-2016 by some_updates, Apprentice Alf and Apprentice Harper
|
|
|
|
|
|
|
|
|
|
|
|
# Revision history:
|
|
|
|
# Revision history:
|
|
|
|
# 1.0 - Kindle info file decryption, extracted from k4mobidedrm, etc.
|
|
|
|
# 1.0 - Kindle info file decryption, extracted from k4mobidedrm, etc.
|
|
|
@ -19,6 +19,7 @@ from __future__ import with_statement
|
|
|
|
# 1.8 - Fixes for Kindle for Mac, and non-ascii in Windows user names
|
|
|
|
# 1.8 - Fixes for Kindle for Mac, and non-ascii in Windows user names
|
|
|
|
# 1.9 - Fixes for Unicode 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
|
|
|
|
# 2.0 - Added comments and extra fix for non-ascii Windows user names
|
|
|
|
|
|
|
|
# 2.1 - Fixed Kindle for PC encryption changes March 2016
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -26,7 +27,7 @@ Retrieve Kindle for PC/Mac user key.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
__license__ = 'GPL v3'
|
|
|
|
__license__ = 'GPL v3'
|
|
|
|
__version__ = '1.9'
|
|
|
|
__version__ = '2.1'
|
|
|
|
|
|
|
|
|
|
|
|
import sys, os, re
|
|
|
|
import sys, os, re
|
|
|
|
from struct import pack, unpack, unpack_from
|
|
|
|
from struct import pack, unpack, unpack_from
|
|
|
@ -1812,7 +1813,7 @@ elif isosx:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
if len(DB)>4:
|
|
|
|
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().encode('hex'))
|
|
|
|
DB['IDString'] = IDString
|
|
|
|
DB['IDString'] = IDString
|
|
|
|
DB['UserName'] = GetUserName()
|
|
|
|
DB['UserName'] = GetUserName()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -1874,7 +1875,7 @@ def cli_main():
|
|
|
|
sys.stderr=SafeUnbuffered(sys.stderr)
|
|
|
|
sys.stderr=SafeUnbuffered(sys.stderr)
|
|
|
|
argv=unicode_argv()
|
|
|
|
argv=unicode_argv()
|
|
|
|
progname = os.path.basename(argv[0])
|
|
|
|
progname = os.path.basename(argv[0])
|
|
|
|
print u"{0} v{1}\nCopyright © 2010-2013 some_updates and Apprentice Alf".format(progname,__version__)
|
|
|
|
print u"{0} v{1}\nCopyright © 2010-2016 by some_updates, Apprentice Alf and Apprentice Harper".format(progname,__version__)
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
opts, args = getopt.getopt(argv[1:], "hk:")
|
|
|
|
opts, args = getopt.getopt(argv[1:], "hk:")
|
|
|
@ -1904,7 +1905,7 @@ def cli_main():
|
|
|
|
# save to the same directory as the script
|
|
|
|
# save to the same directory as the script
|
|
|
|
outpath = os.path.dirname(argv[0])
|
|
|
|
outpath = os.path.dirname(argv[0])
|
|
|
|
|
|
|
|
|
|
|
|
# make sure the outpath is the
|
|
|
|
# make sure the outpath is canonical
|
|
|
|
outpath = os.path.realpath(os.path.normpath(outpath))
|
|
|
|
outpath = os.path.realpath(os.path.normpath(outpath))
|
|
|
|
|
|
|
|
|
|
|
|
if not getkey(outpath, files):
|
|
|
|
if not getkey(outpath, files):
|
|
|
|