mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-10-25 00:56:14 +08:00
Update brute.py
This commit is contained in:
@@ -94,7 +94,7 @@ def gen_fuzz_subdomains(expression, rule):
|
||||
subdomains = list()
|
||||
fuzz_count = exrex.count(rule)
|
||||
if fuzz_count > 10000000:
|
||||
logger.log('ALERT', f'The dictionary generated by this rule is so large:{fuzz_count} > 10000000')
|
||||
logger.log('ALERT', f'The dictionary generated by this rule is too large:{fuzz_count} > 10000000')
|
||||
logger.log('DEBUG', f'Dictionary size based on fuzz mode: {fuzz_count}')
|
||||
for fuzz_string in exrex.generate(rule):
|
||||
fuzz_string = fuzz_string.lower()
|
||||
@@ -493,7 +493,7 @@ class Brute(Module):
|
||||
self.check_env = True
|
||||
|
||||
def gen_brute_dict(self, domain):
|
||||
logger.log('INFOR', f'正在为{domain}生成爆破字典')
|
||||
logger.log('INFOR', f'Generating dictionary for {domain}')
|
||||
dict_set = set()
|
||||
# 如果domain不是self.subdomain 而是self.domain的子域则生成递归爆破字典
|
||||
if self.place is None:
|
||||
@@ -512,41 +512,41 @@ class Brute(Module):
|
||||
# logger.log('INFOR', f'正在去重爆破字典')
|
||||
# dict_set = utils.uniq_dict_list(dict_set)
|
||||
count = len(dict_set)
|
||||
logger.log('INFOR', f'生成的爆破字典大小为{count}')
|
||||
logger.log('INFOR', f'Dictionary size: {count}')
|
||||
if count > 10000000:
|
||||
logger.log('ALERT', f'注意生成的爆破字典太大:{count} > 10000000')
|
||||
logger.log('ALERT', f'The dictionary generated is too large:{count} > 10000000')
|
||||
return dict_set
|
||||
|
||||
def check_brute_params(self):
|
||||
if not (self.word or self.fuzz):
|
||||
logger.log('FATAL', f'请至少指定一种爆破模式')
|
||||
logger.log('FATAL', f'Please specify at least one brute mode')
|
||||
exit(1)
|
||||
if len(self.domains) > 1:
|
||||
self.bulk = True
|
||||
if self.fuzz:
|
||||
if self.place is None or self.rule is None:
|
||||
logger.log('FATAL', f'没有指定fuzz位置或规则')
|
||||
logger.log('FATAL', f'No fuzz position or rules specified')
|
||||
exit(1)
|
||||
if self.bulk:
|
||||
logger.log('FATAL', f'批量爆破的场景下不能使用fuzz模式')
|
||||
logger.log('FATAL', f'Cannot use fuzz mode in the bulk brute')
|
||||
exit(1)
|
||||
if self.recursive_brute:
|
||||
logger.log('FATAL', f'使用fuzz模式下不能使用递归爆破')
|
||||
logger.log('FATAL', f'Cannot use recursive brute in fuzz mode')
|
||||
exit(1)
|
||||
fuzz_count = self.place.count('*')
|
||||
if fuzz_count < 1:
|
||||
logger.log('FATAL', f'没有指定fuzz位置')
|
||||
logger.log('FATAL', f'No fuzz position specified')
|
||||
exit(1)
|
||||
if fuzz_count > 1:
|
||||
logger.log('FATAL', f'只能指定1个fuzz位置')
|
||||
logger.log('FATAL', f'Only one fuzz position can be specified')
|
||||
exit(1)
|
||||
if self.domain not in self.place:
|
||||
logger.log('FATAL', f'指定fuzz的域名有误')
|
||||
logger.log('FATAL', f'Incorrect domain for fuzz')
|
||||
exit(1)
|
||||
|
||||
def main(self, domain):
|
||||
start = time.time()
|
||||
logger.log('INFOR', f'正在爆破域名{domain}')
|
||||
logger.log('INFOR', f'Blasting {domain} ...')
|
||||
massdns_dir = setting.third_party_dir.joinpath('massdns')
|
||||
result_dir = setting.result_save_dir
|
||||
temp_dir = result_dir.joinpath('temp')
|
||||
@@ -597,9 +597,9 @@ class Brute(Module):
|
||||
delete_file(dict_path, output_paths)
|
||||
end = time.time()
|
||||
self.elapse = round(end - start, 1)
|
||||
logger.log('INFOR', f'{self.source} module 耗时{self.elapse}秒'
|
||||
f'发现{domain}的子域{len(self.subdomains)}个')
|
||||
logger.log('DEBUG', f'{self.source} module 发现{domain}的子域:\n'
|
||||
logger.log('INFOR', f'{self.source} module spends {self.elapse} seconds'
|
||||
f'Found {len(self.subdomains)} subdomains of {domain}')
|
||||
logger.log('DEBUG', f'{self.source} module found subdomains of {domain}:\n'
|
||||
f'{self.subdomains}')
|
||||
self.gen_result(brute=dict_len, valid=len(self.subdomains))
|
||||
self.save_db()
|
||||
@@ -614,7 +614,7 @@ class Brute(Module):
|
||||
for self.domain in self.domains:
|
||||
self.check_brute_params()
|
||||
if self.recursive_brute:
|
||||
logger.log('INFOR', f'开始递归爆破{self.domain}的第1层子域')
|
||||
logger.log('INFOR', f'Start recursively brute the first layer subdomain of {self.domain}')
|
||||
valid_subdomains = self.main(self.domain)
|
||||
all_subdomains.extend(valid_subdomains)
|
||||
|
||||
@@ -623,8 +623,8 @@ class Brute(Module):
|
||||
if self.recursive_brute:
|
||||
for layer_num in range(1, self.recursive_depth):
|
||||
# 之前已经做过1层子域爆破 当前实际递归层数是layer+1
|
||||
logger.log('INFOR', f'开始递归爆破{self.domain}的'
|
||||
f'第{layer_num + 1}层子域')
|
||||
logger.log('INFOR', f'Start recursively brute'
|
||||
f'the {layer_num + 1} layer subdomain of {self.domain}')
|
||||
for subdomain in all_subdomains:
|
||||
self.place = '*.' + subdomain
|
||||
# 进行下一层子域爆破的限制条件
|
||||
@@ -633,7 +633,7 @@ class Brute(Module):
|
||||
valid_subdomains = self.main(subdomain)
|
||||
all_subdomains.extend(valid_subdomains)
|
||||
|
||||
logger.log('INFOR', f'结束执行{self.source} module 爆破域名{self.domain}')
|
||||
logger.log('INFOR', f'Finished {self.source} module\'s brute {self.domain}')
|
||||
if not self.path:
|
||||
name = f'{self.domain}_brute_result.{self.format}'
|
||||
self.path = setting.result_save_dir.joinpath(name)
|
||||
|
||||
Reference in New Issue
Block a user