From 3e71817778185edfb48a25012ef704a83e2fe98e Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Tue, 22 Feb 2022 21:19:19 +0800 Subject: [PATCH] Make the brute-force more sensitive and bug fix --- Whatsapp_Chat_Exporter/__main__.py | 2 +- Whatsapp_Chat_Exporter/extract.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Whatsapp_Chat_Exporter/__main__.py b/Whatsapp_Chat_Exporter/__main__.py index bc6caef..14a3b54 100644 --- a/Whatsapp_Chat_Exporter/__main__.py +++ b/Whatsapp_Chat_Exporter/__main__.py @@ -121,7 +121,7 @@ def main(): " are not present. For details, see README.md.") exit(3) elif error == 2: - print("Failed when decompressing the decrypted backup." + print("Failed when decompressing the decrypted backup. " "Possibly incorrect offsets used in decryption.") exit(4) else: diff --git a/Whatsapp_Chat_Exporter/extract.py b/Whatsapp_Chat_Exporter/extract.py index 786b363..f5b3f1e 100644 --- a/Whatsapp_Chat_Exporter/extract.py +++ b/Whatsapp_Chat_Exporter/extract.py @@ -57,8 +57,8 @@ class Crypt(Enum): def brute_force_offset(): - for iv in range(60, 80): - for db in range(80, 130): + for iv in range(0, 200): + for db in range(0, 200): yield iv, iv + 16, db @@ -136,11 +136,12 @@ def decrypt_backup(database, key, output, crypt=Crypt.CRYPT14): current_try += 1 if current_try < len(CRYPT14_OFFSETS): offsets = CRYPT14_OFFSETS[current_try] - t2 = database[offsets["t2"]:offsets["t2"] + 32] iv = database[offsets["iv"]:offsets["iv"] + 16] db_ciphertext = database[offsets["db"]:] continue else: + print("Common offsets are not applicable to " + "your backup. Trying to brute force it...") for start_iv, end_iv, start_db in brute_force_offset(): iv = database[start_iv:end_iv] db_ciphertext = database[start_db:]