mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2026-03-23 14:18:57 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc5261870f | ||
|
|
a2ba5005c9 | ||
|
|
24922999dc | ||
|
|
e2170b4260 | ||
|
|
054ddc894b | ||
|
|
8cd4be6fb0 | ||
|
|
d67e05cf04 | ||
|
|
a5197a6abb | ||
|
|
cfc13db6c5 | ||
|
|
8aa2157d55 | ||
|
|
81b08dcf05 |
@@ -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.2 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.2</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>
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
# Released under the terms of the GNU General Public Licence, version 3
|
# Released under the terms of the GNU General Public Licence, version 3
|
||||||
# <http://www.gnu.org/licenses/>
|
# <http://www.gnu.org/licenses/>
|
||||||
#
|
#
|
||||||
# Requires Calibre version 0.7.55 or higher.
|
|
||||||
#
|
|
||||||
# All credit given to i♥cabbages and The Dark Reverser for the original standalone scripts.
|
# All credit given to i♥cabbages and The Dark Reverser for the original standalone scripts.
|
||||||
# We had the much easier job of converting them to a calibre plugin.
|
# We had the much easier job of converting them to a calibre plugin.
|
||||||
#
|
#
|
||||||
@@ -48,6 +46,8 @@ __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
|
||||||
|
# 6.4.1 - Fix for some new tags in Topaz ebooks.
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -55,7 +55,7 @@ Decrypt DRMed ebooks.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
PLUGIN_NAME = u"DeDRM"
|
PLUGIN_NAME = u"DeDRM"
|
||||||
PLUGIN_VERSION_TUPLE = (6, 3, 6)
|
PLUGIN_VERSION_TUPLE = (6, 4, 1)
|
||||||
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'
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ class PageParser(object):
|
|||||||
self.id = os.path.basename(filename).replace('.dat','')
|
self.id = os.path.basename(filename).replace('.dat','')
|
||||||
self.dict = dict
|
self.dict = dict
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
|
self.first_unknown = True
|
||||||
self.flat_xml = flat_xml
|
self.flat_xml = flat_xml
|
||||||
self.tagpath = []
|
self.tagpath = []
|
||||||
self.doc = []
|
self.doc = []
|
||||||
@@ -262,6 +263,9 @@ class PageParser(object):
|
|||||||
'img.w' : (1, 'scalar_number', 0, 0),
|
'img.w' : (1, 'scalar_number', 0, 0),
|
||||||
'img.src' : (1, 'scalar_number', 0, 0),
|
'img.src' : (1, 'scalar_number', 0, 0),
|
||||||
'img.color_src' : (1, 'scalar_number', 0, 0),
|
'img.color_src' : (1, 'scalar_number', 0, 0),
|
||||||
|
'img.gridSize' : (1, 'scalar_number', 0, 0),
|
||||||
|
'img.gridBottomCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'img.gridTopCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'img.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
'img.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'img.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
'img.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'img.image_type' : (1, 'scalar_number', 0, 0),
|
'img.image_type' : (1, 'scalar_number', 0, 0),
|
||||||
@@ -313,11 +317,16 @@ class PageParser(object):
|
|||||||
'span.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
'span.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'span.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
'span.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
|
||||||
'extratokens' : (1, 'snippets', 1, 0),
|
'extratokens' : (1, 'snippets', 1, 0),
|
||||||
'extratokens.class' : (1, 'scalar_text', 0, 0),
|
'extratokens.class' : (1, 'scalar_text', 0, 0),
|
||||||
'extratokens.type' : (1, 'scalar_text', 0, 0),
|
'extratokens.type' : (1, 'scalar_text', 0, 0),
|
||||||
'extratokens.firstGlyph' : (1, 'scalar_number', 0, 0),
|
'extratokens.firstGlyph' : (1, 'scalar_number', 0, 0),
|
||||||
'extratokens.lastGlyph' : (1, 'scalar_number', 0, 0),
|
'extratokens.lastGlyph' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridSize' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridBottomCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridTopCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
|
||||||
'glyph.h' : (1, 'number', 0, 0),
|
'glyph.h' : (1, 'number', 0, 0),
|
||||||
'glyph.w' : (1, 'number', 0, 0),
|
'glyph.w' : (1, 'number', 0, 0),
|
||||||
@@ -506,8 +515,9 @@ class PageParser(object):
|
|||||||
# or an out of sync condition
|
# or an out of sync condition
|
||||||
else:
|
else:
|
||||||
result = []
|
result = []
|
||||||
if (self.debug):
|
if (self.debug or self.first_unknown):
|
||||||
print 'Unknown Token:', token
|
print 'Unknown Token:', token
|
||||||
|
self.first_unknown = False
|
||||||
self.tag_pop()
|
self.tag_pop()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ def generateBook(bookDir, raw, fixedimage):
|
|||||||
# print "first normal text page is", spage
|
# print "first normal text page is", spage
|
||||||
|
|
||||||
# get page height and width from first text page for use in stylesheet scaling
|
# get page height and width from first text page for use in stylesheet scaling
|
||||||
pname = 'page%04d.dat' % (pnum + 1)
|
pname = 'page%04d.dat' % (pnum - 1)
|
||||||
fname = os.path.join(pageDir,pname)
|
fname = os.path.join(pageDir,pname)
|
||||||
flat_xml = convert2xml.fromData(dict, fname)
|
flat_xml = convert2xml.fromData(dict, fname)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
# ineptepub.pyw, version 6.4
|
# ineptepub.pyw, version 6.5
|
||||||
# Copyright © 2009-2010 by i♥cabbages
|
# Copyright © 2009-2010 by i♥cabbages
|
||||||
|
|
||||||
# Released under the terms of the GNU General Public Licence, version 3
|
# Released under the terms of the GNU General Public Licence, version 3
|
||||||
@@ -41,13 +41,14 @@ from __future__ import with_statement
|
|||||||
# 6.2 - Handle UTF-8 file names inside an ePub, fix by Jose Luis
|
# 6.2 - Handle UTF-8 file names inside an ePub, fix by Jose Luis
|
||||||
# 6.3 - Add additional check on DER file sanity
|
# 6.3 - Add additional check on DER file sanity
|
||||||
# 6.4 - Remove erroneous check on DER file sanity
|
# 6.4 - Remove erroneous check on DER file sanity
|
||||||
|
# 6.5 - Completely remove erroneous check on DER file sanity
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Decrypt Adobe Digital Editions encrypted ePub books.
|
Decrypt Adobe Digital Editions encrypted ePub books.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__version__ = "6.4"
|
__version__ = "6.5"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@@ -316,11 +317,6 @@ def _load_crypto_pycrypto():
|
|||||||
key = [key.getChild(x).value for x in xrange(1, 4)]
|
key = [key.getChild(x).value for x in xrange(1, 4)]
|
||||||
key = [self.bytesToNumber(v) for v in key]
|
key = [self.bytesToNumber(v) for v in key]
|
||||||
self._rsa = _RSA.construct(key)
|
self._rsa = _RSA.construct(key)
|
||||||
# check if pointer is not NULL
|
|
||||||
try:
|
|
||||||
c = self._rsa.contents
|
|
||||||
except ValueError:
|
|
||||||
raise ADEPTError('Error parsing ADEPT user key DER')
|
|
||||||
|
|
||||||
def bytesToNumber(self, bytes):
|
def bytesToNumber(self, bytes):
|
||||||
total = 0L
|
total = 0L
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
# ineptpdf.pyw, version 8.0.3
|
# ineptpdf.pyw, version 8.0.4
|
||||||
# Copyright © 2009-2010 by i♥cabbages
|
# Copyright © 2009-2010 by i♥cabbages
|
||||||
|
|
||||||
# Released under the terms of the GNU General Public Licence, version 3
|
# Released under the terms of the GNU General Public Licence, version 3
|
||||||
@@ -56,6 +56,7 @@ from __future__ import with_statement
|
|||||||
# 8.0.1 - Broken Metadata fix.
|
# 8.0.1 - Broken Metadata fix.
|
||||||
# 8.0.2 - Add additional check on DER file sanity
|
# 8.0.2 - Add additional check on DER file sanity
|
||||||
# 8.0.3 - Remove erroneous check on DER file sanity
|
# 8.0.3 - Remove erroneous check on DER file sanity
|
||||||
|
# 8.0.4 - Completely remove erroneous check on DER file sanity
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -63,7 +64,7 @@ Decrypts Adobe ADEPT-encrypted PDF files.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__version__ = "8.0.3"
|
__version__ = "8.0.4"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@@ -387,11 +388,6 @@ def _load_crypto_pycrypto():
|
|||||||
key = [key.getChild(x).value for x in xrange(1, 4)]
|
key = [key.getChild(x).value for x in xrange(1, 4)]
|
||||||
key = [self.bytesToNumber(v) for v in key]
|
key = [self.bytesToNumber(v) for v in key]
|
||||||
self._rsa = _RSA.construct(key)
|
self._rsa = _RSA.construct(key)
|
||||||
# check if pointer is not NULL
|
|
||||||
try:
|
|
||||||
c = self._rsa.contents
|
|
||||||
except ValueError:
|
|
||||||
raise ADEPTError('Error parsing ADEPT user key DER')
|
|
||||||
|
|
||||||
def bytesToNumber(self, bytes):
|
def bytesToNumber(self, bytes):
|
||||||
total = 0L
|
total = 0L
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -448,6 +448,8 @@ class MobiBook:
|
|||||||
goodpids.append(pid[0:-2])
|
goodpids.append(pid[0:-2])
|
||||||
elif len(pid)==8:
|
elif len(pid)==8:
|
||||||
goodpids.append(pid)
|
goodpids.append(pid)
|
||||||
|
else:
|
||||||
|
print u"Warning: PID {0} has wrong number of digits".format(pid)
|
||||||
|
|
||||||
if self.crypto_type == 1:
|
if self.crypto_type == 1:
|
||||||
t1_keyvec = 'QDCVEPMU675RUBSZ'
|
t1_keyvec = 'QDCVEPMU675RUBSZ'
|
||||||
@@ -530,7 +532,7 @@ def cli_main():
|
|||||||
stripped_file = getUnencryptedBook(infile, pidlist)
|
stripped_file = getUnencryptedBook(infile, pidlist)
|
||||||
file(outfile, 'wb').write(stripped_file)
|
file(outfile, 'wb').write(stripped_file)
|
||||||
except DrmException, e:
|
except DrmException, e:
|
||||||
print u"MobiDeDRM v{0} Error: {0:s}".format(__version__,e.args[0])
|
print u"MobiDeDRM v{0} Error: {1:s}".format(__version__,e.args[0])
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,11 @@
|
|||||||
# 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
|
||||||
|
# 6.4.1 - Fix for new tags in Topaz ebooks
|
||||||
|
# 6.4.2 - Fix for new tags in Topaz ebooks, and very small Topaz ebooks
|
||||||
|
|
||||||
__version__ = '6.3.6'
|
__version__ = '6.4.2'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os, os.path
|
import os, os.path
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
# Released under the terms of the GNU General Public Licence, version 3
|
# Released under the terms of the GNU General Public Licence, version 3
|
||||||
# <http://www.gnu.org/licenses/>
|
# <http://www.gnu.org/licenses/>
|
||||||
#
|
#
|
||||||
# Requires Calibre version 0.7.55 or higher.
|
|
||||||
#
|
|
||||||
# All credit given to i♥cabbages and The Dark Reverser for the original standalone scripts.
|
# All credit given to i♥cabbages and The Dark Reverser for the original standalone scripts.
|
||||||
# We had the much easier job of converting them to a calibre plugin.
|
# We had the much easier job of converting them to a calibre plugin.
|
||||||
#
|
#
|
||||||
@@ -48,6 +46,8 @@ __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
|
||||||
|
# 6.4.1 - Fix for some new tags in Topaz ebooks.
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -55,7 +55,7 @@ Decrypt DRMed ebooks.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
PLUGIN_NAME = u"DeDRM"
|
PLUGIN_NAME = u"DeDRM"
|
||||||
PLUGIN_VERSION_TUPLE = (6, 3, 6)
|
PLUGIN_VERSION_TUPLE = (6, 4, 1)
|
||||||
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'
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ class PageParser(object):
|
|||||||
self.id = os.path.basename(filename).replace('.dat','')
|
self.id = os.path.basename(filename).replace('.dat','')
|
||||||
self.dict = dict
|
self.dict = dict
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
|
self.first_unknown = True
|
||||||
self.flat_xml = flat_xml
|
self.flat_xml = flat_xml
|
||||||
self.tagpath = []
|
self.tagpath = []
|
||||||
self.doc = []
|
self.doc = []
|
||||||
@@ -262,6 +263,9 @@ class PageParser(object):
|
|||||||
'img.w' : (1, 'scalar_number', 0, 0),
|
'img.w' : (1, 'scalar_number', 0, 0),
|
||||||
'img.src' : (1, 'scalar_number', 0, 0),
|
'img.src' : (1, 'scalar_number', 0, 0),
|
||||||
'img.color_src' : (1, 'scalar_number', 0, 0),
|
'img.color_src' : (1, 'scalar_number', 0, 0),
|
||||||
|
'img.gridSize' : (1, 'scalar_number', 0, 0),
|
||||||
|
'img.gridBottomCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'img.gridTopCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'img.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
'img.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'img.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
'img.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'img.image_type' : (1, 'scalar_number', 0, 0),
|
'img.image_type' : (1, 'scalar_number', 0, 0),
|
||||||
@@ -313,11 +317,16 @@ class PageParser(object):
|
|||||||
'span.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
'span.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'span.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
'span.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
|
||||||
'extratokens' : (1, 'snippets', 1, 0),
|
'extratokens' : (1, 'snippets', 1, 0),
|
||||||
'extratokens.class' : (1, 'scalar_text', 0, 0),
|
'extratokens.class' : (1, 'scalar_text', 0, 0),
|
||||||
'extratokens.type' : (1, 'scalar_text', 0, 0),
|
'extratokens.type' : (1, 'scalar_text', 0, 0),
|
||||||
'extratokens.firstGlyph' : (1, 'scalar_number', 0, 0),
|
'extratokens.firstGlyph' : (1, 'scalar_number', 0, 0),
|
||||||
'extratokens.lastGlyph' : (1, 'scalar_number', 0, 0),
|
'extratokens.lastGlyph' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridSize' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridBottomCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridTopCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
|
||||||
'glyph.h' : (1, 'number', 0, 0),
|
'glyph.h' : (1, 'number', 0, 0),
|
||||||
'glyph.w' : (1, 'number', 0, 0),
|
'glyph.w' : (1, 'number', 0, 0),
|
||||||
@@ -506,8 +515,9 @@ class PageParser(object):
|
|||||||
# or an out of sync condition
|
# or an out of sync condition
|
||||||
else:
|
else:
|
||||||
result = []
|
result = []
|
||||||
if (self.debug):
|
if (self.debug or self.first_unknown):
|
||||||
print 'Unknown Token:', token
|
print 'Unknown Token:', token
|
||||||
|
self.first_unknown = False
|
||||||
self.tag_pop()
|
self.tag_pop()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ def generateBook(bookDir, raw, fixedimage):
|
|||||||
# print "first normal text page is", spage
|
# print "first normal text page is", spage
|
||||||
|
|
||||||
# get page height and width from first text page for use in stylesheet scaling
|
# get page height and width from first text page for use in stylesheet scaling
|
||||||
pname = 'page%04d.dat' % (pnum + 1)
|
pname = 'page%04d.dat' % (pnum - 1)
|
||||||
fname = os.path.join(pageDir,pname)
|
fname = os.path.join(pageDir,pname)
|
||||||
flat_xml = convert2xml.fromData(dict, fname)
|
flat_xml = convert2xml.fromData(dict, fname)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
# ineptepub.pyw, version 6.4
|
# ineptepub.pyw, version 6.5
|
||||||
# Copyright © 2009-2010 by i♥cabbages
|
# Copyright © 2009-2010 by i♥cabbages
|
||||||
|
|
||||||
# Released under the terms of the GNU General Public Licence, version 3
|
# Released under the terms of the GNU General Public Licence, version 3
|
||||||
@@ -41,13 +41,14 @@ from __future__ import with_statement
|
|||||||
# 6.2 - Handle UTF-8 file names inside an ePub, fix by Jose Luis
|
# 6.2 - Handle UTF-8 file names inside an ePub, fix by Jose Luis
|
||||||
# 6.3 - Add additional check on DER file sanity
|
# 6.3 - Add additional check on DER file sanity
|
||||||
# 6.4 - Remove erroneous check on DER file sanity
|
# 6.4 - Remove erroneous check on DER file sanity
|
||||||
|
# 6.5 - Completely remove erroneous check on DER file sanity
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Decrypt Adobe Digital Editions encrypted ePub books.
|
Decrypt Adobe Digital Editions encrypted ePub books.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__version__ = "6.4"
|
__version__ = "6.5"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@@ -316,11 +317,6 @@ def _load_crypto_pycrypto():
|
|||||||
key = [key.getChild(x).value for x in xrange(1, 4)]
|
key = [key.getChild(x).value for x in xrange(1, 4)]
|
||||||
key = [self.bytesToNumber(v) for v in key]
|
key = [self.bytesToNumber(v) for v in key]
|
||||||
self._rsa = _RSA.construct(key)
|
self._rsa = _RSA.construct(key)
|
||||||
# check if pointer is not NULL
|
|
||||||
try:
|
|
||||||
c = self._rsa.contents
|
|
||||||
except ValueError:
|
|
||||||
raise ADEPTError('Error parsing ADEPT user key DER')
|
|
||||||
|
|
||||||
def bytesToNumber(self, bytes):
|
def bytesToNumber(self, bytes):
|
||||||
total = 0L
|
total = 0L
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
# ineptpdf.pyw, version 8.0.3
|
# ineptpdf.pyw, version 8.0.4
|
||||||
# Copyright © 2009-2010 by i♥cabbages
|
# Copyright © 2009-2010 by i♥cabbages
|
||||||
|
|
||||||
# Released under the terms of the GNU General Public Licence, version 3
|
# Released under the terms of the GNU General Public Licence, version 3
|
||||||
@@ -56,6 +56,7 @@ from __future__ import with_statement
|
|||||||
# 8.0.1 - Broken Metadata fix.
|
# 8.0.1 - Broken Metadata fix.
|
||||||
# 8.0.2 - Add additional check on DER file sanity
|
# 8.0.2 - Add additional check on DER file sanity
|
||||||
# 8.0.3 - Remove erroneous check on DER file sanity
|
# 8.0.3 - Remove erroneous check on DER file sanity
|
||||||
|
# 8.0.4 - Completely remove erroneous check on DER file sanity
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -63,7 +64,7 @@ Decrypts Adobe ADEPT-encrypted PDF files.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__version__ = "8.0.3"
|
__version__ = "8.0.4"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@@ -387,11 +388,6 @@ def _load_crypto_pycrypto():
|
|||||||
key = [key.getChild(x).value for x in xrange(1, 4)]
|
key = [key.getChild(x).value for x in xrange(1, 4)]
|
||||||
key = [self.bytesToNumber(v) for v in key]
|
key = [self.bytesToNumber(v) for v in key]
|
||||||
self._rsa = _RSA.construct(key)
|
self._rsa = _RSA.construct(key)
|
||||||
# check if pointer is not NULL
|
|
||||||
try:
|
|
||||||
c = self._rsa.contents
|
|
||||||
except ValueError:
|
|
||||||
raise ADEPTError('Error parsing ADEPT user key DER')
|
|
||||||
|
|
||||||
def bytesToNumber(self, bytes):
|
def bytesToNumber(self, bytes):
|
||||||
total = 0L
|
total = 0L
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -448,6 +448,8 @@ class MobiBook:
|
|||||||
goodpids.append(pid[0:-2])
|
goodpids.append(pid[0:-2])
|
||||||
elif len(pid)==8:
|
elif len(pid)==8:
|
||||||
goodpids.append(pid)
|
goodpids.append(pid)
|
||||||
|
else:
|
||||||
|
print u"Warning: PID {0} has wrong number of digits".format(pid)
|
||||||
|
|
||||||
if self.crypto_type == 1:
|
if self.crypto_type == 1:
|
||||||
t1_keyvec = 'QDCVEPMU675RUBSZ'
|
t1_keyvec = 'QDCVEPMU675RUBSZ'
|
||||||
@@ -530,7 +532,7 @@ def cli_main():
|
|||||||
stripped_file = getUnencryptedBook(infile, pidlist)
|
stripped_file = getUnencryptedBook(infile, pidlist)
|
||||||
file(outfile, 'wb').write(stripped_file)
|
file(outfile, 'wb').write(stripped_file)
|
||||||
except DrmException, e:
|
except DrmException, e:
|
||||||
print u"MobiDeDRM v{0} Error: {0:s}".format(__version__,e.args[0])
|
print u"MobiDeDRM v{0} Error: {1:s}".format(__version__,e.args[0])
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -9,8 +9,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
# Released under the terms of the GNU General Public Licence, version 3
|
# Released under the terms of the GNU General Public Licence, version 3
|
||||||
# <http://www.gnu.org/licenses/>
|
# <http://www.gnu.org/licenses/>
|
||||||
#
|
#
|
||||||
# Requires Calibre version 0.7.55 or higher.
|
|
||||||
#
|
|
||||||
# All credit given to i♥cabbages and The Dark Reverser for the original standalone scripts.
|
# All credit given to i♥cabbages and The Dark Reverser for the original standalone scripts.
|
||||||
# We had the much easier job of converting them to a calibre plugin.
|
# We had the much easier job of converting them to a calibre plugin.
|
||||||
#
|
#
|
||||||
@@ -48,6 +46,9 @@ __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
|
||||||
|
# 6.4.1 - Fix for some new tags in Topaz ebooks.
|
||||||
|
# 6.4.2 - Fix for more new tags in Topaz ebooks and very small Topaz ebooks
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -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, 2)
|
||||||
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'
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ class PageParser(object):
|
|||||||
self.id = os.path.basename(filename).replace('.dat','')
|
self.id = os.path.basename(filename).replace('.dat','')
|
||||||
self.dict = dict
|
self.dict = dict
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
|
self.first_unknown = True
|
||||||
self.flat_xml = flat_xml
|
self.flat_xml = flat_xml
|
||||||
self.tagpath = []
|
self.tagpath = []
|
||||||
self.doc = []
|
self.doc = []
|
||||||
@@ -262,6 +263,9 @@ class PageParser(object):
|
|||||||
'img.w' : (1, 'scalar_number', 0, 0),
|
'img.w' : (1, 'scalar_number', 0, 0),
|
||||||
'img.src' : (1, 'scalar_number', 0, 0),
|
'img.src' : (1, 'scalar_number', 0, 0),
|
||||||
'img.color_src' : (1, 'scalar_number', 0, 0),
|
'img.color_src' : (1, 'scalar_number', 0, 0),
|
||||||
|
'img.gridSize' : (1, 'scalar_number', 0, 0),
|
||||||
|
'img.gridBottomCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'img.gridTopCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'img.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
'img.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'img.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
'img.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'img.image_type' : (1, 'scalar_number', 0, 0),
|
'img.image_type' : (1, 'scalar_number', 0, 0),
|
||||||
@@ -313,11 +317,16 @@ class PageParser(object):
|
|||||||
'span.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
'span.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
||||||
'span.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
'span.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
|
||||||
'extratokens' : (1, 'snippets', 1, 0),
|
'extratokens' : (1, 'snippets', 1, 0),
|
||||||
'extratokens.class' : (1, 'scalar_text', 0, 0),
|
'extratokens.class' : (1, 'scalar_text', 0, 0),
|
||||||
'extratokens.type' : (1, 'scalar_text', 0, 0),
|
'extratokens.type' : (1, 'scalar_text', 0, 0),
|
||||||
'extratokens.firstGlyph' : (1, 'scalar_number', 0, 0),
|
'extratokens.firstGlyph' : (1, 'scalar_number', 0, 0),
|
||||||
'extratokens.lastGlyph' : (1, 'scalar_number', 0, 0),
|
'extratokens.lastGlyph' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridSize' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridBottomCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridTopCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridBeginCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
'extratokens.gridEndCenter' : (1, 'scalar_number', 0, 0),
|
||||||
|
|
||||||
'glyph.h' : (1, 'number', 0, 0),
|
'glyph.h' : (1, 'number', 0, 0),
|
||||||
'glyph.w' : (1, 'number', 0, 0),
|
'glyph.w' : (1, 'number', 0, 0),
|
||||||
@@ -506,8 +515,9 @@ class PageParser(object):
|
|||||||
# or an out of sync condition
|
# or an out of sync condition
|
||||||
else:
|
else:
|
||||||
result = []
|
result = []
|
||||||
if (self.debug):
|
if (self.debug or self.first_unknown):
|
||||||
print 'Unknown Token:', token
|
print 'Unknown Token:', token
|
||||||
|
self.first_unknown = False
|
||||||
self.tag_pop()
|
self.tag_pop()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ def generateBook(bookDir, raw, fixedimage):
|
|||||||
# print "first normal text page is", spage
|
# print "first normal text page is", spage
|
||||||
|
|
||||||
# get page height and width from first text page for use in stylesheet scaling
|
# get page height and width from first text page for use in stylesheet scaling
|
||||||
pname = 'page%04d.dat' % (pnum + 1)
|
pname = 'page%04d.dat' % (pnum - 1)
|
||||||
fname = os.path.join(pageDir,pname)
|
fname = os.path.join(pageDir,pname)
|
||||||
flat_xml = convert2xml.fromData(dict, fname)
|
flat_xml = convert2xml.fromData(dict, fname)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
# ineptepub.pyw, version 6.4
|
# ineptepub.pyw, version 6.5
|
||||||
# Copyright © 2009-2010 by i♥cabbages
|
# Copyright © 2009-2010 by i♥cabbages
|
||||||
|
|
||||||
# Released under the terms of the GNU General Public Licence, version 3
|
# Released under the terms of the GNU General Public Licence, version 3
|
||||||
@@ -41,13 +41,14 @@ from __future__ import with_statement
|
|||||||
# 6.2 - Handle UTF-8 file names inside an ePub, fix by Jose Luis
|
# 6.2 - Handle UTF-8 file names inside an ePub, fix by Jose Luis
|
||||||
# 6.3 - Add additional check on DER file sanity
|
# 6.3 - Add additional check on DER file sanity
|
||||||
# 6.4 - Remove erroneous check on DER file sanity
|
# 6.4 - Remove erroneous check on DER file sanity
|
||||||
|
# 6.5 - Completely remove erroneous check on DER file sanity
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Decrypt Adobe Digital Editions encrypted ePub books.
|
Decrypt Adobe Digital Editions encrypted ePub books.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__version__ = "6.4"
|
__version__ = "6.5"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@@ -316,11 +317,6 @@ def _load_crypto_pycrypto():
|
|||||||
key = [key.getChild(x).value for x in xrange(1, 4)]
|
key = [key.getChild(x).value for x in xrange(1, 4)]
|
||||||
key = [self.bytesToNumber(v) for v in key]
|
key = [self.bytesToNumber(v) for v in key]
|
||||||
self._rsa = _RSA.construct(key)
|
self._rsa = _RSA.construct(key)
|
||||||
# check if pointer is not NULL
|
|
||||||
try:
|
|
||||||
c = self._rsa.contents
|
|
||||||
except ValueError:
|
|
||||||
raise ADEPTError('Error parsing ADEPT user key DER')
|
|
||||||
|
|
||||||
def bytesToNumber(self, bytes):
|
def bytesToNumber(self, bytes):
|
||||||
total = 0L
|
total = 0L
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
# ineptpdf.pyw, version 8.0.3
|
# ineptpdf.pyw, version 8.0.4
|
||||||
# Copyright © 2009-2010 by i♥cabbages
|
# Copyright © 2009-2010 by i♥cabbages
|
||||||
|
|
||||||
# Released under the terms of the GNU General Public Licence, version 3
|
# Released under the terms of the GNU General Public Licence, version 3
|
||||||
@@ -56,6 +56,7 @@ from __future__ import with_statement
|
|||||||
# 8.0.1 - Broken Metadata fix.
|
# 8.0.1 - Broken Metadata fix.
|
||||||
# 8.0.2 - Add additional check on DER file sanity
|
# 8.0.2 - Add additional check on DER file sanity
|
||||||
# 8.0.3 - Remove erroneous check on DER file sanity
|
# 8.0.3 - Remove erroneous check on DER file sanity
|
||||||
|
# 8.0.4 - Completely remove erroneous check on DER file sanity
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -63,7 +64,7 @@ Decrypts Adobe ADEPT-encrypted PDF files.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__version__ = "8.0.3"
|
__version__ = "8.0.4"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@@ -387,11 +388,6 @@ def _load_crypto_pycrypto():
|
|||||||
key = [key.getChild(x).value for x in xrange(1, 4)]
|
key = [key.getChild(x).value for x in xrange(1, 4)]
|
||||||
key = [self.bytesToNumber(v) for v in key]
|
key = [self.bytesToNumber(v) for v in key]
|
||||||
self._rsa = _RSA.construct(key)
|
self._rsa = _RSA.construct(key)
|
||||||
# check if pointer is not NULL
|
|
||||||
try:
|
|
||||||
c = self._rsa.contents
|
|
||||||
except ValueError:
|
|
||||||
raise ADEPTError('Error parsing ADEPT user key DER')
|
|
||||||
|
|
||||||
def bytesToNumber(self, bytes):
|
def bytesToNumber(self, bytes):
|
||||||
total = 0L
|
total = 0L
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -448,6 +448,8 @@ class MobiBook:
|
|||||||
goodpids.append(pid[0:-2])
|
goodpids.append(pid[0:-2])
|
||||||
elif len(pid)==8:
|
elif len(pid)==8:
|
||||||
goodpids.append(pid)
|
goodpids.append(pid)
|
||||||
|
else:
|
||||||
|
print u"Warning: PID {0} has wrong number of digits".format(pid)
|
||||||
|
|
||||||
if self.crypto_type == 1:
|
if self.crypto_type == 1:
|
||||||
t1_keyvec = 'QDCVEPMU675RUBSZ'
|
t1_keyvec = 'QDCVEPMU675RUBSZ'
|
||||||
@@ -530,7 +532,7 @@ def cli_main():
|
|||||||
stripped_file = getUnencryptedBook(infile, pidlist)
|
stripped_file = getUnencryptedBook(infile, pidlist)
|
||||||
file(outfile, 'wb').write(stripped_file)
|
file(outfile, 'wb').write(stripped_file)
|
||||||
except DrmException, e:
|
except DrmException, e:
|
||||||
print u"MobiDeDRM v{0} Error: {0:s}".format(__version__,e.args[0])
|
print u"MobiDeDRM v{0} Error: {1:s}".format(__version__,e.args[0])
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Version 6.3.5 January 2016
|
# Version 3.2.0 January 2016
|
||||||
# Update for latest version of Windows Desktop app.
|
# Update for latest version of Windows Desktop app.
|
||||||
# Support Kobo devices in the command line version.
|
# Support Kobo devices in the command line version.
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user