Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check saved Firefox passwords against the list of domains that use Cloudflare
#!/usr/bin/python3
import glob
import json
import sys
import os
from urllib.parse import urlparse
# download from https://github.com/pirate/sites-using-cloudflare/
cloudflare_tlds = frozenset(map(lambda x:x.strip(),
open("sites-using-cloudflare-master/sorted_unique_cf.txt")))
profiles = os.path.join(os.environ['HOME'], '.mozilla/firefox/*/logins.json')
for profile in glob.glob(profiles):
print("Checking", profile)
data = json.load(open(profile))
check_tlds = set()
for login in data['logins']:
url = login['hostname']
host_port = urlparse(url).netloc
host = host_port.split(':')[0]
f = host.split('.')
for i in range(len(f)):
domain = '.'.join(host.split('.')[-i-1:])
if domain in cloudflare_tlds:
check_tlds.add(domain)
break
for tld in check_tlds:
print(" ", tld)
@looselytyped

This comment has been minimized.

looselytyped commented Feb 24, 2017

Thank you for this. Just a couple of notes for anyone passing by

  • This uses python3 - if you have Homebrew you can
    • Install python3 with brew install python3
    • Usage is python3 check-firefox-passwords.py

This script assumes you downloaded sorted_unique_cf.txt from the master branch. In case you just cloned https://github.com/pirate/sites-using-cloudflare/ you will need to

Finally, on OSX logins.json is under ~/Library/Application Support/Firefox/Profiles/<some-identifier>.default - I changed Line #12 to profiles = os.path.join(os.environ['HOME'], 'Library/Application Support/Firefox/Profiles/*/logins.json')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment