Skip to content

Instantly share code, notes, and snippets.

@Sinkmanu
Created June 30, 2016 09:16
Show Gist options
  • Save Sinkmanu/679a96f749cfc4ef1191373f5adde5f1 to your computer and use it in GitHub Desktop.
Save Sinkmanu/679a96f749cfc4ef1191373f5adde5f1 to your computer and use it in GitHub Desktop.
Check if a list with email accounts is in HaveIBeenPwned
#!/usr/bin/env python3
import sys
import requests
import json
emails = sys.argv[1]
urlAPI = "https://haveibeenpwned.com/api/v2/breachedaccount/"
user_agent = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0' }
try:
print("[*] Reading file")
with open(emails, "r") as f:
for line in f:
url = urlAPI + line.strip()
r = requests.get(url, headers=user_agent)
if r.status_code == 200:
data = json.loads(r.text)
print("[+] %s:\t%s (%s)"%(line.strip(),data[0]['Name'], data[0]['Domain']))
except e:
print("[ERR] %s"%e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment