original_docstring: Generate lookalike domain names for the given domain. Then confirm if the domains have
          been registered and collect DNS records. The domain names and IP addresses are checked
          against Cymon.io's threat feeds. If a result is found (200 OK), then the domain or IP has
          been reported to be part of some sort of malicious activity relatively recently.
  
          This function returns a list of domains, A-records, MX-records, and the results from Cymon.
  
          A Cymon API key is recommended, but not required.
  
          Parameters:
          domain      The base domain used for generating lookalike domains
          limit       An upper limit on how many lookalike domain names to check
          
docstring: Generate lookalike domain names for the given domain. Then confirm if the domains have
  been registered and collect DNS records. The domain names and IP addresses are checked
  against Cymon.io's threat feeds. If a result is found (200 OK), then the domain or IP has
  been reported to be part of some sort of malicious activity relatively recently.
  
  This function returns a list of domains, A-records, MX-records, and the results from Cymon.
  
  A Cymon API key is recommended, but not required.
  
  domain      The base domain used for generating lookalike domains
  limit       An upper limit on how many lookalike domain names to check
docstring_tokens: Generate lookalike domain names for the given domain . Then confirm if the domains have been registered and collect DNS records . The domain names and IP addresses are checked against Cymon . io ' s threat feeds . If a result is found ( 200 OK ) then the domain or IP has been reported to be part of some sort of malicious activity relatively recently . This function returns a list of domains A - records MX - records and the results from Cymon . A Cymon API key is recommended but not required . domain The base domain used for generating lookalike domains limit An upper limit on how many lookalike domain names to check
code: def run_domain_twister(self,domain,limit=domain_limit):
          """Generate lookalike domain names for the given domain. Then confirm if the domains have
          been registered and collect DNS records. The domain names and IP addresses are checked
          against Cymon.io's threat feeds. If a result is found (200 OK), then the domain or IP has
          been reported to be part of some sort of malicious activity relatively recently.
  
          This function returns a list of domains, A-records, MX-records, and the results from Cymon.
  
          A Cymon API key is recommended, but not required.
  
          Parameters:
          domain      The base domain used for generating lookalike domains
          limit       An upper limit on how many lookalike domain names to check
          """
          naked,_,tld = domain.rpartition('.')
          domain_data = []
          candidates = {
              'alt_tlds':self.generate_alt_tlds(domain,naked,tld),
              'homoglyphs':self.generate_homoglyphs(domain,naked,tld),
              'suffixes':self.generate_suffixes(domain,naked,tld),
          }
          for kind in candidates.keys():
              # Sort by the ranking score before checking availability
              ranked = sorted(candidates[kind],key=operator.itemgetter(1),reverse=True)
              for name,rank in ranked:
                  # If the domain is registered, collect the DNS records for further analysis
                  if self.check_availability(name):
                      try:
                          a_records = self.dns_collector.return_dns_record_list(name,"A")
                      except:
                          a_records = "None"
                      try:
                          mx_records = self.dns_collector.return_dns_record_list(name,"MX")
                      except:
                          mx_records = "None"
                  else:
                      a_records = "None"
                      mx_records = "None"
                  data = {'name':name,'rank':rank,'a_records':a_records,'mx_records':mx_records}
                  domain_data.append(data)
                  if len(domain_data) >= int(limit):
                      break
          twister_results = []
          for candidate in domain_data:
              # Search for domains and IP addresses tied to the domain name
              try:
                  results = self.search_cymon_domain(candidate['name'])
                  if results:
                      malicious_domain = 1
                  else:
                      malicious_domain = 0
              except Exception as error:
                  malicious_domain = 0
                  click.secho("\n[!] There was an error checking {} with Cymon.io!".format(candidate['name']),fg="red")
              # Search for domains and IP addresses tied to the A-record IP
              for record in candidate['a_records']:
                  try:
                      results = self.search_cymon_ip(record)
                      if results:
                          malicious_ip = 1
                      else:
                          malicious_ip = 0
                  except Exception as error:
                      malicious_ip = 0
                      click.secho("\n[!] There was an error checking {} with Cymon.io!".format(domain[1]),fg="red")
              if malicious_domain == 1:
                  cymon_result = "Yes"
              elif malicious_ip == 1:
                  cymon_result = "Yes"
              else:
                  cymon_result = "No"
              temp = {}
              temp['domain'] = candidate['name']
              temp['rank'] = candidate['rank']
              temp['a_records'] = candidate['a_records']
              temp['mx_records'] = candidate['mx_records']
              temp['malicious'] = cymon_result
              twister_results.append(temp)
          return twister_results
code_tokens: def run_domain_twister ( self , domain , limit = domain_limit ) : naked , _ , tld = domain . rpartition ( '.' ) domain_data = [ ] candidates = { 'alt_tlds' : self . generate_alt_tlds ( domain , naked , tld ) , 'homoglyphs' : self . generate_homoglyphs ( domain , naked , tld ) , 'suffixes' : self . generate_suffixes ( domain , naked , tld ) , } for kind in candidates . keys ( ) : ranked = sorted ( candidates [ kind ] , key = operator . itemgetter ( 1 ) , reverse = True ) for name , rank in ranked : if self . check_availability ( name ) : try : a_records = self . dns_collector . return_dns_record_list ( name , "A" ) except : a_records = "None" try : mx_records = self . dns_collector . return_dns_record_list ( name , "MX" ) except : mx_records = "None" else : a_records = "None" mx_records = "None" data = { 'name' : name , 'rank' : rank , 'a_records' : a_records , 'mx_records' : mx_records } domain_data . append ( data ) if len ( domain_data ) >= int ( limit ) : break twister_results = [ ] for candidate in domain_data : try : results = self . search_cymon_domain ( candidate [ 'name' ] ) if results : malicious_domain = 1 else : malicious_domain = 0 except Exception as error : malicious_domain = 0 click . secho ( "\n[!] There was an error checking {} with Cymon.io!" . format ( candidate [ 'name' ] ) , fg = "red" ) for record in candidate [ 'a_records' ] : try : results = self . search_cymon_ip ( record ) if results : malicious_ip = 1 else : malicious_ip = 0 except Exception as error : malicious_ip = 0 click . secho ( "\n[!] There was an error checking {} with Cymon.io!" . format ( domain [ 1 ] ) , fg = "red" ) if malicious_domain == 1 : cymon_result = "Yes" elif malicious_ip == 1 : cymon_result = "Yes" else : cymon_result = "No" temp = { } temp [ 'domain' ] = candidate [ 'name' ] temp [ 'rank' ] = candidate [ 'rank' ] temp [ 'a_records' ] = candidate [ 'a_records' ] temp [ 'mx_records' ] = candidate [ 'mx_records' ] temp [ 'malicious' ] = cymon_result twister_results . append ( temp ) return twister_results
short_docstring: Generate lookalike domain names for the given domain.
short_docstring_tokens: Generate lookalike domain names for the given domain .
comment: """Generate lookalike domain names for the given domain. Then confirm if the domains have
          been registered and collect DNS records. The domain names and IP addresses are checked
          against Cymon.io's threat feeds. If a result is found (200 OK), then the domain or IP has
          been reported to be part of some sort of malicious activity relatively recently.
  
          This function returns a list of domains, A-records, MX-records, and the results from Cymon.
  
          A Cymon API key is recommended, but not required.
  
          Parameters:
          domain      The base domain used for generating lookalike domains
          limit       An upper limit on how many lookalike domain names to check
          """$SEP$# Sort by the ranking score before checking availability$SEP$# If the domain is registered, collect the DNS records for further analysis$SEP$# Search for domains and IP addresses tied to the domain name$SEP$# Search for domains and IP addresses tied to the A-record IP