add feature to also check for email adresses

This commit is contained in:
moritz 2019-05-29 14:11:17 +02:00
parent c500bdfe9e
commit ef3c85aa2d

View File

@ -26,22 +26,26 @@
# - add feature: keepass integration? isnt there something like this already? # - add feature: keepass integration? isnt there something like this already?
from sys import argv, stdout, exit from sys import argv, stdout, exit
from argparse import ArgumentParser from argparse import ArgumentParser
from hashlib import sha1 from hashlib import sha1
from getpass import getpass from getpass import getpass
from requests import get from requests import get
RED = "\033[1;31m" RED = "\033[1;31m"
GREEN = "\033[0;32m" GREEN = "\033[0;32m"
RESET = "\033[0;0m" RESET = "\033[0;0m"
API = 'https://api.pwnedpasswords.com/range/' API = 'https://api.pwnedpasswords.com/range/'
API_MAIL = 'https://haveibeenpwned.com/api/v2/breachedaccount/'
ROW = '{:<30}{:<10}{:<45}' ROW = '{:<30}{:<10}{:<45}'
HIDDEN = False HIDDEN = False
parser = ArgumentParser(description='Check if your email or password appears in a data leak.') parser = ArgumentParser(
description='Check if your email or password appears in a data leak.',
epilog='Moritz Münch, moritzmuench@mailbox.org, willipink.eu, GPL3+'
)
parser.add_argument('-m', '-mail', '--mail', parser.add_argument('-m', '-mail', '--mail',
metavar='foo@adress.bar', metavar='foo@adress.bar',
nargs='+', nargs='+',
@ -53,7 +57,6 @@ parser.add_argument('-p', '-password', '--password',
help='Password which should be checked against the leak database.' help='Password which should be checked against the leak database.'
) )
args = parser.parse_args() args = parser.parse_args()
print(args)
@ -119,7 +122,29 @@ def query_password(password):
def query_mail(mail): def query_mail(mail):
pass print()
try:
response = get(API_MAIL + mail).json()
for breach in response:
print('Name: {}'.format(breach['Name']))
print('Title: {}'.format(breach['Title']))
print('Domain: {}'.format(breach['Domain']))
print('Breach date: {}'.format(breach['BreachDate']))
print('Added date: {}'.format(breach['AddedDate']))
print('Modified date: {}'.format(breach['ModifiedDate']))
print('Pwn count: {}'.format(breach['PwnCount']))
print('Description: {}'.format(breach['Description']))
print('Breached data: {}'.format(', '.join([data for data in breach['DataClasses']])))
print('Verified: {}'.format('yes' if breach['IsVerified'] == 1 else 'No'))
print('Fabricated: {}'.format('yes' if breach['IsFabricated'] == 1 else 'No'))
print('Sensitive: {}'.format('yes' if breach['IsSensitive'] == 1 else 'No'))
print('Retired: {}'.format('yes' if breach['IsRetired'] == 1 else 'No'))
print('Spam: {}'.format('yes' if breach['IsSpamList'] == 1 else 'No'))
except:
print('The mail adress {} was not found in any leak databases so far'.format(mail))
if HIDDEN:
prompt_password_or_mail()
if __name__ == '__main__': if __name__ == '__main__':