From ef3c85aa2d22e71aab3e1854ab9bfc09885614c6 Mon Sep 17 00:00:00 2001 From: moritz Date: Wed, 29 May 2019 14:11:17 +0200 Subject: [PATCH] add feature to also check for email adresses --- src/have_I_b33n_pwned.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/have_I_b33n_pwned.py b/src/have_I_b33n_pwned.py index f928c48..9368bfa 100644 --- a/src/have_I_b33n_pwned.py +++ b/src/have_I_b33n_pwned.py @@ -26,22 +26,26 @@ # - add feature: keepass integration? isnt there something like this already? - from sys import argv, stdout, exit from argparse import ArgumentParser from hashlib import sha1 from getpass import getpass from requests import get + RED = "\033[1;31m" GREEN = "\033[0;32m" RESET = "\033[0;0m" API = 'https://api.pwnedpasswords.com/range/' +API_MAIL = 'https://haveibeenpwned.com/api/v2/breachedaccount/' ROW = '{:<30}{:<10}{:<45}' 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', metavar='foo@adress.bar', nargs='+', @@ -53,7 +57,6 @@ parser.add_argument('-p', '-password', '--password', help='Password which should be checked against the leak database.' ) args = parser.parse_args() -print(args) @@ -119,7 +122,29 @@ def query_password(password): 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__':