[cookies] fix chrome aes_cbc plaintext unicode decoding

This commit is contained in:
Evgeny Zislis 2024-11-01 14:24:23 +02:00
parent a6783a3b99
commit efa7ec323a
No known key found for this signature in database

View file

@ -1013,8 +1013,9 @@ def pbkdf2_sha1(password, salt, iterations, key_length):
def _decrypt_aes_cbc_multi(ciphertext, keys, logger, initialization_vector=b' ' * 16):
for key in keys:
plaintext = unpad_pkcs7(aes_cbc_decrypt_bytes(ciphertext, key, initialization_vector))
for cookie in (plaintext, plaintext[32:]):
try:
return plaintext.decode()
return cookie.decode()
except UnicodeDecodeError:
pass
logger.warning('failed to decrypt cookie (AES-CBC) because UTF-8 decoding failed. Possibly the key is wrong?', only_once=True)