Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to decrypt TPZ file #1823

Open
zwhitten opened this issue Aug 28, 2021 · 9 comments
Open

Fails to decrypt TPZ file #1823

zwhitten opened this issue Aug 28, 2021 · 9 comments

Comments

@zwhitten
Copy link

Calibre: 5.26
DeDRM: 7.2.1

Logs:

DeDRM v7.2.1: Trying to decrypt A Guide to the Bodhisattva Way of Life.tpz
Using Library AlfCrypto Python
Using Library AlfCrypto Python
Decrypting Topaz ebook: A Guide to the Bodhisattva Way of Life
Found 4 keys to try after 0.2 seconds
Trying: b'+bOSXmHV'
DeDRM v7.2.1: Failed to decrypt with error: ord() expected string of length 1, but int found
DeDRM v7.2.1: Looking for new default Kindle Key after 0.2 seconds
No k4Mac kindle-info/rainier/kinf2011 files have been found.
DeDRM v7.2.1: Ultimately failed to decrypt after 0.2 seconds. Read the FAQs at Harper's repository: http
s://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
[12.99] splash screen hidden
[12.99] Started up in 12.99 seconds with 6272 books
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 540, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.sta
rttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 238, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.topazextract", line 352, in processBook
    bookKeys+=decryptDkeyRecords(data,pid)
  File "calibre_plugins.dedrm.topazextract", line 192, in decryptDkeyRecords
    key = decryptDkeyRecord(data[1:length+1],PID)
  File "calibre_plugins.dedrm.topazextract", line 174, in decryptDkeyRecord
    record = decryptRecord(data,PID)
  File "calibre_plugins.dedrm.topazextract", line 169, in decryptRecord
    ctx = topazCryptoInit(PID)
  File "calibre_plugins.dedrm.topazextract", line 144, in topazCryptoInit
    return Topaz_Cipher().ctx_init(key)
  File "calibre_plugins.dedrm.alfcrypto", line 211, in ctx_init
    keyByte = ord(keyChar)
TypeError: ord() expected string of length 1, but int found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre/customize/ui.py", line 176, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 633, in run
    decrypted_ebook = self.KindleMobiDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 583, in KindleMobiDecrypt
    raise DeDRMError("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Har
per's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAM
E, PLUGIN_VERSION,time.time()-self.starttime))
calibre_plugins.dedrm.DeDRMError: DeDRM v7.2.1: Ultimately failed to decrypt after 0.2 seconds. Read the
 FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
Running file type plugin GetFileName failed with traceback:
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 176, in _run_filetype_plugins
  File "calibre_plugins.getfilename.__init__", line 108, in run
    json.dump (dictio_aux, file)
  File "json/__init__.py", line 180, in dump
TypeError: a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 433, in get_file_type_metadata
  File "calibre/customize/builtins.py", line 416, in get_metadata
  File "calibre/ebooks/metadata/topaz.py", line 378, in get_metadata
  File "calibre/ebooks/metadata/topaz.py", line 114, in __init__
ValueError: '/Users/zwhitten/Downloads/A Guide to the Bodhisattva Way of Life.tpz': Invalid Topaz format
 - no metadata record
(END)
@ableeker
Copy link
Contributor

@zwhitten This looks similar to issue #1788. Could you try the version of the plug-in in that issue?

@zwhitten
Copy link
Author

zwhitten commented Aug 29, 2021

@ableeker still failed with that version as well

DeDRM v7.2.1: Trying to decrypt A Guide to the Bodhisattva Way of Life.tpz
Using Library AlfCrypto Python
Using Library AlfCrypto Python
Decrypting Topaz ebook: A Guide to the Bodhisattva Way of Life
Found 4 keys to try after 0.1 seconds
Trying: b'+bOSXmHV'
DeDRM v7.2.1: Failed to decrypt with error: ord() expected string of length 1, but int found
DeDRM v7.2.1: Looking for new default Kindle Key after 0.1 seconds
No k4Mac kindle-info/rainier/kinf2011 files have been found.
DeDRM v7.2.1: Ultimately failed to decrypt after 0.1 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
[6.19] splash screen hidden
[6.19] Started up in 6.19 seconds with 6274 books
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 540, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 238, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.topazextract", line 354, in processBook
    bookKeys+=decryptDkeyRecords(data,pid)
  File "calibre_plugins.dedrm.topazextract", line 192, in decryptDkeyRecords
    key = decryptDkeyRecord(data[1:length+1],PID)
  File "calibre_plugins.dedrm.topazextract", line 174, in decryptDkeyRecord
    record = decryptRecord(data,PID)
  File "calibre_plugins.dedrm.topazextract", line 169, in decryptRecord
    ctx = topazCryptoInit(PID)
  File "calibre_plugins.dedrm.topazextract", line 144, in topazCryptoInit
    return Topaz_Cipher().ctx_init(key)
  File "calibre_plugins.dedrm.alfcrypto", line 211, in ctx_init
    keyByte = ord(keyChar)
TypeError: ord() expected string of length 1, but int found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre/customize/ui.py", line 176, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 633, in run
    decrypted_ebook = self.KindleMobiDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 583, in KindleMobiDecrypt
    raise DeDRMError("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
calibre_plugins.dedrm.DeDRMError: DeDRM v7.2.1: Ultimately failed to decrypt after 0.1 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
Running file type plugin GetFileName failed with traceback:
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 176, in _run_filetype_plugins
  File "calibre_plugins.getfilename.__init__", line 108, in run
    json.dump (dictio_aux, file)
  File "json/__init__.py", line 180, in dump
TypeError: a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 433, in get_file_type_metadata
  File "calibre/customize/builtins.py", line 416, in get_metadata
  File "calibre/ebooks/metadata/topaz.py", line 378, in get_metadata
  File "calibre/ebooks/metadata/topaz.py", line 114, in __init__
ValueError: '/Users/zwhitten/Downloads/A Guide to the Bodhisattva Way of Life.tpz': Invalid Topaz format - no metadata record
Prefs:  {'SchemaVersion': '0.3', 'configured': True, 'date_col': '', 'ext_col': '', 'nom_col': '', 'opc_name': '', 'path_col': ''}
Prefs:  {'SchemaVersion': '0.3', 'configured': True, 'date_col': '', 'ext_col': '', 'nom_col': '', 'opc_name': '', 'path_col': ''}
Prefs:  {'SchemaVersion': '0.3', 'configured': True, 'date_col': '', 'ext_col': '', 'nom_col': '', 'opc_name': '', 'path_col': ''}
Prefs:  {'SchemaVersion': '0.3', 'configured': True, 'date_col': '', 'ext_col': '', 'nom_col': '', 'opc_name': '', 'path_col': ''}
Prefs:  {'SchemaVersion': '0.3', 'configured': True, 'date_col': '', 'ext_col': '', 'nom_col': '', 'opc_name': '', 'path_col': ''}
Added A Guide to the Bodhisattva Way of Life to db in: 0.1
Added 1 books in 4.0 seconds

@ableeker
Copy link
Contributor

ableeker commented Sep 1, 2021

@zwhitten Another attempt. Does this version work?

DeDRM_plugin.zip

@zwhitten
Copy link
Author

zwhitten commented Sep 2, 2021

@ableeker Fails with that version as well

DeDRM v7.2.1: Trying to decrypt A Guide to the Bodhisattva Way of Life.tpz
Using Library AlfCrypto Python
Using Library AlfCrypto Python
Decrypting Topaz ebook: A Guide to the Bodhisattva Way of Life
Found 4 keys to try after 0.1 seconds
Trying: b'o8JIgsmv'
DeDRM v7.2.1: Failed to decrypt with error: ord() expected string of length 1, but int found
DeDRM v7.2.1: Looking for new default Kindle Key after 0.1 seconds
No k4Mac kindle-info/rainier/kinf2011 files have been found.
DeDRM v7.2.1: Ultimately failed to decrypt after 0.1 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
[5.59] splash screen hidden
[5.59] Started up in 5.59 seconds with 6316 books
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 540, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 238, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.topazextract", line 356, in processBook
    bookKeys+=decryptDkeyRecords(data,pid)
  File "calibre_plugins.dedrm.topazextract", line 194, in decryptDkeyRecords
    key = decryptDkeyRecord(data[1:length+1],PID)
  File "calibre_plugins.dedrm.topazextract", line 176, in decryptDkeyRecord
    record = decryptRecord(data,PID)
  File "calibre_plugins.dedrm.topazextract", line 171, in decryptRecord
    ctx = topazCryptoInit(PID)
  File "calibre_plugins.dedrm.topazextract", line 146, in topazCryptoInit
    return Topaz_Cipher().ctx_init(key)
  File "calibre_plugins.dedrm.alfcrypto", line 211, in ctx_init
    keyByte = ord(keyChar)
TypeError: ord() expected string of length 1, but int found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre/customize/ui.py", line 176, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 633, in run
    decrypted_ebook = self.KindleMobiDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 583, in KindleMobiDecrypt
    raise DeDRMError("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
calibre_plugins.dedrm.DeDRMError: DeDRM v7.2.1: Ultimately failed to decrypt after 0.1 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
Running file type plugin GetFileName failed with traceback:
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 176, in _run_filetype_plugins
  File "calibre_plugins.getfilename.__init__", line 108, in run
    json.dump (dictio_aux, file)
  File "json/__init__.py", line 180, in dump
TypeError: a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 433, in get_file_type_metadata
  File "calibre/customize/builtins.py", line 416, in get_metadata
  File "calibre/ebooks/metadata/topaz.py", line 378, in get_metadata
  File "calibre/ebooks/metadata/topaz.py", line 114, in __init__
ValueError: '/Users/zwhitten/Downloads/A Guide to the Bodhisattva Way of Life.tpz': Invalid Topaz format - no metadata record
DeDRM v7.2.1: Trying to decrypt A Guide to the Bodhisattva Way of Life - Unknown.tpz
Using Library AlfCrypto Python
Using Library AlfCrypto Python
Decrypting Topaz ebook: A Guide to the Bodhisattva Way of Life
Found 4 keys to try after 0.1 seconds
Trying: b'E1ZVDLM*'
DeDRM v7.2.1: Failed to decrypt with error: ord() expected string of length 1, but int found
DeDRM v7.2.1: Looking for new default Kindle Key after 0.1 seconds
No k4Mac kindle-info/rainier/kinf2011 files have been found.
DeDRM v7.2.1: Ultimately failed to decrypt after 0.1 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
Prefs:  {'SchemaVersion': '0.3', 'configured': True, 'date_col': '', 'ext_col': '', 'nom_col': '', 'opc_name': '', 'path_col': ''}
Prefs:  {'SchemaVersion': '0.3', 'configured': True, 'date_col': '', 'ext_col': '', 'nom_col': '', 'opc_name': '', 'path_col': ''}
Prefs:  {'SchemaVersion': '0.3', 'configured': True, 'date_col': '', 'ext_col': '', 'nom_col': '', 'opc_name': '', 'path_col': ''}
Prefs:  {'SchemaVersion': '0.3', 'configured': True, 'date_col': '', 'ext_col': '', 'nom_col': '', 'opc_name': '', 'path_col': ''}
Prefs:  {'SchemaVersion': '0.3', 'configured': True, 'date_col': '', 'ext_col': '', 'nom_col': '', 'opc_name': '', 'path_col': ''}
Added A Guide to the Bodhisattva Way of Life to db in: 0.1
Added 1 books in 3.2 seconds
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "calibre_plugins.dedrm.__init__", line 540, in KindleMobiDecrypt
    book = k4mobidedrm.GetDecryptedBook(path_to_ebook,kindleDatabases,androidFiles,serials,pids,self.starttime)
  File "calibre_plugins.dedrm.k4mobidedrm", line 238, in GetDecryptedBook
    mb.processBook(totalpids)
  File "calibre_plugins.dedrm.topazextract", line 356, in processBook
    bookKeys+=decryptDkeyRecords(data,pid)
  File "calibre_plugins.dedrm.topazextract", line 194, in decryptDkeyRecords
    key = decryptDkeyRecord(data[1:length+1],PID)
  File "calibre_plugins.dedrm.topazextract", line 176, in decryptDkeyRecord
    record = decryptRecord(data,PID)
  File "calibre_plugins.dedrm.topazextract", line 171, in decryptRecord
    ctx = topazCryptoInit(PID)
  File "calibre_plugins.dedrm.topazextract", line 146, in topazCryptoInit
    return Topaz_Cipher().ctx_init(key)
  File "calibre_plugins.dedrm.alfcrypto", line 211, in ctx_init
    keyByte = ord(keyChar)
TypeError: ord() expected string of length 1, but int found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "calibre/customize/ui.py", line 176, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 633, in run
    decrypted_ebook = self.KindleMobiDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 583, in KindleMobiDecrypt
    raise DeDRMError("{0} v{1}: Ultimately failed to decrypt after {2:.1f} seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
calibre_plugins.dedrm.DeDRMError: DeDRM v7.2.1: Ultimately failed to decrypt after 0.1 seconds. Read the FAQs at Harper's repository: https://github.com/apprenticeharper/DeDRM_tools/blob/master/FAQs.md
Running file type plugin GetFileName failed with traceback:
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 176, in _run_filetype_plugins
  File "calibre_plugins.getfilename.__init__", line 108, in run
    json.dump (dictio_aux, file)
  File "json/__init__.py", line 180, in dump
TypeError: a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 433, in get_file_type_metadata
  File "calibre/customize/builtins.py", line 416, in get_metadata
  File "calibre/ebooks/metadata/topaz.py", line 378, in get_metadata
  File "calibre/ebooks/metadata/topaz.py", line 114, in __init__
ValueError: '/Volumes/MMXXI/Calibre/Unknown/A Guide to the Bodhisattva Way of Life (7617)/A Guide to the Bodhisattva Way of Life - Unknown.tpz': Invalid Topaz format - no metadata record

@zwhitten
Copy link
Author

zwhitten commented Sep 9, 2021

Reverting to Calibre 4.23.0 and DeDRM v6.6.3 solved this one for me. TPZ file was successfully imported with the older versions

@ableeker
Copy link
Contributor

@zwhitten Does this version work for you?

DeDRM_plugin.zip

@zwhitten
Copy link
Author

hey @ableeker that version did work

@ghost
Copy link

ghost commented Jun 30, 2022

TPZ files still seem to be an issue. The last plugin version @ableeker recommends above works, but not very well. Lots of formatting is lost, special characters are turned into gibberish, etc. Are there any plans for a more permanent, and more accurate, solution?

@ElleKayEm
Copy link

TPZ format has been on ongoing issue since forever. It's an awful format.

Development of DeDRM has moved to noDRM's github: https://github.com/noDRM/DeDRM_tools

There's a chance that you might have better luck with the older Python 2 versions: calibre 4.23 and DeDRM 6.8.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants