Chrome Tips
Introduction
This page is to help with things chrome.
Password
It appears that passwords are not easy to access anymore to defeat the people a Chrome I have found a python script which will provide this.
The Code
# source: https://stackoverflow.com/questions/23153159/decrypting-google-chrome-cookies
# just put a few answers together for a working script
# python3 retrieve_password.py
# outputs passwords.csv
import secretstorage
import sqlite3
import os
import csv
from Crypto.Cipher import AES
from Crypto.Protocol.KDF import PBKDF2
bus = secretstorage.dbus_init()
collection = secretstorage.get_default_collection(bus)
for item in collection.get_all_items():
if item.get_label() == 'Chrome Safe Storage':
MY_PASS = item.get_secret()
break
else:
raise Exception('google-chrome password not found!')
db = sqlite3.connect(os.getenv("HOME") + '/.config/google-chrome/Default/Login Data')
cursor = db.cursor()
cursor.execute('''SELECT signon_realm, username_value, password_value FROM logins WHERE LENGTH(password_value) != 0''')
all_rows = cursor.fetchall()
def clean(x):
return x[:-x[-1]].decode('utf8')
csvfile = open('passwords.csv', mode='w')
csvwrite = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
for entry in all_rows:
entryl = list(entry)
encrypted_value = entry[2]
encrypted_value = encrypted_value[3:]
salt = b'saltysalt'
iv = b' ' * 16
length = 16
my_pass = MY_PASS
iterations = 1
key = PBKDF2(my_pass, salt, length, iterations)
cipher = AES.new(key, AES.MODE_CBC, IV=iv)
decrypted = cipher.decrypt(encrypted_value)
entryl[2] = clean(decrypted)
csvwrite.writerow(entryl)
Usage
Easy Pezzy. You will need to install Crypto
pip3 install pycrypto
python3 retrieve_password.py
Passwords Stored in Cookies
I know people should not do this but they do so here is how to workaround a lost password in a cookie where retrieval might not be easy.
- Export using getcookie (chrome extension) Exports cookie as Netscape format
- Import using https://github.com/zhad3/cookies.txt-importer-for-chrome