Making sure files and versions are consistent
This commit is contained in:
parent
5eb3338423
commit
92ce0396fe
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
# adobekey.pyw, version 5.7
|
# adobekey.pyw, version 6.0
|
||||||
# Copyright © 2009-2010 i♥cabbages
|
# Copyright © 2009-2010 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
|
||||||
# <http://www.gnu.org/licenses/>
|
# <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
# Modified 2010–2013 by some_updates, DiapDealer and Apprentice Alf
|
# Modified 2010–2016 by several people
|
||||||
|
|
||||||
# Windows users: Before running this program, you must first install Python.
|
# Windows users: Before running this program, you must first install Python.
|
||||||
# We recommend ActiveState Python 2.7.X for Windows (x86) from
|
# We recommend ActiveState Python 2.7.X for Windows (x86) from
|
||||||
|
|
|
@ -57,6 +57,7 @@ from __future__ import with_statement
|
||||||
# 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
|
# 8.0.4 - Completely remove erroneous check on DER file sanity
|
||||||
|
# 8.0.5 - Do not process DRM-free documents
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -64,7 +65,7 @@ Decrypts Adobe ADEPT-encrypted PDF files.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__version__ = "8.0.4"
|
__version__ = "8.0.5"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
@ -1468,6 +1469,7 @@ class PDFDocument(object):
|
||||||
if not self.encryption:
|
if not self.encryption:
|
||||||
self.is_printable = self.is_modifiable = self.is_extractable = True
|
self.is_printable = self.is_modifiable = self.is_extractable = True
|
||||||
self.ready = True
|
self.ready = True
|
||||||
|
raise PDFEncryptionError('Document is not encrypted.')
|
||||||
return
|
return
|
||||||
(docid, param) = self.encryption
|
(docid, param) = self.encryption
|
||||||
type = literal_name(param['Filter'])
|
type = literal_name(param['Filter'])
|
||||||
|
@ -2180,11 +2182,11 @@ def decryptBook(userkey, inpath, outpath):
|
||||||
if RSA is None:
|
if RSA is None:
|
||||||
raise ADEPTError(u"PyCrypto or OpenSSL must be installed.")
|
raise ADEPTError(u"PyCrypto or OpenSSL must be installed.")
|
||||||
with open(inpath, 'rb') as inf:
|
with open(inpath, 'rb') as inf:
|
||||||
try:
|
#try:
|
||||||
serializer = PDFSerializer(inf, userkey)
|
serializer = PDFSerializer(inf, userkey)
|
||||||
except:
|
#except:
|
||||||
print u"Error serializing pdf {0}. Probably wrong key.".format(os.path.basename(inpath))
|
# print u"Error serializing pdf {0}. Probably wrong key.".format(os.path.basename(inpath))
|
||||||
return 2
|
# return 2
|
||||||
# hope this will fix the 'bad file descriptor' problem
|
# hope this will fix the 'bad file descriptor' problem
|
||||||
with open(outpath, 'wb') as outf:
|
with open(outpath, 'wb') as outf:
|
||||||
# help construct to make sure the method runs to the end
|
# help construct to make sure the method runs to the end
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
# adobekey.pyw, version 5.7
|
# adobekey.pyw, version 6.0
|
||||||
# Copyright © 2009-2010 i♥cabbages
|
# Copyright © 2009-2010 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
|
||||||
# <http://www.gnu.org/licenses/>
|
# <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
# Modified 2010–2013 by some_updates, DiapDealer and Apprentice Alf
|
# Modified 2010–2016 by several people
|
||||||
|
|
||||||
# Windows users: Before running this program, you must first install Python.
|
# Windows users: Before running this program, you must first install Python.
|
||||||
# We recommend ActiveState Python 2.7.X for Windows (x86) from
|
# We recommend ActiveState Python 2.7.X for Windows (x86) from
|
||||||
|
|
Binary file not shown.
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
# adobekey.pyw, version 5.7
|
# adobekey.pyw, version 6.0
|
||||||
# Copyright © 2009-2010 i♥cabbages
|
# Copyright © 2009-2010 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
|
||||||
# <http://www.gnu.org/licenses/>
|
# <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
# Modified 2010–2013 by some_updates, DiapDealer and Apprentice Alf
|
# Modified 2010–2016 by several people
|
||||||
|
|
||||||
# Windows users: Before running this program, you must first install Python.
|
# Windows users: Before running this program, you must first install Python.
|
||||||
# We recommend ActiveState Python 2.7.X for Windows (x86) from
|
# We recommend ActiveState Python 2.7.X for Windows (x86) from
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
# adobekey.pyw, version 5.7
|
# adobekey.pyw, version 6.0
|
||||||
# Copyright © 2009-2010 i♥cabbages
|
# Copyright © 2009-2010 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
|
||||||
# <http://www.gnu.org/licenses/>
|
# <http://www.gnu.org/licenses/>
|
||||||
|
|
||||||
# Modified 2010–2013 by some_updates, DiapDealer and Apprentice Alf
|
# Modified 2010–2016 by several people
|
||||||
|
|
||||||
# Windows users: Before running this program, you must first install Python.
|
# Windows users: Before running this program, you must first install Python.
|
||||||
# We recommend ActiveState Python 2.7.X for Windows (x86) from
|
# We recommend ActiveState Python 2.7.X for Windows (x86) from
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Version 3.2.2 October 2016
|
||||||
|
# Change to the way the new database version is handled.
|
||||||
|
#
|
||||||
|
# Version 3.2.1 September 2016
|
||||||
|
# Update for v4.0 of Windows Desktop app.
|
||||||
|
#
|
||||||
# Version 3.2.0 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.
|
||||||
|
@ -136,8 +142,8 @@
|
||||||
#
|
#
|
||||||
"""Manage all Kobo books, either encrypted or DRM-free."""
|
"""Manage all Kobo books, either encrypted or DRM-free."""
|
||||||
|
|
||||||
__version__ = '3.1.9'
|
__version__ = '3.2.2'
|
||||||
__about__ = u"Obok v{0}\nCopyright © 2012-2015 Physisticated et al.".format(__version__)
|
__about__ = u"Obok v{0}\nCopyright © 2012-2016 Physisticated et al.".format(__version__)
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
@ -152,6 +158,7 @@ import xml.etree.ElementTree as ET
|
||||||
import string
|
import string
|
||||||
import shutil
|
import shutil
|
||||||
import argparse
|
import argparse
|
||||||
|
import tempfile
|
||||||
|
|
||||||
can_parse_xml = True
|
can_parse_xml = True
|
||||||
try:
|
try:
|
||||||
|
@ -162,7 +169,7 @@ except ImportError:
|
||||||
# print u"Cannot find xml.etree, disabling extraction of serial numbers"
|
# print u"Cannot find xml.etree, disabling extraction of serial numbers"
|
||||||
|
|
||||||
# List of all known hash keys
|
# List of all known hash keys
|
||||||
KOBO_HASH_KEYS = ['88b3a2e13', 'XzUhGYdFp', 'NoCanLook']
|
KOBO_HASH_KEYS = ['88b3a2e13', 'XzUhGYdFp', 'NoCanLook','QJhwzAtXL']
|
||||||
|
|
||||||
class ENCRYPTIONError(Exception):
|
class ENCRYPTIONError(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -355,7 +362,18 @@ class KoboLibrary(object):
|
||||||
|
|
||||||
if (self.kobodir != u""):
|
if (self.kobodir != u""):
|
||||||
self.bookdir = os.path.join(self.kobodir, u"kepub")
|
self.bookdir = os.path.join(self.kobodir, u"kepub")
|
||||||
self.__sqlite = sqlite3.connect(kobodb)
|
# make a copy of the database in a temporary file
|
||||||
|
# so we can ensure it's not using WAL logging which sqlite3 can't do.
|
||||||
|
self.newdb = tempfile.NamedTemporaryFile(mode='wb', delete=False)
|
||||||
|
print self.newdb.name
|
||||||
|
olddb = open(kobodb, 'rb')
|
||||||
|
self.newdb.write(olddb.read(18))
|
||||||
|
self.newdb.write('\x01\x01')
|
||||||
|
olddb.read(2)
|
||||||
|
self.newdb.write(olddb.read())
|
||||||
|
olddb.close()
|
||||||
|
self.newdb.close()
|
||||||
|
self.__sqlite = sqlite3.connect(self.newdb.name)
|
||||||
self.__cursor = self.__sqlite.cursor()
|
self.__cursor = self.__sqlite.cursor()
|
||||||
self._userkeys = []
|
self._userkeys = []
|
||||||
self._books = []
|
self._books = []
|
||||||
|
@ -366,6 +384,8 @@ class KoboLibrary(object):
|
||||||
"""Closes the database used by the library."""
|
"""Closes the database used by the library."""
|
||||||
self.__cursor.close()
|
self.__cursor.close()
|
||||||
self.__sqlite.close()
|
self.__sqlite.close()
|
||||||
|
# delete the temporary copy of the database
|
||||||
|
os.remove(self.newdb.name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def userkeys (self):
|
def userkeys (self):
|
||||||
|
@ -558,12 +578,19 @@ class KoboFile(object):
|
||||||
Returns True if the content was checked, False if it was not
|
Returns True if the content was checked, False if it was not
|
||||||
checked."""
|
checked."""
|
||||||
if self.mimetype == 'application/xhtml+xml':
|
if self.mimetype == 'application/xhtml+xml':
|
||||||
if contents[:5]=="<?xml":
|
if contents[:5]=="<?xml" or contents[:8]=="\xef\xbb\xbf<?xml":
|
||||||
|
# utf-8
|
||||||
|
return True
|
||||||
|
elif contents[:14]=="\xfe\xff\x00<\x00?\x00x\x00m\x00l":
|
||||||
|
# utf-16BE
|
||||||
|
return True
|
||||||
|
elif contents[:14]=="\xff\xfe<\x00?\x00x\x00m\x00l\x00":
|
||||||
|
# utf-16LE
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print u"Bad XML: {0}".format(contents[:5])
|
print u"Bad XML: {0}".format(contents[:8])
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if self.mimetype == 'image/jpeg':
|
elif self.mimetype == 'image/jpeg':
|
||||||
if contents[:3] == '\xff\xd8\xff':
|
if contents[:3] == '\xff\xd8\xff':
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue