def is_hibp(password): # Required: A descriptive user agent must be set describing the application consuming # the HIBP API pyhibp.set_user_agent(ua="PMS-Service") # Check a password to see if it has been disclosed in a public breach corpus resp = pw.is_password_breached(password=password) if resp: #print("Password breached!") #print("This password was used {0} time(s) before.".format(resp)) return True return False
def __init__(self, usable_chars=USABLE_CHARS, excluded_chars=EXCLUDED_CHARS, min_pass_len=MIN_PASS_LEN, max_pass_len=MAX_PASS_LEN, excluded_words=EXCLUDED_WORDS, remove_repeating=False, remove_english=False, ensure_proportions=False, language_lib=None, include_whitespace=True): """ Args: usable_chars (list): list of lists containing arrays of characters to be used in password generation. Is not relevant in generating passwords from language model. excuded_chars (list): list of characters which will not be used in password generation. Is not relevant in generating passwords from language model. min_pass_len (int): Minimum length of any password generated by this class. max_pass_len (int): Maximum length of any password generated by this class. excluded_words (list): List of words(str) which will not be used in password generation. Is not relevant in generating passwords from language model. remove_repeating (bool): Determines if repeating characters will be removed from password. Is not relevant in generating passwords from language model. remove_english (bool): Determines if English language words, with len more than 3 will be removed from password. Is not relevant in generating passwords from language model. ensure_proportions (bool): Determines if the rule that the password must have at least one of each group from usable_chars list will be enforced. Is not relevant in generating passwords from language model. language_lib (str): Name of the language model to be used in generating language model passwords. include_whitespace (bool): Determines if the whitespaces will be included in the passwords generated by the language model. """ self.excluded_chars = excluded_chars """ Usable chars are checked against the excluded characters, and any matching chars are removed before initializing usable_chars property. """ for excl_char in excluded_chars: for usable_char_list in usable_chars: if excl_char in usable_char_list: usable_char_list.remove(excl_char) self.usable_chars = usable_chars self.excluded_words = excluded_words # Setting the minimum and maximum length of the generated passwords. self.min_pass_len = min_pass_len self.max_pass_len = max_pass_len # Passwords generated with self.generate_human_password will be stored here self.human_passwords = [] # Passwords generated with self.generate_password will be stored here self.passwords = [] self.language_manager = Language(library=language_lib, min_sentence_length=min_pass_len, max_sentence_length=max_pass_len, include_whitespace=include_whitespace) if language_lib is not None else None set_user_agent(ua="PyPass Python password generator. Demo version.")
def email(): pyhibp.set_user_agent( ua="Awesome application/0.0.1 (An awesome description)") HIBP_API_KEY = 'aa3876c762b9457385e2278befd83ac8' if HIBP_API_KEY: pyhibp.set_api_key(key=HIBP_API_KEY) resp = pyhibp.get_all_breaches() dict = [] email_name = "*****@*****.**" _resp = pyhibp.get_account_breaches(account=email_name, truncate_response=True) print(_resp) for x in _resp: email = models.infected_email(email=email_name, site=x['Name']) email.save() print(x['Name'])
def hibpEmailVerification(email): pyhibp.set_user_agent(ua="A e-mail breach verification") # Have I Been Pawned Key HIBP_API_KEY = '362134bc48ee49ed8dad0efad610a49a' retorno = "Não encontramos evidências de que seu e-mail foi vazado!" if HIBP_API_KEY: pyhibp.set_api_key(key=HIBP_API_KEY) resp = pyhibp.get_account_breaches(account=f"{email}", truncate_response=True) if resp: retorno = resp return retorno
def __init__(self, email=None, phone_num=None): with open('private_key.json') as f: KEY = json.load(f) API_KEY = KEY['pwnd_token'] f.close() pyhibp.set_api_key(key=API_KEY) pyhibp.set_user_agent(ua="Making a test application for a project.") self.phone_num = phone_num self.email = email self.breaches = pyhibp.get_account_breaches(account=self.email, truncate_response=True, include_unverified=True) self.breaches_num = len(self.get_list_breaches()) if (not (self.email or self.phone_num)): print('This user has an invalid email or phone number.') return None
def check_hibp(self, email, password, elastic=False): print("---" + Fore.CYAN + "Have I Been Pwned" + Fore.RESET + "---") pyhibp.set_user_agent(ua="pepe") pyhibp.set_api_key(key='7ca6ddde2dae4228a8b1a175bbb1583e') to_elastic = {"email": email, "password": password, "results": []} try: resp = pyhibp.get_account_breaches(account=email, truncate_response=True) if resp: for name in resp: to_elastic['results'].append(name['Name']) print(Fore.MAGENTA + name['Name'] + Fore.RESET) else: print(Fore.RED + "Nothing found" + Fore.RESET) except Exception as e: print(Fore.RED + str(e) + Fore.RESET) if len(to_elastic['results']) > 0: if elastic: self.put_elastic('hibp', 'email', to_elastic) return True else: return False
def getbreaches(): pyhibp.set_user_agent( ua="Awesome application/0.0.1 (An awesome description)") HIBP_API_KEY = 'aa3876c762b9457385e2278befd83ac8' if HIBP_API_KEY: # Set the API key prior to using the functions which require it. pyhibp.set_api_key(key=HIBP_API_KEY) resp = pyhibp.get_all_breaches() dict = [] print("this is for all the breach") for x in resp: dict.append({ 'name': x['Name'], 'domain': x['Domain'], 'time': x['PwnCount'] }) for y in dict: print(y['name']) book = models.all_breaches(name=y['name'], domain=y['domain'], time_breached=y['time']) book.save()
numbers = "0123456789" symbolls = "!@#$%^&*()_+=-+/`~|" user_password = "******" mixing = letters_low + letters_up + numbers + symbolls def user_password_fn(): length = int(input("Enter the length for you password: "******"".join(random.sample(mixing, length)) print(f"Your password: {user_password}") user_password_fn() pyhibp.set_user_agent(ua="None") resp = pw.is_password_breached(password=f"{user_password}") if resp: print(f"Password breached! \nThis password was used {resp} times before.") if int(len(user_password)) < 8: again = int( input( "Your password's length is less than 8. Please re-enter the password.\nEnter 1 to continue..." )) if again == 1: while True: user_password_fn() z = input( "Enter '1' if you want to continue, to exit, enter anything!!!" )
#Remember to follow me on tiktok ;) @_r.x.t.i_ from pyhibp import pwnedpasswords as pw from sendsms import SMS import json import pyhibp import time pyhibp.set_user_agent(ua="blahblahblah/0.0.1 (Protecting ourselves since covid 19. BLACKLIVESMATTER)") #load passwords f = open("pwds.json", "r") pwdata = json.load(f) f.close() while True: print("Checking if we've been pwned...") breachedpwds = [] for password in pwdata["passwords"].values(): resp = pw.is_password_breached(password=password) if resp: breachedpwds.append(password) f = open("message.txt", "w") f.write("The following password(s) have been compromised:\n") #feel free to personalize this message best to your needs... for i in breachedpwds: f.write(u"\u2022" + i +'\n') f.close() #if any passwords have been breached send message if len(breachedpwds) != 0:
def check_pawned(password): # Setting the User-Agent to be used in subsequent calls sent to the HIBP API backend. pyhibp.set_user_agent(ua="PMS") # Check if a password has been disclosed in any of the data breaches resp = pawned.is_password_breached(password=password) return resp
import pandas as pd import re import os from fnmatch import fnmatch import time import pyhibp import configparser path = '/'.join((os.path.abspath(__file__).replace('\\', '/')).split('/')[:-1]) config = configparser.ConfigParser() config.read(os.path.join(path, 'settings.conf')) api = config['settings']['hibpapikey'] delay = float(config['settings']['timedelay']) pyhibp.set_user_agent(ua="nynerd's HIBP Project") pyhibp.set_api_key(key=api) def intro(): print(""" _ _ _____ ____ _____ _____ _____ _____ _____ ______ _____ | | | |_ _| _ \| __ \ | __ \|_ _| __ \| __ \| ____| __ \ | |__| | | | | |_) | |__) | | |__) | | | | |__) | |__) | |__ | |__) | | __ | | | | _ <| ___/ | _ / | | | ___/| ___/| __| | _ / | | | |_| |_| |_) | | | | \ \ _| |_| | | | | |____| | \ \ |_| |_|_____|____/|_| |_| \_\_____|_| |_| |______|_| \_\ """)
import pyhibp from pyhibp import pwnedpasswords as pw pyhibp.set_user_agent(ua="OSINTed/1.0 (OSINT FrameWork @spooky_sec)") def CheckPassword(password): handle = pw.is_password_breached(password=f"{password}") return handle
"\n L'adresse email n'a pas été violée ou été dans une fuite de données" ) elif str(check.status_code) == "200": #L'adresse email a été violée print("\nL'adresse email a été violée") else: #print(check.status_code) print( "\nUne erreur s'est produite: This version of the API has been discontinued, please use V3: https://www.troyhunt.com/authentication-and-the-have-i-been-pwned-api/!!! " ) condition = False break elif action == '5': #On définit un agent utilisateur décrivant l'application utilisant l'API HIBP pyhibp.set_user_agent( ua="Awesome application/0.0.1 (An awesome description)") #L'utilisateur saisit le mot de passe passw = input("\nSaississez le mot de passe à vérifier: ") #Vérifiez si le mot de passe n'a été divulgué dans une violation publique resp = pw.is_password_breached(password=passw) if resp: print("\nVotre mot de passe a déjà fuité!") print("Ce mot de passe a été utilisé {0} fois déjà.".format(resp)) else: print( "\nVotre mot n'a pas été violée ou été dans une fuite de données" ) condition = False break else:
def check_pawned_password(password): pyhibp.set_user_agent(ua="HIBP Application/0.0.1") return pw.is_password_breached(password=password)