def test_emailformat(): em = EmailFormat.EmailFormat('verisgroup.com', Verbose=True) name = em.BuildName(['alex', 'test'], "{first}.{last}") assert name == 'alex.test' cleannames = [['alex', 'test'], ['alex', 'man'], ['alex', 'dude'], ['mad', 'max']] domain = 'verisgroup.com' finalemails = ['*****@*****.**'] result = em.EmailDetect(cleannames, domain, finalemails) assert result[0] == '{f}{last}' finalemails = ['*****@*****.**'] result = em.EmailDetect(cleannames, domain, finalemails) assert result[0] == '{f}.{last}' finalemails = ['*****@*****.**'] result = em.EmailDetect(cleannames, domain, finalemails) assert result[0] == '{first}{last}' finalemails = ['*****@*****.**'] result = em.EmailDetect(cleannames, domain, finalemails) assert result[0] == '{first}.{last}' finalemails = ['*****@*****.**'] result = em.EmailDetect(cleannames, domain, finalemails) assert result[0] == '{first}.{l}' finalemails = ['*****@*****.**'] result = em.EmailDetect(cleannames, domain, finalemails) assert result[0] == '{first}{l}' finalemails = ['*****@*****.**'] result = em.EmailDetect(cleannames, domain, finalemails) assert result[0] == '{first}_{last}' finalemails = ['*****@*****.**'] result = em.EmailDetect(cleannames, domain, finalemails) assert result[0] == '{first}' # now test building emails fm = '{f}{last}' emails = em.EmailBuilder(cleannames, domain, fm) assert '*****@*****.**' in emails fm = '{f}.{last}' emails = em.EmailBuilder(cleannames, domain, fm) assert '*****@*****.**' in emails fm = '{first}{last}' emails = em.EmailBuilder(cleannames, domain, fm) assert '*****@*****.**' in emails fm = '{first}.{last}' emails = em.EmailBuilder(cleannames, domain, fm) assert '*****@*****.**' in emails fm = '{first}.{l}' emails = em.EmailBuilder(cleannames, domain, fm) assert '*****@*****.**' in emails fm = '{first}{l}' emails = em.EmailBuilder(cleannames, domain, fm) assert '*****@*****.**' in emails fm = '{first}_{last}' emails = em.EmailBuilder(cleannames, domain, fm) print emails assert '*****@*****.**' in emails fm = '{first}' emails = em.EmailBuilder(cleannames, domain, fm) assert '*****@*****.**' in emails
def NameBuilder(self, domain, emaillist, Verbose=False): ''' Takes in Domain Names, returns List of names in indiviual lists. All the basic logic is here. ''' self.title() ValidFormat = [ '{first}.{last}', '{first}{last}', '{f}{last}', '{f}.{last}', '{first}{l}', '{first}_{last}' ] line = " [*] Now attempting to build Names:\n" print line CleanNames = [] # Query for Linkedin Names - Adapted from https://github.com/pan0pt1c0n/PhishBait Li = LinkedinNames.LinkedinScraper(domain, Verbose=Verbose) LNames = Li.LinkedInNames() if LNames: e = ' [*] LinkedinScraper has Gathred: ' + str( len(LNames)) + ' Names' print helpers.color(e, status=True) for raw in LNames: try: name = Li.LinkedInClean(raw) if name: CleanNames.append(name) except Exception as e: print e # Query for Connect6 Names c6 = Connect6.Connect6Scraper(domain, Verbose=Verbose) urllist = c6.Connect6AutoUrl() self.title() print helpers.color(" [*] Now Starting Connect6 Scrape:") line = " [*] SimplyEmail has attempted to find correct URL for Connect6:\n" line += " URL detected: " + helpers.color(urllist[0], status=True) print line Question = " [>] Is this URL correct?: " Answer = raw_input(helpers.color(Question, bold=False)) if Answer.upper() in "YES": Names = c6.Connect6Download(urllist[0]) if Names: e = ' [*] Connect6 has Gathred: ' + str(len(Names)) + ' Names' print helpers.color(e, status=True) for raw in Names: name = c6.Connect6ParseName(raw) if name: CleanNames.append(name) else: while True: for item in urllist: print " Potential URL: " + item e = ' [!] GoogleDork This: site:connect6.com "' + str( domain) + '"' print helpers.color(e, bold=False) print " [-] Commands Supported: (B) ack - (R) etry" Question = " [>] Please Provide a URL: " Answer = raw_input(helpers.color(Question, bold=False)) if Answer.upper() in "BACK": e = " [!] Skiping Connect6 Scrape!" print helpers.color(e, firewall=True) break if Answer: break if Answer.upper() != "B": Names = c6.Connect6Download(Answer) if Names: e = ' [*] Connect6 has Gathred: ' + str( len(Names)) + ' Names' print helpers.color(e, status=True) for raw in Names: name = c6.Connect6ParseName(raw) if name: CleanNames.append(name) self.title() print helpers.color(' [*] Names have been built:', status=True) print helpers.color(' [*] Attempting to resolve email format', status=True) Em = EmailFormat.EmailFormat(domain, Verbose=Verbose) Format = Em.EmailHunterDetect() if Format: e = ' [!] Auto detected the fromat: ' + str(Format) print helpers.color(e, status=True) if not Format: print helpers.color( " [*] Now attempting to manualy detect format (slow)!") Format = Em.EmailDetect(CleanNames, domain, emaillist) # Now check if we have more than one result in the list # This due to how I perform checks, in rare cases I had more than one format. if len(Format) > 1: line = helpers.color( ' [*] More than one email format was detected!\n') for item in Format: line += ' * Format: ' + item + '\n' print line line = ' [*] Here are a few samples of the emails obtained:\n' line += ' 1)' + emaillist[0] + '\n' if emaillist[1]: line += ' 2)' + emaillist[1] + '\n' if emaillist[2]: line += ' 3)' + emaillist[2] print line while True: s = False Question = " [>] Please Provid a valid Format: " Answer = raw_input(helpers.color(Question, bold=False)) try: for item in ValidFormat: if str(Answer) == str(item): Format = str(Answer) s = True except: pass if s: break if len(Format) < 1: Format = False else: Format = str(Format[0]) if not Format: print helpers.color(' [!] Failed to resolve format of email', firewall=True) line = helpers.color(' [*] Available formats supported:\n', status=True) line += ' {first}.{last} = [email protected]\n' line += ' {first}{last} = [email protected]\n' line += ' {f}{last} = [email protected]\n' line += ' {f}.{last} = [email protected]\n' line += ' {first}{l} = [email protected]\n' line += ' {first}.{l} = [email protected]\n' line += ' {first}_{last} = [email protected]\n\n' print line if len(emaillist) > 0: line = ' [*] Here are a few samples of the emails obtained:\n' line += ' 1)' + emaillist[0] + '\n' if emaillist[1]: line += ' 2)' + emaillist[1] + '\n' if emaillist[2]: line += ' 3)' + emaillist[2] print line else: line = ' [*] No unique emails discovered to display (May have to go manual)!\n' print helpers.color(line, firewall=True) while True: s = False Question = " [>] Please Provid a valid Format: " Answer = raw_input(helpers.color(Question, bold=False)) try: for item in ValidFormat: if str(Answer) == str(item): Format = str(Answer) s = True except: pass if s: break # Now build the emails! BuiltEmails = Em.EmailBuilder(CleanNames, domain, Format, Verbose=Verbose) if BuiltEmails: return BuiltEmails