ElDavoo / wa-crypt-tools

Manage WhatsApp .crypt12, .crypt14 and .crypt15 files.
GNU General Public License v3.0
635 stars 80 forks source link

[bug] [since #2ae18b1] Decryption of non-msgstore files crashes #120

Closed gchem1se closed 7 months ago

gchem1se commented 7 months ago

I noticed wadecrypt crashes when the issued file is not a msgstore (eg. I'm decrypting wa.db.cryptXX or stickers.db.cryptXX). I found the cause is trivial, a logging line in a utils module, in the header_info function, which tries to print the maximum feature number of the msgstore file, even if the provided input is not a msgstore. I might create a PR, but it's really a one-line solution. utils.py:180:

string += str("Max feature number: {}\n".format(max(features)))

Everything works again after commenting it out or adding a check.

Complete traceback:

File "venv/bin/wadecrypt", line 8, in <module>
    sys.exit(main())
  File "venv/lib/python3.10/site-packages/wa_crypt_tools/wadecrypt.py", line 237, in main
    db = DatabaseFactory.from_file(args.encrypted)
  File "venv/lib/python3.10/site-packages/wa_crypt_tools/lib/db/dbfactory.py", line 128, in from_file
    l.debug(header_info(header))
  File "venv/lib/python3.10/site-packages/wa_crypt_tools/lib/utils.py", line 180, in header_info
    string += str("Max feature number: {}\n".format(max(features)))
ValueError: max() arg is an empty sequence
ElDavoo commented 7 months ago

Yep, the new version was a little bit rushed out and the number of things that can happen is exploding.
Congrats for the on-point and precise debug and thanks for the PR! I will merge it when it's ready (i saw you closed it)

gchem1se commented 7 months ago

I closed it 'cause even if it was a one-line solution, I still managed to forget a newline ._. eheh. Should be fine now. Keep up the good work!