noDRM / DeDRM_tools

DeDRM tools for ebooks
7.4k stars 325 forks source link

Wrong ADE Passhash (B&N) key selected #687

Open HamsterExAstris opened 2 days ago

HamsterExAstris commented 2 days ago

Question / bug report

I have two Nook books where the wrong key is being selected, resulting in the file not decrypting correctly.

Other books correctly skip the wrong keys and select the correct one. Both books are selecting the same wrong key each time, but they're selecting different wrong keys from each other.

Which version of Calibre are you running?

7.22

Which version of the DeDRM plugin are you running?

10.0.9-rc1

If applicable, which version of the Kindle software are you running?

No response

Log output

DeDRM v10.0.9: Trying to decrypt FILENAME.epub
DeDRM v10.0.9: Verifying zip archive integrity
DeDRM v10.0.9: “FILENAME.epub” is a secure PassHash-protected (B&N) ePub
DeDRM v10.0.9: Trying Encryption key KEYNAME
1n0rxpk8.epub is a secure Adobe PassHash (B&N) ePub.
DeDRM v10.0.9: Post-processing took 0.0 seconds
DeDRM v10.0.9: Finished after 2.4 seconds
DeDRM v10.0.9: Trying to decrypt FILENAME.epub
DeDRM v10.0.9: Verifying zip archive integrity
DeDRM v10.0.9: “FILENAME.epub” is a secure PassHash-protected (B&N) ePub
DeDRM v10.0.9: Trying Encryption key KEYNAME
lqrxjw60.epub is a secure Adobe PassHash (B&N) ePub.
Could not decrypt lqrxjw60.epub because of an exception:
Traceback (most recent call last):
  File "C:\Users\USERNAME\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptepub.py", line 275, in decryptBook
  File "C:\Users\USERNAME\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptepub.py", line 91, in __init__
  File "Crypto\Cipher\AES.py", line 228, in new
  File "Crypto\Cipher\__init__.py", line 79, in _create_cipher
  File "Crypto\Cipher\_mode_cbc.py", line 274, in _create_cbc_cipher
  File "Crypto\Cipher\AES.py", line 90, in _create_base_cipher
ValueError: Incorrect AES key length (0 bytes)

DeDRM v10.0.9: Failed to decrypt with key KEYNAME after 2.9 seconds
DeDRM v10.0.9: Trying Encryption key KEYNAME
lqrxjw60.epub is a secure Adobe PassHash (B&N) ePub.
Could not decrypt lqrxjw60.epub because of an exception:
Traceback (most recent call last):
  File "C:\Users\USERNAME\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptepub.py", line 275, in decryptBook
  File "C:\Users\USERNAME\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptepub.py", line 91, in __init__
  File "Crypto\Cipher\AES.py", line 228, in new
  File "Crypto\Cipher\__init__.py", line 79, in _create_cipher
  File "Crypto\Cipher\_mode_cbc.py", line 274, in _create_cbc_cipher
  File "Crypto\Cipher\AES.py", line 90, in _create_base_cipher
ValueError: Incorrect AES key length (0 bytes)

DeDRM v10.0.9: Failed to decrypt with key KEYNAME after 2.9 seconds
DeDRM v10.0.9: Trying Encryption key KEYNAME
lqrxjw60.epub is a secure Adobe PassHash (B&N) ePub.
Could not decrypt lqrxjw60.epub because of an exception:
Traceback (most recent call last):
  File "C:\Users\USERNAME\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptepub.py", line 275, in decryptBook
  File "C:\Users\USERNAME\AppData\Roaming\calibre\plugins\DeDRM.zip\ineptepub.py", line 91, in __init__
  File "Crypto\Cipher\AES.py", line 228, in new
  File "Crypto\Cipher\__init__.py", line 79, in _create_cipher
  File "Crypto\Cipher\_mode_cbc.py", line 274, in _create_cbc_cipher
  File "Crypto\Cipher\AES.py", line 90, in _create_base_cipher
ValueError: Incorrect AES key length (0 bytes)

DeDRM v10.0.9: Failed to decrypt with key KEYNAME after 2.9 seconds
DeDRM v10.0.9: Trying Encryption key KEYNAME
lqrxjw60.epub is a secure Adobe PassHash (B&N) ePub.
DeDRM v10.0.9: Post-processing took 0.0 seconds
DeDRM v10.0.9: Finished after 3.4 seconds
ElleKayEm commented 1 day ago

Are you using the Windows Nook app to extract your key and download your books?

HamsterExAstris commented 1 day ago

Yes, I'm using the Windows Nook app to download the books, and the correct key was extracted from there. If I remove the wrongly-selected keys from the plugin configuration, it successfully uses the extracted key to decrypt the file.

The keys it's selecting in error are username/password keys from c. 2012. Obviously not going to have any new files using those keys, but I prefer to keep them on file just in case I stumble across any old files I didn't previously run through the tool.

ElleKayEm commented 1 day ago

Okay, something @noDRM will need to look at.

I have a few of those old cc based passwords lurking around in DeDRM too. Incidentally, the only way you'd need one of those keys is if you found an undecrypted file that you couldn't download a new copy of. If the account it was purchased from was deleted or the book was completely deleted from the account.