def chrome_process(safe_storage_key, chrome_data):
# Salt, iterations, iv, size -> https://cs.chromium.org/chromium/src/components/os_crypt/os_crypt_mac.mm
iv = "".join(("20",) * 16)
key = pbkdf2_hmac("sha1", safe_storage_key, b"saltysalt", 1003)[:16]
copy_path = tempfile.mkdtemp() # Work around for locking DB
with open(chrome_data, "r") as content:
dbcopy = content.read()
with open("{0}/chrome".format(copy_path), "w") as content:
# If Chrome is open the DB will be locked, get around this by making a temp copy.
content.write(dbcopy)
database = sqlite3.connect("{0}/chrome".format(copy_path))
if "Web Data" in chrome_data:
sql_query = "select name_on_card, card_number_encrypted, expiration_month, expiration_year from credit_cards"
else:
sql_query = "select username_value, password_value, origin_url, submit_element from logins"
decrypted_list = []
with database:
for values in database.execute(sql_query):
if values[0] == '' or (values[1][:3] != b"v10"):
# User will be empty if they have selected "never" store password.
continue
else:
decrypted_list.append((str(values[2]).encode("ascii", "ignore"), values[0].encode("ascii", "ignore"), str(chrome_decrypt(values[1], iv, key)).encode("ascii", "ignore"), values[3]))
shutil.rmtree(copy_path)
return decrypted_list
评论列表
文章目录