Расшифровка cookies google-chrome
Не получается расшифровать encrypted_value, выводится такая строка:
b'v10\x18\x06E\x04j\xc5\x98\x86\x13[\xaf\xd3j\xbf!\xd8P\xc3\x8f\x92\xecV\xcc\xbb\x03Hd\xba\xd9\x91\tb<\xcb\xc7>\xc7\xf6#f^.\xbd\x87\xca!\xb2\x96u0\xd3\x82>5\xe09\n\x9b\xbe\xbd\xad\xf4Ta\xf5o\xf3\xc5\x9a\xe9\x95^5_0:\xbf\xc58\x0fDD\xe19\xa0\xe5&q\x12f\xd8\xf8\xb4\xce\x0
Так понимаю это двоичное значение, а как его расшифровать не очень догоняю
import os
import shutil
import base64
import sqlite3
import win32crypt
import re
from Cryptodome.Cipher import AES
Chrome_cookies = os.getenv('LOCALAPPDATA') + r"\Google\Chrome\User Data\Default\Login Data"
Key = os.getenv('LOCALAPPDATA') + r"\Google\Chrome\User Data\Local State"
def chrome_cookies():
if os.path.exists(Chrome_cookies) == True:
with open (Key, 'r') as f:
matches = re.findall(r'"encrypted_key":"(.+?)"', f.read())
key = base64.b64decode(matches[0])[5:]
decryption_key2 = win32crypt.CryptUnprotectData(key, None, None, None, 0)[1]
shutil.copy2(Chrome_cookies, 'databasepasss.db')
conn = sqlite3.connect('databasepasss.db')
cursor = conn.cursor()
cursor.execute('SELECT host_key, name, encrypted_value FROM cookies')
show = cursor.fetchall()
with open ('D:\\cookies.txt', 'w+') as f:
for host_key, name, encrypted_value in show:
initialization_vector = encrypted_value[3:15]
password = encrypted_value[15:-16]
gsm = AES.new(decryption_key2, AES.MODE_GCM,initialization_vector)
decrypted_cookies = gsm.decrypt(password)
paass = decrypted_cookies.decode()
text = 'Host key: ' + host_key + '\n' +'\n' + 'Name: ' + name + '\n' + '\n' + 'encrypted_value: ' + str(encrypted_value) + '\n' + '\n' + '============' + '\n' + '\n'
print(text)
f.write(text)
chrome_cookies()