forked from catalyst256/MyJunk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
haveibeenpwned.py
executable file
·47 lines (41 loc) · 1.09 KB
/
haveibeenpwned.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
import requests
import sys
import json
email = sys.argv[1]
def check_email(email):
try:
url = 'https://haveibeenpwned.com/api/v2/breachedaccount/'
req = url + str(email)
r = requests.get(req, verify=False)
if r.status_code == 404:
x = 'Account: ' + email + ' has not been pwned'
return x
if r.status_code == 200:
j = r.json()
x = json.dumps(j, indent=2, separators=(',', ': '), ensure_ascii=False, encoding="utf-8")
return x
else:
pass
except Exception as e:
return str(e)
def check_pastebin(email):
try:
url = 'https://haveibeenpwned.com/api/v2/pasteaccount/'
req = url + str(email)
r = requests.get(req, verify=False)
if r.status_code == 404:
x = 'Account: ' + email + ' has not been pasted'
return x
if r.status_code == 200:
j = r.json()
x = json.dumps(j, indent=2, separators=(',', ': '), ensure_ascii=False, encoding="utf-8")
return x
else:
pass
except Exception as e:
return str(e)
t = check_email(email)
print t
q = check_pastebin(email)
print q