Update PDF to use Decimal instead of float to handle very precise numbers. Update for changes to ActiveState Python. Fix a few copyright dates. Update version to 6.5.4. Minor changes to obok script for stand-alone use.

This commit is contained in:
Apprentice Harper 2017-06-27 06:50:24 +01:00
parent 9bea20c7ab
commit 2042354788
23 changed files with 195 additions and 110 deletions

View File

@ -57,6 +57,7 @@ __docformat__ = 'restructuredtext en'
# 6.5.1 - Updated version number, added PDF check for DRM-free documents
# 6.5.2 - Another Topaz fix
# 6.5.3 - Warn about KFX files explicitly
# 6.5.4 - Mac App Fix, improve PDF decryption, handle latest tcl changes in ActivePython
"""
@ -64,7 +65,7 @@ Decrypt DRMed ebooks.
"""
PLUGIN_NAME = u"DeDRM"
PLUGIN_VERSION_TUPLE = (6, 5, 3)
PLUGIN_VERSION_TUPLE = (6, 5, 4)
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'

View File

@ -3,13 +3,14 @@
from __future__ import with_statement
# ignobleepub.pyw, version 3.8
# ignobleepub.pyw, version 4.1
# Copyright © 2009-2010 by i♥cabbages
# Released under the terms of the GNU General Public Licence, version 3
# <http://www.gnu.org/licenses/>
# Modified 20102013 by some_updates, DiapDealer and Apprentice Alf
# Modified 20152017 by Apprentice Harper
# Windows users: Before running this program, you must first install Python 2.6
# from <http://www.python.org/download/> and PyCrypto from
@ -35,13 +36,14 @@ from __future__ import with_statement
# 3.8 - Fixed to retain zip file metadata (e.g. file modification date)
# 3.9 - moved unicode_argv call inside main for Windows DeDRM compatibility
# 4.0 - Work if TkInter is missing
# 4.1 - Import tkFileDialog, don't assume something else will import it.
"""
Decrypt Barnes & Noble encrypted ePub books.
"""
__license__ = 'GPL v3'
__version__ = "4.0"
__version__ = "4.1"
import sys
import os
@ -337,6 +339,7 @@ def gui_main():
try:
import Tkinter
import Tkconstants
import tkFileDialog
import tkMessageBox
import traceback
except:

View File

@ -3,14 +3,14 @@
from __future__ import with_statement
# ineptepub.pyw, version 6.5
# ineptepub.pyw, version 6.6
# Copyright © 2009-2010 by i♥cabbages
# Released under the terms of the GNU General Public Licence, version 3
# <http://www.gnu.org/licenses/>
# Modified 20102013 by some_updates, DiapDealer and Apprentice Alf
# Modified 20152016 by Apprentice Harper
# Modified 20152017 by Apprentice Harper
# Windows users: Before running this program, you must first install Python 2.7
# from <http://www.python.org/download/> and PyCrypto from
@ -42,13 +42,14 @@ from __future__ import with_statement
# 6.3 - Add additional check on DER file sanity
# 6.4 - Remove erroneous check on DER file sanity
# 6.5 - Completely remove erroneous check on DER file sanity
# 6.6 - Import tkFileDialog, don't assume something else will import it.
"""
Decrypt Adobe Digital Editions encrypted ePub books.
"""
__license__ = 'GPL v3'
__version__ = "6.5"
__version__ = "6.6"
import sys
import os
@ -484,6 +485,7 @@ def gui_main():
try:
import Tkinter
import Tkconstants
import tkFileDialog
import tkMessageBox
import traceback
except:

View File

@ -3,14 +3,14 @@
from __future__ import with_statement
# ineptpdf.pyw, version 8.0.4
# ineptpdf.pyw, version 8.0.6
# Copyright © 2009-2010 by i♥cabbages
# Released under the terms of the GNU General Public Licence, version 3
# <http://www.gnu.org/licenses/>
# Modified 20102012 by some_updates, DiapDealer and Apprentice Alf
# Modified 2015-2016 by Apprentice Harper
# Modified 2015-2017 by Apprentice Harper
# Windows users: Before running this program, you must first install Python 2.7
# from <http://www.python.org/download/> and PyCrypto from
@ -58,6 +58,7 @@ from __future__ import with_statement
# 8.0.3 - Remove erroneous check on DER file sanity
# 8.0.4 - Completely remove erroneous check on DER file sanity
# 8.0.5 - Do not process DRM-free documents
# 8.0.6 - Replace use of float by Decimal for greater precision, and import tkFileDialog
"""
@ -65,7 +66,7 @@ Decrypts Adobe ADEPT-encrypted PDF files.
"""
__license__ = 'GPL v3'
__version__ = "8.0.5"
__version__ = "8.0.6"
import sys
import os
@ -73,6 +74,7 @@ import re
import zlib
import struct
import hashlib
from decimal import *
from itertools import chain, islice
import xml.etree.ElementTree as etree
@ -653,7 +655,7 @@ class PSBaseParser(object):
return (self.parse_number, j+1)
if c == '.':
self.token = c
return (self.parse_float, j+1)
return (self.parse_decimal, j+1)
if c.isalpha():
self.token = c
return (self.parse_keyword, j+1)
@ -718,20 +720,21 @@ class PSBaseParser(object):
c = s[j]
if c == '.':
self.token += c
return (self.parse_float, j+1)
return (self.parse_decimal, j+1)
try:
self.add_token(int(self.token))
except ValueError:
pass
return (self.parse_main, j)
def parse_float(self, s, i):
def parse_decimal(self, s, i):
m = END_NUMBER.search(s, i)
if not m:
self.token += s[i:]
return (self.parse_float, len(s))
return (self.parse_decimal, len(s))
j = m.start(0)
self.token += s[i:j]
self.add_token(float(self.token))
self.add_token(Decimal(self.token))
return (self.parse_main, j)
def parse_keyword(self, s, i):
@ -933,7 +936,7 @@ class PSStackParser(PSBaseParser):
(pos, token) = self.nexttoken()
##print (pos,token), (self.curtype, self.curstack)
if (isinstance(token, int) or
isinstance(token, float) or
isinstance(token, Decimal) or
isinstance(token, bool) or
isinstance(token, str) or
isinstance(token, PSLiteral)):
@ -1062,17 +1065,17 @@ def int_value(x):
return 0
return x
def float_value(x):
def decimal_value(x):
x = resolve1(x)
if not isinstance(x, float):
if not isinstance(x, Decimal):
if STRICT:
raise PDFTypeError('Float required: %r' % x)
raise PDFTypeError('Decimal required: %r' % x)
return 0.0
return x
def num_value(x):
x = resolve1(x)
if not (isinstance(x, int) or isinstance(x, float)):
if not (isinstance(x, int) or isinstance(x, Decimal)):
if STRICT:
raise PDFTypeError('Int or Float required: %r' % x)
return 0
@ -2142,7 +2145,11 @@ class PDFSerializer(object):
if self.last.isalnum():
self.write(' ')
self.write(str(obj).lower())
elif isinstance(obj, (int, long, float)):
elif isinstance(obj, (int, long)):
if self.last.isalnum():
self.write(' ')
self.write(str(obj))
elif isinstance(obj, Decimal):
if self.last.isalnum():
self.write(' ')
self.write(str(obj))
@ -2218,6 +2225,7 @@ def gui_main():
try:
import Tkinter
import Tkconstants
import tkFileDialog
import tkMessageBox
import traceback
except:

View File

@ -4,7 +4,7 @@
from __future__ import with_statement
# kindlekey.py
# Copyright © 2010-2016 by some_updates, Apprentice Alf and Apprentice Harper
# Copyright © 2010-2017 by some_updates, Apprentice Alf and Apprentice Harper
# Revision history:
# 1.0 - Kindle info file decryption, extracted from k4mobidedrm, etc.
@ -22,6 +22,7 @@ from __future__ import with_statement
# 2.1 - Fixed Kindle for PC encryption changes March 2016
# 2.2 - Fixes for Macs with bonded ethernet ports
# Also removed old .kinfo file support (pre-2011)
# 2.3 - Added more field names thanks to concavegit's KFX code.
"""
@ -29,7 +30,7 @@ Retrieve Kindle for PC/Mac user key.
"""
__license__ = 'GPL v3'
__version__ = '2.2'
__version__ = '2.3'
import sys, os, re
from struct import pack, unpack, unpack_from
@ -1010,8 +1011,11 @@ if iswindows:
'max_date',\
'SIGVERIF',\
'build_version',\
'SerialNumber',\
'UsernameHash',\
'kindle.directedid.info',\
'DSN'
]
DB = {}
with open(kInfoFile, 'rb') as infoReader:
data = infoReader.read()
@ -1447,6 +1451,10 @@ elif isosx:
'max_date',\
'SIGVERIF',\
'build_version',\
'SerialNumber',\
'UsernameHash',\
'kindle.directedid.info',\
'DSN'
]
with open(kInfoFile, 'rb') as infoReader:
filedata = infoReader.read()

View File

@ -29,8 +29,9 @@
# 6.5.1 - Version bump to match plugin & Mac app
# 6.5.2 - Fix for a new tag in Topaz ebooks
# 6.5.3 - Explicitly warn about KFX files
# 6.5.4 - PDF float fix.
__version__ = '6.5.3'
__version__ = '6.5.4'
import sys
import os, os.path

View File

@ -57,6 +57,7 @@ __docformat__ = 'restructuredtext en'
# 6.5.1 - Updated version number, added PDF check for DRM-free documents
# 6.5.2 - Another Topaz fix
# 6.5.3 - Warn about KFX files explicitly
# 6.5.4 - Mac App Fix, improve PDF decryption, handle latest tcl changes in ActivePython
"""
@ -64,7 +65,7 @@ Decrypt DRMed ebooks.
"""
PLUGIN_NAME = u"DeDRM"
PLUGIN_VERSION_TUPLE = (6, 5, 3)
PLUGIN_VERSION_TUPLE = (6, 5, 4)
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'

View File

@ -3,13 +3,14 @@
from __future__ import with_statement
# ignobleepub.pyw, version 3.8
# ignobleepub.pyw, version 4.1
# Copyright © 2009-2010 by i♥cabbages
# Released under the terms of the GNU General Public Licence, version 3
# <http://www.gnu.org/licenses/>
# Modified 20102013 by some_updates, DiapDealer and Apprentice Alf
# Modified 20152017 by Apprentice Harper
# Windows users: Before running this program, you must first install Python 2.6
# from <http://www.python.org/download/> and PyCrypto from
@ -35,13 +36,14 @@ from __future__ import with_statement
# 3.8 - Fixed to retain zip file metadata (e.g. file modification date)
# 3.9 - moved unicode_argv call inside main for Windows DeDRM compatibility
# 4.0 - Work if TkInter is missing
# 4.1 - Import tkFileDialog, don't assume something else will import it.
"""
Decrypt Barnes & Noble encrypted ePub books.
"""
__license__ = 'GPL v3'
__version__ = "4.0"
__version__ = "4.1"
import sys
import os
@ -337,6 +339,7 @@ def gui_main():
try:
import Tkinter
import Tkconstants
import tkFileDialog
import tkMessageBox
import traceback
except:

View File

@ -3,14 +3,14 @@
from __future__ import with_statement
# ineptepub.pyw, version 6.5
# ineptepub.pyw, version 6.6
# Copyright © 2009-2010 by i♥cabbages
# Released under the terms of the GNU General Public Licence, version 3
# <http://www.gnu.org/licenses/>
# Modified 20102013 by some_updates, DiapDealer and Apprentice Alf
# Modified 20152016 by Apprentice Harper
# Modified 20152017 by Apprentice Harper
# Windows users: Before running this program, you must first install Python 2.7
# from <http://www.python.org/download/> and PyCrypto from
@ -42,13 +42,14 @@ from __future__ import with_statement
# 6.3 - Add additional check on DER file sanity
# 6.4 - Remove erroneous check on DER file sanity
# 6.5 - Completely remove erroneous check on DER file sanity
# 6.6 - Import tkFileDialog, don't assume something else will import it.
"""
Decrypt Adobe Digital Editions encrypted ePub books.
"""
__license__ = 'GPL v3'
__version__ = "6.5"
__version__ = "6.6"
import sys
import os
@ -484,6 +485,7 @@ def gui_main():
try:
import Tkinter
import Tkconstants
import tkFileDialog
import tkMessageBox
import traceback
except:

View File

@ -3,14 +3,14 @@
from __future__ import with_statement
# ineptpdf.pyw, version 8.0.4
# ineptpdf.pyw, version 8.0.6
# Copyright © 2009-2010 by i♥cabbages
# Released under the terms of the GNU General Public Licence, version 3
# <http://www.gnu.org/licenses/>
# Modified 20102012 by some_updates, DiapDealer and Apprentice Alf
# Modified 2015-2016 by Apprentice Harper
# Modified 2015-2017 by Apprentice Harper
# Windows users: Before running this program, you must first install Python 2.7
# from <http://www.python.org/download/> and PyCrypto from
@ -58,6 +58,7 @@ from __future__ import with_statement
# 8.0.3 - Remove erroneous check on DER file sanity
# 8.0.4 - Completely remove erroneous check on DER file sanity
# 8.0.5 - Do not process DRM-free documents
# 8.0.6 - Replace use of float by Decimal for greater precision, and import tkFileDialog
"""
@ -65,7 +66,7 @@ Decrypts Adobe ADEPT-encrypted PDF files.
"""
__license__ = 'GPL v3'
__version__ = "8.0.5"
__version__ = "8.0.6"
import sys
import os
@ -73,6 +74,7 @@ import re
import zlib
import struct
import hashlib
from decimal import *
from itertools import chain, islice
import xml.etree.ElementTree as etree
@ -653,7 +655,7 @@ class PSBaseParser(object):
return (self.parse_number, j+1)
if c == '.':
self.token = c
return (self.parse_float, j+1)
return (self.parse_decimal, j+1)
if c.isalpha():
self.token = c
return (self.parse_keyword, j+1)
@ -718,20 +720,21 @@ class PSBaseParser(object):
c = s[j]
if c == '.':
self.token += c
return (self.parse_float, j+1)
return (self.parse_decimal, j+1)
try:
self.add_token(int(self.token))
except ValueError:
pass
return (self.parse_main, j)
def parse_float(self, s, i):
def parse_decimal(self, s, i):
m = END_NUMBER.search(s, i)
if not m:
self.token += s[i:]
return (self.parse_float, len(s))
return (self.parse_decimal, len(s))
j = m.start(0)
self.token += s[i:j]
self.add_token(float(self.token))
self.add_token(Decimal(self.token))
return (self.parse_main, j)
def parse_keyword(self, s, i):
@ -933,7 +936,7 @@ class PSStackParser(PSBaseParser):
(pos, token) = self.nexttoken()
##print (pos,token), (self.curtype, self.curstack)
if (isinstance(token, int) or
isinstance(token, float) or
isinstance(token, Decimal) or
isinstance(token, bool) or
isinstance(token, str) or
isinstance(token, PSLiteral)):
@ -1062,17 +1065,17 @@ def int_value(x):
return 0
return x
def float_value(x):
def decimal_value(x):
x = resolve1(x)
if not isinstance(x, float):
if not isinstance(x, Decimal):
if STRICT:
raise PDFTypeError('Float required: %r' % x)
raise PDFTypeError('Decimal required: %r' % x)
return 0.0
return x
def num_value(x):
x = resolve1(x)
if not (isinstance(x, int) or isinstance(x, float)):
if not (isinstance(x, int) or isinstance(x, Decimal)):
if STRICT:
raise PDFTypeError('Int or Float required: %r' % x)
return 0
@ -2142,7 +2145,11 @@ class PDFSerializer(object):
if self.last.isalnum():
self.write(' ')
self.write(str(obj).lower())
elif isinstance(obj, (int, long, float)):
elif isinstance(obj, (int, long)):
if self.last.isalnum():
self.write(' ')
self.write(str(obj))
elif isinstance(obj, Decimal):
if self.last.isalnum():
self.write(' ')
self.write(str(obj))
@ -2218,6 +2225,7 @@ def gui_main():
try:
import Tkinter
import Tkconstants
import tkFileDialog
import tkMessageBox
import traceback
except:

View File

@ -4,7 +4,7 @@
from __future__ import with_statement
# kindlekey.py
# Copyright © 2010-2016 by some_updates, Apprentice Alf and Apprentice Harper
# Copyright © 2010-2017 by some_updates, Apprentice Alf and Apprentice Harper
# Revision history:
# 1.0 - Kindle info file decryption, extracted from k4mobidedrm, etc.
@ -22,6 +22,7 @@ from __future__ import with_statement
# 2.1 - Fixed Kindle for PC encryption changes March 2016
# 2.2 - Fixes for Macs with bonded ethernet ports
# Also removed old .kinfo file support (pre-2011)
# 2.3 - Added more field names thanks to concavegit's KFX code.
"""
@ -29,7 +30,7 @@ Retrieve Kindle for PC/Mac user key.
"""
__license__ = 'GPL v3'
__version__ = '2.2'
__version__ = '2.3'
import sys, os, re
from struct import pack, unpack, unpack_from
@ -1010,8 +1011,11 @@ if iswindows:
'max_date',\
'SIGVERIF',\
'build_version',\
'SerialNumber',\
'UsernameHash',\
'kindle.directedid.info',\
'DSN'
]
DB = {}
with open(kInfoFile, 'rb') as infoReader:
data = infoReader.read()
@ -1447,6 +1451,10 @@ elif isosx:
'max_date',\
'SIGVERIF',\
'build_version',\
'SerialNumber',\
'UsernameHash',\
'kindle.directedid.info',\
'DSN'
]
with open(kInfoFile, 'rb') as infoReader:
filedata = infoReader.read()

View File

@ -57,6 +57,7 @@ __docformat__ = 'restructuredtext en'
# 6.5.1 - Updated version number, added PDF check for DRM-free documents
# 6.5.2 - Another Topaz fix
# 6.5.3 - Warn about KFX files explicitly
# 6.5.4 - Mac App Fix, improve PDF decryption, handle latest tcl changes in ActivePython
"""
@ -64,7 +65,7 @@ Decrypt DRMed ebooks.
"""
PLUGIN_NAME = u"DeDRM"
PLUGIN_VERSION_TUPLE = (6, 5, 3)
PLUGIN_VERSION_TUPLE = (6, 5, 4)
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'

View File

@ -3,13 +3,14 @@
from __future__ import with_statement
# ignobleepub.pyw, version 3.8
# ignobleepub.pyw, version 4.1
# Copyright © 2009-2010 by i♥cabbages
# Released under the terms of the GNU General Public Licence, version 3
# <http://www.gnu.org/licenses/>
# Modified 20102013 by some_updates, DiapDealer and Apprentice Alf
# Modified 20152017 by Apprentice Harper
# Windows users: Before running this program, you must first install Python 2.6
# from <http://www.python.org/download/> and PyCrypto from
@ -35,13 +36,14 @@ from __future__ import with_statement
# 3.8 - Fixed to retain zip file metadata (e.g. file modification date)
# 3.9 - moved unicode_argv call inside main for Windows DeDRM compatibility
# 4.0 - Work if TkInter is missing
# 4.1 - Import tkFileDialog, don't assume something else will import it.
"""
Decrypt Barnes & Noble encrypted ePub books.
"""
__license__ = 'GPL v3'
__version__ = "4.0"
__version__ = "4.1"
import sys
import os
@ -337,6 +339,7 @@ def gui_main():
try:
import Tkinter
import Tkconstants
import tkFileDialog
import tkMessageBox
import traceback
except:

View File

@ -3,14 +3,14 @@
from __future__ import with_statement
# ineptepub.pyw, version 6.5
# ineptepub.pyw, version 6.6
# Copyright © 2009-2010 by i♥cabbages
# Released under the terms of the GNU General Public Licence, version 3
# <http://www.gnu.org/licenses/>
# Modified 20102013 by some_updates, DiapDealer and Apprentice Alf
# Modified 20152016 by Apprentice Harper
# Modified 20152017 by Apprentice Harper
# Windows users: Before running this program, you must first install Python 2.7
# from <http://www.python.org/download/> and PyCrypto from
@ -42,13 +42,14 @@ from __future__ import with_statement
# 6.3 - Add additional check on DER file sanity
# 6.4 - Remove erroneous check on DER file sanity
# 6.5 - Completely remove erroneous check on DER file sanity
# 6.6 - Import tkFileDialog, don't assume something else will import it.
"""
Decrypt Adobe Digital Editions encrypted ePub books.
"""
__license__ = 'GPL v3'
__version__ = "6.5"
__version__ = "6.6"
import sys
import os
@ -484,6 +485,7 @@ def gui_main():
try:
import Tkinter
import Tkconstants
import tkFileDialog
import tkMessageBox
import traceback
except:

View File

@ -3,14 +3,14 @@
from __future__ import with_statement
# ineptpdf.pyw, version 8.0.4
# ineptpdf.pyw, version 8.0.6
# Copyright © 2009-2010 by i♥cabbages
# Released under the terms of the GNU General Public Licence, version 3
# <http://www.gnu.org/licenses/>
# Modified 20102012 by some_updates, DiapDealer and Apprentice Alf
# Modified 2015-2016 by Apprentice Harper
# Modified 2015-2017 by Apprentice Harper
# Windows users: Before running this program, you must first install Python 2.7
# from <http://www.python.org/download/> and PyCrypto from
@ -58,6 +58,7 @@ from __future__ import with_statement
# 8.0.3 - Remove erroneous check on DER file sanity
# 8.0.4 - Completely remove erroneous check on DER file sanity
# 8.0.5 - Do not process DRM-free documents
# 8.0.6 - Replace use of float by Decimal for greater precision, and import tkFileDialog
"""
@ -65,7 +66,7 @@ Decrypts Adobe ADEPT-encrypted PDF files.
"""
__license__ = 'GPL v3'
__version__ = "8.0.5"
__version__ = "8.0.6"
import sys
import os
@ -73,6 +74,7 @@ import re
import zlib
import struct
import hashlib
from decimal import *
from itertools import chain, islice
import xml.etree.ElementTree as etree
@ -653,7 +655,7 @@ class PSBaseParser(object):
return (self.parse_number, j+1)
if c == '.':
self.token = c
return (self.parse_float, j+1)
return (self.parse_decimal, j+1)
if c.isalpha():
self.token = c
return (self.parse_keyword, j+1)
@ -718,20 +720,21 @@ class PSBaseParser(object):
c = s[j]
if c == '.':
self.token += c
return (self.parse_float, j+1)
return (self.parse_decimal, j+1)
try:
self.add_token(int(self.token))
except ValueError:
pass
return (self.parse_main, j)
def parse_float(self, s, i):
def parse_decimal(self, s, i):
m = END_NUMBER.search(s, i)
if not m:
self.token += s[i:]
return (self.parse_float, len(s))
return (self.parse_decimal, len(s))
j = m.start(0)
self.token += s[i:j]
self.add_token(float(self.token))
self.add_token(Decimal(self.token))
return (self.parse_main, j)
def parse_keyword(self, s, i):
@ -933,7 +936,7 @@ class PSStackParser(PSBaseParser):
(pos, token) = self.nexttoken()
##print (pos,token), (self.curtype, self.curstack)
if (isinstance(token, int) or
isinstance(token, float) or
isinstance(token, Decimal) or
isinstance(token, bool) or
isinstance(token, str) or
isinstance(token, PSLiteral)):
@ -1062,17 +1065,17 @@ def int_value(x):
return 0
return x
def float_value(x):
def decimal_value(x):
x = resolve1(x)
if not isinstance(x, float):
if not isinstance(x, Decimal):
if STRICT:
raise PDFTypeError('Float required: %r' % x)
raise PDFTypeError('Decimal required: %r' % x)
return 0.0
return x
def num_value(x):
x = resolve1(x)
if not (isinstance(x, int) or isinstance(x, float)):
if not (isinstance(x, int) or isinstance(x, Decimal)):
if STRICT:
raise PDFTypeError('Int or Float required: %r' % x)
return 0
@ -2142,7 +2145,11 @@ class PDFSerializer(object):
if self.last.isalnum():
self.write(' ')
self.write(str(obj).lower())
elif isinstance(obj, (int, long, float)):
elif isinstance(obj, (int, long)):
if self.last.isalnum():
self.write(' ')
self.write(str(obj))
elif isinstance(obj, Decimal):
if self.last.isalnum():
self.write(' ')
self.write(str(obj))
@ -2218,6 +2225,7 @@ def gui_main():
try:
import Tkinter
import Tkconstants
import tkFileDialog
import tkMessageBox
import traceback
except:

View File

@ -4,7 +4,7 @@
from __future__ import with_statement
# kindlekey.py
# Copyright © 2010-2016 by some_updates, Apprentice Alf and Apprentice Harper
# Copyright © 2010-2017 by some_updates, Apprentice Alf and Apprentice Harper
# Revision history:
# 1.0 - Kindle info file decryption, extracted from k4mobidedrm, etc.
@ -22,6 +22,7 @@ from __future__ import with_statement
# 2.1 - Fixed Kindle for PC encryption changes March 2016
# 2.2 - Fixes for Macs with bonded ethernet ports
# Also removed old .kinfo file support (pre-2011)
# 2.3 - Added more field names thanks to concavegit's KFX code.
"""
@ -29,7 +30,7 @@ Retrieve Kindle for PC/Mac user key.
"""
__license__ = 'GPL v3'
__version__ = '2.2'
__version__ = '2.3'
import sys, os, re
from struct import pack, unpack, unpack_from
@ -1010,8 +1011,11 @@ if iswindows:
'max_date',\
'SIGVERIF',\
'build_version',\
'SerialNumber',\
'UsernameHash',\
'kindle.directedid.info',\
'DSN'
]
DB = {}
with open(kInfoFile, 'rb') as infoReader:
data = infoReader.read()
@ -1447,6 +1451,10 @@ elif isosx:
'max_date',\
'SIGVERIF',\
'build_version',\
'SerialNumber',\
'UsernameHash',\
'kindle.directedid.info',\
'DSN'
]
with open(kInfoFile, 'rb') as infoReader:
filedata = infoReader.read()

View File

@ -56,7 +56,7 @@ We strongly recommend renaming the DeDRM\_tools\_X.X.X.zip archive (after extrac
## The Windows Application
### I've installed ActiveState Python and PyCrypto, but the Windows application won't run. What have I done wrong?
Nothing. There's a bug in the current ActiveState Python Windows installer that puts the Tcl code in the wrong place. See [this comment of mine at ActiveState community](https://community.activestate.com/node/19090). Just move the Tcl code to the correct place manually and the Windows app should run.
Nothing. There's a bug in the some older ActiveState Python Windows installers that puts the Tcl code in the wrong place. See [this comment of mine at ActiveState community](https://community.activestate.com/node/19090). Just move the Tcl code to the correct place manually and the Windows app should run.
## The Macintosh Application
### I can't open the Macintosh Application. Some message about it not being signed or something.

Binary file not shown.

View File

@ -19,7 +19,7 @@ except NameError:
PLUGIN_NAME = 'Obok DeDRM'
PLUGIN_SAFE_NAME = PLUGIN_NAME.strip().lower().replace(' ', '_')
PLUGIN_DESCRIPTION = _('Removes DRM from Kobo kepubs and adds them to the library.')
PLUGIN_VERSION_TUPLE = (6, 5, 3)
PLUGIN_VERSION_TUPLE = (6, 5, 4)
PLUGIN_VERSION = '.'.join([str(x) for x in PLUGIN_VERSION_TUPLE])
HELPFILE_NAME = PLUGIN_SAFE_NAME + '_Help.htm'
PLUGIN_AUTHORS = 'Anon'

View File

@ -665,41 +665,16 @@ class KoboFile(object):
contents = contents[:-padding]
return contents
def cli_main():
description = __about__
epilog = u"Parsing of arguments failed."
parser = argparse.ArgumentParser(prog=sys.argv[0], description=description, epilog=epilog)
parser.add_argument('--devicedir', default='/media/KOBOeReader', help="directory of connected Kobo device")
args = vars(parser.parse_args())
serials = []
devicedir = u""
if args['devicedir']:
devicedir = args['devicedir']
lib = KoboLibrary(serials, devicedir)
for i, book in enumerate(lib.books):
print u"{0}: {1}".format(i + 1, book.title)
num_string = raw_input(u"Convert book number... ")
try:
num = int(num_string)
book = lib.books[num - 1]
except (ValueError, IndexError):
exit()
def decrypt_book(book, lib):
print u"Converting {0}".format(book.title)
zin = zipfile.ZipFile(book.filename, "r")
# make filename out of Unicode alphanumeric and whitespace equivalents from title
outname = u"{0}.epub".format(re.sub('[^\s\w]', '_', book.title, 0, re.UNICODE))
if (book.type == 'drm-free'):
print u"DRM-free book, conversion is not needed"
shutil.copyfile(book.filename, outname)
print u"Book saved as {0}".format(os.path.join(os.getcwd(), outname))
exit(0)
return 0
result = 1
for userkey in lib.userkeys:
print u"Trying key: {0}".format(userkey.encode('hex_codec'))
@ -722,13 +697,50 @@ def cli_main():
print u"Decryption failed."
zout.close()
os.remove(outname)
zin.close()
lib.close()
if result != 0:
print u"Could not decrypt book with any of the keys found."
return result
def cli_main():
description = __about__
epilog = u"Parsing of arguments failed."
parser = argparse.ArgumentParser(prog=sys.argv[0], description=description, epilog=epilog)
parser.add_argument('--devicedir', default='/media/KOBOeReader', help="directory of connected Kobo device")
parser.add_argument('--all', action='store_true', help="flag for converting all books on device")
args = vars(parser.parse_args())
serials = []
devicedir = u""
if args['devicedir']:
devicedir = args['devicedir']
lib = KoboLibrary(serials, devicedir)
if args['all']:
books = lib.books
else:
for i, book in enumerate(lib.books):
print u"{0}: {1}".format(i + 1, book.title)
print u"Or 'all'"
choice = raw_input(u"Convert book number... ")
if choice == u'all':
books = list(lib.books)
else:
try:
num = int(choice)
books = [lib.books[num - 1]]
except (ValueError, IndexError):
print u"Invalid choice. Exiting..."
exit()
results = [decrypt_book(book, lib) for book in books]
lib.close()
overall_result = all(result != 0 for result in results)
if overall_result != 0:
print u"Could not decrypt book with any of the keys found."
return overall_result
if __name__ == '__main__':
sys.stdout=SafeUnbuffered(sys.stdout)
sys.stderr=SafeUnbuffered(sys.stderr)

View File

@ -4,7 +4,7 @@
from __future__ import with_statement
# kindlekey.py
# Copyright © 2010-2016 by some_updates, Apprentice Alf and Apprentice Harper
# Copyright © 2010-2017 by some_updates, Apprentice Alf and Apprentice Harper
# Revision history:
# 1.0 - Kindle info file decryption, extracted from k4mobidedrm, etc.
@ -22,6 +22,7 @@ from __future__ import with_statement
# 2.1 - Fixed Kindle for PC encryption changes March 2016
# 2.2 - Fixes for Macs with bonded ethernet ports
# Also removed old .kinfo file support (pre-2011)
# 2.3 - Added more field names thanks to concavegit's KFX code.
"""
@ -29,7 +30,7 @@ Retrieve Kindle for PC/Mac user key.
"""
__license__ = 'GPL v3'
__version__ = '2.2'
__version__ = '2.3'
import sys, os, re
from struct import pack, unpack, unpack_from
@ -1010,8 +1011,11 @@ if iswindows:
'max_date',\
'SIGVERIF',\
'build_version',\
'SerialNumber',\
'UsernameHash',\
'kindle.directedid.info',\
'DSN'
]
DB = {}
with open(kInfoFile, 'rb') as infoReader:
data = infoReader.read()
@ -1447,6 +1451,10 @@ elif isosx:
'max_date',\
'SIGVERIF',\
'build_version',\
'SerialNumber',\
'UsernameHash',\
'kindle.directedid.info',\
'DSN'
]
with open(kInfoFile, 'rb') as infoReader:
filedata = infoReader.read()

View File

@ -19,9 +19,9 @@ These tools do NOT work with Apple's iBooks FairPlay DRM (see end of this file.)
* With Kindle for PC/Mac 1.19 and later, Amazon included support for their new KFX format which uses a new DRM scheme that these tools cannot remove. Using 1.17 or earlier prevents downloads of the new format.
** Some later Kindles support Amazon's new KFX format which uses a new DRM scheme that these tools cannot remove. To avoid this problem, instead of using files downloaded directly to your Kindle, download from Amazon's web site 'for transfer via USB'. This will give you an older format file that the tools can decrypt.
** Some later Kindles support Amazon's new KFX format which uses a new DRM scheme that these tools cannot remove. To avoid this problem, instead of using files downloaded directly to your Kindle, download from Amazon's web site 'for transfer via USB'. This will give you an older format file that the tools can decrypt. See also the FAQ entry about this.
*** With Adobe Digital Editions 3.0 and later, Adobe have introduced a new, optional, DRM scheme. To avoid this new scheme, you should use Adobe Digital Editions 2.0.1. Some books are required to use the new DRM scheme and so will not download with ADE 2.0.1. If you still want such a book, you will need to use ADE 3.0 or later to download it, but you should remember that no tools to remove Adobe's new DRM scheme exist as of April 2017.
*** With Adobe Digital Editions 3.0 and later, Adobe have introduced a new, optional, DRM scheme. To avoid this new scheme, you should use Adobe Digital Editions 2.0.1. Some books are required to use the new DRM scheme and so will not download with ADE 2.0.1. If you still want such a book, you will need to use ADE 3.0 or later to download it, but you should remember that no tools to remove Adobe's new DRM scheme exist as of June 2017.
About the tools
---------------
@ -96,8 +96,6 @@ http://www.activestate.com/activepython/downloads
We do **NOT** recommend the version of Python from python.org as it is missing various Windows specific libraries, does not install the Tk Widget kit (for graphical user interfaces) by default, and does not properly update the system PATH environment variable. Therefore using the default python.org build on Windows is simply an exercise in frustration for most Windows users.
Note that currently (October 2016) ActiveState Python puts the tcl library in the wrong place, and it needs to be manually moved. See this thread at activestate.com for the latest information: https://community.activestate.com/node/19090
In addition, Windows Users need PyCrypto:
There are many places to get PyCrypto installers for Windows. One such place is: