Skip to content

Instantly share code, notes, and snippets.

@NelsonMinar
Created January 11, 2018 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NelsonMinar/f667798c95b2bddfe6392f01111488ab to your computer and use it in GitHub Desktop.
Save NelsonMinar/f667798c95b2bddfe6392f01111488ab to your computer and use it in GitHub Desktop.
IndexedDB database file walker for Firefox
#!/usr/bin/env python3.6
"""
Hacky code to walk all the IndexedDB storage in your Firefox profile
and print some basic information about them.
The hardcoded path here works in WSL, Linux-for-Windows. Change as needed.
"""
base_dir = '/mnt/c/Users/*/AppData/Roaming/Mozilla/Firefox/Profiles/*/storage/default/'
import sqlite3, glob, re
path_re = re.compile(r'storage/default/([^/]+)/idb/')
q_db_cols = '''
select object_store.name, group_concat(object_store_index.name)
from object_store left join object_store_index
on object_store.id = object_store_index.object_store_id
group by object_store.name;
'''
q_dbs = '''
select origin, name, version, last_vacuum_size
from database;
'''
for fn in glob.glob(f'{base_dir}/*/idb/*.sqlite'):
# Grab the site from the path name, but we don't really use this
m = path_re.search(fn)
assert m is not None
site_path = m.group(1).replace('+++', '://')
conn = sqlite3.connect(fn)
c = conn.cursor()
for origin, name, version, size in c.execute(q_dbs):
print(f'{origin:30.30} {name:24.24} {version:10} {size:10}')
for table, columns in conn.execute(q_db_cols):
columns = '-' if columns is None else columns
columns = columns.replace(',', ', ')
print(f' {table} {columns}')
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment