Search code examples
sqlitegoogle-chromecookies

How Do I Read Chrome Cookies File?


I would like to note that I've opened read and tried all the solutions from all the posts on StackOverflow to try and achieve my goal with absolutely no luck at all, tried using SH, Python, CMD, C# and even PowerShell all of the codes were outdated and did not work for me

Story Goes:

I've reinstalled Windows and wanted to backup Chrome Cookies just so I won't have to login into all of the websites again, I simply went to:

'/Local/Google/Chrome/User Data/Default/Cookies/Cookies'

and saved the file to my USB, Now I would like to read some of the cookies from that file so I can restore them one by one since I already have Cookies I need on my current Chrome.


What I know:

The Cookies file is based on SQL-LITE3 database which is encrypted, I figured ok there must be a way to at least view the database tables columns and etc with some kind of a sql viewer but I can't find any, I would love any hints on this one, Any method. Thanks!


Solution

  • I am not really sure if this is what you are looking for. I am also trying to use existing cookies but need to decrypt them first. This script will at least load the cookie database and let you pull values. It is quite broad and will pull thousands of lines. Maybe someone will find it useful.

    import requests
    from bs4 import BeautifulSoup
    import sqlite3
    import gzip
    
    filename="\\Local\\Google\\Chrome\\User Data\\Default\\Cookies" #EDIT ME
    connection = sqlite3.connect(filename)
    cursor = connection.cursor()
    cursor.execute("SELECT * FROM cookies;")
    results = cursor.fetchall()
    
    for r in results:
        site=r[1]
        type=r[2]
        code=str(r[12])
        vSite=site.find("ENTER WEBSITE")
        if vSite > -1:
            print(site+': '+'\t'+type+'\n'+'\n'+code+'\n')
    cursor.close()
    connection.close()