mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-26 12:57:50 +08:00
优化内存
This commit is contained in:
@@ -90,9 +90,9 @@ def gen_subdomains(expression, path):
|
|||||||
|
|
||||||
:param str expression: generate subdomains's expression
|
:param str expression: generate subdomains's expression
|
||||||
:param str path: path of wordlist
|
:param str path: path of wordlist
|
||||||
:return list subdomains: list of subdomains
|
:return set subdomains: list of subdomains
|
||||||
"""
|
"""
|
||||||
subdomains = list()
|
subdomains = set()
|
||||||
with open(path, encoding='utf-8', errors='ignore') as fd:
|
with open(path, encoding='utf-8', errors='ignore') as fd:
|
||||||
for line in fd:
|
for line in fd:
|
||||||
word = line.strip().lower()
|
word = line.strip().lower()
|
||||||
@@ -105,14 +105,13 @@ def gen_subdomains(expression, path):
|
|||||||
if word.endswith('.'):
|
if word.endswith('.'):
|
||||||
word = word[:-1]
|
word = word[:-1]
|
||||||
subdomain = expression.replace('*', word)
|
subdomain = expression.replace('*', word)
|
||||||
subdomains.append(subdomain)
|
subdomains.add(subdomain)
|
||||||
size = len(subdomains)
|
size = len(subdomains)
|
||||||
logger.log('DEBUG', f'The size of the dictionary generated by {path} is {size}')
|
logger.log('DEBUG', f'The size of the dictionary generated by {path} is {size}')
|
||||||
if size == 0:
|
if size == 0:
|
||||||
logger.log('ALERT', 'Please check the dictionary content!')
|
logger.log('ALERT', 'Please check the dictionary content!')
|
||||||
else:
|
else:
|
||||||
random_domain = random.choice(subdomains)
|
utils.check_random_subdomain(subdomains)
|
||||||
logger.log('ALERT', f'Please check whether {random_domain} is correct or not')
|
|
||||||
return subdomains
|
return subdomains
|
||||||
|
|
||||||
|
|
||||||
@@ -123,12 +122,12 @@ def gen_fuzz_subdomains(expression, rule, fuzzlist):
|
|||||||
:param str expression: generate subdomains's expression
|
:param str expression: generate subdomains's expression
|
||||||
:param str rule: regexp rule
|
:param str rule: regexp rule
|
||||||
:param str fuzzlist: fuzz dictionary
|
:param str fuzzlist: fuzz dictionary
|
||||||
:return list subdomains: list of subdomains
|
:return set subdomains: list of subdomains
|
||||||
"""
|
"""
|
||||||
subdomains = list()
|
subdomains = set()
|
||||||
if fuzzlist:
|
if fuzzlist:
|
||||||
fuzz_domain = gen_subdomains(expression, fuzzlist)
|
fuzz_domain = gen_subdomains(expression, fuzzlist)
|
||||||
subdomains = subdomains.extend(fuzz_domain)
|
subdomains.update(fuzz_domain)
|
||||||
if rule:
|
if rule:
|
||||||
fuzz_count = exrex.count(rule)
|
fuzz_count = exrex.count(rule)
|
||||||
if fuzz_count > 10000000:
|
if fuzz_count > 10000000:
|
||||||
@@ -139,9 +138,8 @@ def gen_fuzz_subdomains(expression, rule, fuzzlist):
|
|||||||
if not fuzz_string.isalnum():
|
if not fuzz_string.isalnum():
|
||||||
continue
|
continue
|
||||||
fuzz_domain = expression.replace('*', fuzz_string)
|
fuzz_domain = expression.replace('*', fuzz_string)
|
||||||
subdomains.append(fuzz_domain)
|
subdomains.add(fuzz_domain)
|
||||||
random_domain = random.choice(subdomains)
|
utils.check_random_subdomain(subdomains)
|
||||||
logger.log('ALERT', f'Please check whether {random_domain} is correct or not')
|
|
||||||
logger.log('DEBUG', f'Dictionary size based on fuzz mode: {len(subdomains)}')
|
logger.log('DEBUG', f'Dictionary size based on fuzz mode: {len(subdomains)}')
|
||||||
return subdomains
|
return subdomains
|
||||||
|
|
||||||
@@ -152,7 +150,7 @@ def gen_word_subdomains(expression, path):
|
|||||||
|
|
||||||
:param str expression: generate subdomains's expression
|
:param str expression: generate subdomains's expression
|
||||||
:param str path: path of wordlist
|
:param str path: path of wordlist
|
||||||
:return list subdomains: list of subdomains
|
:return set subdomains: list of subdomains
|
||||||
"""
|
"""
|
||||||
subdomains = gen_subdomains(expression, path)
|
subdomains = gen_subdomains(expression, path)
|
||||||
logger.log('DEBUG', f'Dictionary based on word mode size: {len(subdomains)}')
|
logger.log('DEBUG', f'Dictionary based on word mode size: {len(subdomains)}')
|
||||||
@@ -543,11 +541,10 @@ class Brute(Module):
|
|||||||
wordlist = self.recursive_nextlist
|
wordlist = self.recursive_nextlist
|
||||||
if self.word:
|
if self.word:
|
||||||
word_subdomains = gen_word_subdomains(self.place, wordlist)
|
word_subdomains = gen_word_subdomains(self.place, wordlist)
|
||||||
# set可以合并list
|
dict_set.update(word_subdomains)
|
||||||
dict_set = dict_set.union(word_subdomains)
|
|
||||||
if self.fuzz:
|
if self.fuzz:
|
||||||
fuzz_subdomains = gen_fuzz_subdomains(self.place, self.rule, self.fuzzlist)
|
fuzz_subdomains = gen_fuzz_subdomains(self.place, self.rule, self.fuzzlist)
|
||||||
dict_set = dict_set.union(fuzz_subdomains)
|
dict_set.update(fuzz_subdomains)
|
||||||
count = len(dict_set)
|
count = len(dict_set)
|
||||||
logger.log('INFOR', f'Dictionary size: {count}')
|
logger.log('INFOR', f'Dictionary size: {count}')
|
||||||
if count > 10000000:
|
if count > 10000000:
|
||||||
|
|||||||
@@ -728,3 +728,13 @@ def match_subdomains(domain, html, distinct=True, fuzzy=True):
|
|||||||
return set(deal)
|
return set(deal)
|
||||||
else:
|
else:
|
||||||
return list(deal)
|
return list(deal)
|
||||||
|
|
||||||
|
|
||||||
|
def check_random_subdomain(subdomains):
|
||||||
|
if not subdomains:
|
||||||
|
logger.log('ALERT', f'The generated dictionary is empty')
|
||||||
|
return False
|
||||||
|
for subdomain in subdomains:
|
||||||
|
if subdomain:
|
||||||
|
logger.log('ALERT', f'Please check whether {subdomain} is correct or not')
|
||||||
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user