Last active
February 26, 2017 18:31
-
-
Save avian2/30db0d579732287d758c21ba8ded9393 to your computer and use it in GitHub Desktop.
Check saved Firefox passwords against the list of domains that use Cloudflare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this. Just a couple of notes for anyone passing by
python3
- if you have Homebrew you canbrew install python3
python3 check-firefox-passwords.py
This script assumes you downloaded
sorted_unique_cf.txt
from themaster
branch. In case you just cloned https://github.com/pirate/sites-using-cloudflare/ you will need toopen("sites-using-cloudflare/sorted_unique_cf.txt")
Finally, on OSX
logins.json
is under~/Library/Application Support/Firefox/Profiles/<some-identifier>.default
- I changed Line #12 toprofiles = os.path.join(os.environ['HOME'], 'Library/Application Support/Firefox/Profiles/*/logins.json')