Decrypting Chromium cookies Decrypting Chromium cookies google-chrome google-chrome

Decrypting Chromium cookies


You're on the right track! I've been working on this for a few days and finally figured it out. (Many thanks to the OP for the helpful links to the Chromium source.)

I've put up a post with a little more detail and a working script, but here is the basic idea:

#! /usr/bin/env python3from Crypto.Cipher import AESfrom Crypto.Protocol.KDF import PBKDF2# Function to get rid of paddingdef clean(x):     return x[:-x[-1]].decode('utf8')# replace with your encrypted_value from sqlite3encrypted_value = ENCRYPTED_VALUE # Trim off the 'v10' that Chrome/ium prependsencrypted_value = encrypted_value[3:]# Default values used by both Chrome and Chromium in OSX and Linuxsalt = b'saltysalt'iv = b' ' * 16length = 16# On Mac, replace MY_PASS with your password from Keychain# On Linux, replace MY_PASS with 'peanuts'my_pass = MY_PASSmy_pass = my_pass.encode('utf8')# 1003 on Mac, 1 on Linuxiterations = 1003key = PBKDF2(my_pass, salt, length, iterations)cipher = AES.new(key, AES.MODE_CBC, IV=iv)decrypted = cipher.decrypt(encrypted_value)print(clean(decrypted))


@n8henrie's answer worked for me, but in my environment with Ubuntu, Chrome no longer use 'peanuts' as password, instead it's stored in gnome keyring. I managed to get the password for decryption using secretstorage package like this:

import secretstoragebus = 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()        breakelse:    raise Exception('Chrome password not found!')