def gen_fuzz_subdomains(expression, rule, fuzzlist): """ Generate subdomains based on fuzz mode :param str expression: generate subdomains's expression :param str rule: regexp rule :param str fuzzlist: fuzz dictionary :return set subdomains: list of subdomains """ subdomains = set() if fuzzlist: fuzz_domain = gen_subdomains(expression, fuzzlist) subdomains.update(fuzz_domain) if rule: fuzz_count = exrex.count(rule) if fuzz_count > 10000000: logger.log( 'ALERT', f'The dictionary generated by this rule is too large: ' f'{fuzz_count} > 10000000') for fuzz_string in exrex.generate(rule): fuzz_string = fuzz_string.lower() if not fuzz_string.isalnum(): continue fuzz_domain = expression.replace('*', fuzz_string) subdomains.add(fuzz_domain) utils.check_random_subdomain(subdomains) logger.log('DEBUG', f'Dictionary size based on fuzz mode: {len(subdomains)}') return subdomains
def gen_subdomains(expression, path): """ Generate subdomains :param str expression: generate subdomains's expression :param str path: path of wordlist :return set subdomains: list of subdomains """ subdomains = set() with open(path, encoding='utf-8', errors='ignore') as fd: for line in fd: word = line.strip().lower() if len(word) == 0: continue if not utils.is_subname(word): continue if word.startswith('.'): word = word[1:] if word.endswith('.'): word = word[:-1] subdomain = expression.replace('*', word) subdomains.add(subdomain) size = len(subdomains) logger.log('DEBUG', f'The size of the dictionary generated by {path} is {size}') if size == 0: logger.log('ALERT', 'Please check the dictionary content!') else: utils.check_random_subdomain(subdomains) return subdomains