From bf7394fe698b30ab3244d1510e5cd7038941baeb Mon Sep 17 00:00:00 2001 From: Miguel Silva Date: Thu, 17 Oct 2024 18:29:01 +0100 Subject: [PATCH 1/2] The retrieval does not work with passwords over ~106 bytes long. Changing the Mode of operation from GCM to CBC fixes this. --- Linux/lazagne/softwares/browsers/chromium_based.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Linux/lazagne/softwares/browsers/chromium_based.py b/Linux/lazagne/softwares/browsers/chromium_based.py index 59e4e6c7..09fb8d9d 100644 --- a/Linux/lazagne/softwares/browsers/chromium_based.py +++ b/Linux/lazagne/softwares/browsers/chromium_based.py @@ -60,7 +60,7 @@ def _decrypt_v80(self, buff, master_key): try: iv = buff[3:15] payload = buff[15:] - cipher = AES.new(master_key, AES.MODE_GCM, iv) + cipher = AES.new(master_key, AES.MODE_CBC, iv) decrypted_pass = cipher.decrypt(payload) decrypted_pass = decrypted_pass[:-16] # .decode() # remove suffix bytes return decrypted_pass From 6ed0181ca4e906bd3364dba0fdcbce6196a47e19 Mon Sep 17 00:00:00 2001 From: Miguel Silva Date: Thu, 17 Oct 2024 23:59:38 +0100 Subject: [PATCH 2/2] Wrapped the AES mode change in a try catch to guarantee backwards compatibility --- Linux/lazagne/softwares/browsers/chromium_based.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Linux/lazagne/softwares/browsers/chromium_based.py b/Linux/lazagne/softwares/browsers/chromium_based.py index 09fb8d9d..e7d6d33d 100644 --- a/Linux/lazagne/softwares/browsers/chromium_based.py +++ b/Linux/lazagne/softwares/browsers/chromium_based.py @@ -56,11 +56,11 @@ def remove_padding(self, data): self.debug(traceback.format_exc()) return data - def _decrypt_v80(self, buff, master_key): + def _decrypt_v80(self, buff, master_key, AES_mode): try: iv = buff[3:15] payload = buff[15:] - cipher = AES.new(master_key, AES.MODE_CBC, iv) + cipher = AES.new(master_key, AES_mode, iv) decrypted_pass = cipher.decrypt(payload) decrypted_pass = decrypted_pass[:-16] # .decode() # remove suffix bytes return decrypted_pass @@ -107,7 +107,11 @@ def get_passwords(self, path): password = self.chrome_decrypt(password, key=enc_key, init_vector=self.enc_config['iv']) password = password if python_version == 2 else password.decode() except UnicodeDecodeError: - password = self._decrypt_v80(password, enc_key) + password = self._decrypt_v80(password, enc_key, AES.MODE_GCM) + try: + password=password.decode() + except UnicodeDecodeError : + password = self._decrypt_v80(password, enc_key, AES.MODE_CBC) if password: break else: