From c73eabe2a4661a2b1f9fda32604ac7cc3c134388 Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Mon, 17 Jan 2022 10:46:02 +0800 Subject: [PATCH] Clearer error message in decompressing decrypted backup --- Whatsapp_Chat_Exporter/extract.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Whatsapp_Chat_Exporter/extract.py b/Whatsapp_Chat_Exporter/extract.py index 48e1cea..9855085 100644 --- a/Whatsapp_Chat_Exporter/extract.py +++ b/Whatsapp_Chat_Exporter/extract.py @@ -59,7 +59,10 @@ def decrypt_backup(database, key, output, crypt14=True): main_key = key[126:] cipher = AES.new(main_key, AES.MODE_GCM, iv) db_compressed = cipher.decrypt(db_ciphertext) - db = zlib.decompress(db_compressed) + try: + db = zlib.decompress(db_compressed) + except zlib.error: + print("Decompressing failed. Possibly incorrect offsets used in decryption.") if db[0:6].upper() == b"SQLITE": with open(output, "wb") as f: f.write(db)