Skip to content

Instantly share code, notes, and snippets.

@avian2
Last active February 26, 2017 18:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avian2/30db0d579732287d758c21ba8ded9393 to your computer and use it in GitHub Desktop.
Save avian2/30db0d579732287d758c21ba8ded9393 to your computer and use it in GitHub Desktop.
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
Copy link

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