mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-25 20:37:48 +08:00
fixed #275
This commit is contained in:
@@ -342,7 +342,6 @@ class Brute(Module):
|
|||||||
self.ips_times = dict() # IP集合出现次数
|
self.ips_times = dict() # IP集合出现次数
|
||||||
self.enable_wildcard = None # 当前域名是否使用泛解析
|
self.enable_wildcard = None # 当前域名是否使用泛解析
|
||||||
self.quite = False
|
self.quite = False
|
||||||
self.in_china = None
|
|
||||||
|
|
||||||
def gen_brute_dict(self, domain):
|
def gen_brute_dict(self, domain):
|
||||||
logger.log('INFOR', f'Generating dictionary for {domain}')
|
logger.log('INFOR', f'Generating dictionary for {domain}')
|
||||||
@@ -425,7 +424,7 @@ class Brute(Module):
|
|||||||
|
|
||||||
if self.enable_wildcard:
|
if self.enable_wildcard:
|
||||||
wildcard_ips, wildcard_ttl = wildcard.collect_wildcard_record(domain, ns_ip_list)
|
wildcard_ips, wildcard_ttl = wildcard.collect_wildcard_record(domain, ns_ip_list)
|
||||||
ns_path = utils.get_ns_path(self.in_china, self.enable_wildcard, ns_ip_list)
|
ns_path = utils.get_ns_path(settings.use_china_nameservers, self.enable_wildcard, ns_ip_list)
|
||||||
|
|
||||||
dict_set = self.gen_brute_dict(domain)
|
dict_set = self.gen_brute_dict(domain)
|
||||||
|
|
||||||
@@ -459,8 +458,6 @@ class Brute(Module):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
logger.log('INFOR', f'Start running {self.source} module')
|
logger.log('INFOR', f'Start running {self.source} module')
|
||||||
if self.in_china is None:
|
|
||||||
_, self.in_china = utils.get_net_env()
|
|
||||||
self.domains = utils.get_domains(self.target, self.targets)
|
self.domains = utils.get_domains(self.target, self.targets)
|
||||||
for self.domain in self.domains:
|
for self.domain in self.domains:
|
||||||
self.results = list() # 置空
|
self.results = list() # 置空
|
||||||
|
|||||||
+30
-23
@@ -497,28 +497,35 @@ def delete_file(*paths):
|
|||||||
@tenacity.retry(stop=tenacity.stop_after_attempt(3),
|
@tenacity.retry(stop=tenacity.stop_after_attempt(3),
|
||||||
wait=tenacity.wait_fixed(2))
|
wait=tenacity.wait_fixed(2))
|
||||||
def check_net():
|
def check_net():
|
||||||
urls = ['http://ip-api.com/json/']
|
times = 0
|
||||||
url = random.choice(urls)
|
while True:
|
||||||
header = {'User_Agent': 'curl'}
|
times += 1
|
||||||
timeout = settings.request_timeout_second
|
urls = ['https://www.baidu.com', 'https://www.bing.com',
|
||||||
verify = settings.request_ssl_verify
|
'https://www.cloudflare.com', 'https://www.akamai.com/',
|
||||||
logger.log('DEBUG', f'Trying to access {url}')
|
'https://www.fastly.com/', 'https://www.amazon.com/']
|
||||||
session = requests.Session()
|
url = random.choice(urls)
|
||||||
session.trust_env = False
|
logger.log('DEBUG', f'Trying to access {url}')
|
||||||
try:
|
header = get_random_header()
|
||||||
rsp = session.get(url, headers=header, timeout=timeout, verify=verify)
|
proxy = get_proxy()
|
||||||
except Exception as e:
|
timeout = settings.request_timeout_second
|
||||||
logger.log('ERROR', e.args)
|
verify = settings.request_ssl_verify
|
||||||
logger.log('ALERT', 'Unable to access Internet, retrying...')
|
session = requests.Session()
|
||||||
raise e
|
session.trust_env = False
|
||||||
logger.log('DEBUG', 'Access to Internet OK')
|
session = requests.Session()
|
||||||
country = rsp.json().get('country').lower()
|
session.trust_env = False
|
||||||
if country in ['cn', 'china']:
|
try:
|
||||||
logger.log('DEBUG', f'The computer is located in China')
|
rsp = session.get(url, headers=header, proxies=proxy,
|
||||||
return True, True
|
timeout=timeout, verify=verify)
|
||||||
else:
|
except Exception as e:
|
||||||
logger.log('DEBUG', f'The computer is not located in China')
|
logger.log('ERROR', e.args)
|
||||||
return True, False
|
logger.log('ALERT', f'Unable to access Internet, retrying for the {times}th time')
|
||||||
|
else:
|
||||||
|
if rsp.status_code == 200:
|
||||||
|
logger.log('DEBUG', 'Access to Internet OK')
|
||||||
|
return True
|
||||||
|
if times >= 3:
|
||||||
|
logger.log('ALERT', 'Access to Internet failed')
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def check_dep():
|
def check_dep():
|
||||||
@@ -540,7 +547,7 @@ def get_net_env():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.log('DEBUG', e.args)
|
logger.log('DEBUG', e.args)
|
||||||
logger.log('ALERT', 'Please check your network environment.')
|
logger.log('ALERT', 'Please check your network environment.')
|
||||||
return False, None
|
return False
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ result_save_dir = relative_directory.joinpath('results') # 结果保存目录
|
|||||||
temp_save_dir = result_save_dir.joinpath('temp')
|
temp_save_dir = result_save_dir.joinpath('temp')
|
||||||
|
|
||||||
# OneForAll入口参数设置
|
# OneForAll入口参数设置
|
||||||
|
enable_check_network = True # 开启网络环境检查
|
||||||
enable_check_version = True # 开启最新版本检查
|
enable_check_version = True # 开启最新版本检查
|
||||||
enable_brute_module = True # 使用爆破模块(默认True)
|
enable_brute_module = True # 使用爆破模块(默认True)
|
||||||
enable_dns_resolve = True # 使用DNS解析子域(默认True)
|
enable_dns_resolve = True # 使用DNS解析子域(默认True)
|
||||||
@@ -54,6 +55,7 @@ brute_socket_num = 1 # 爆破时每个进程下的socket数量
|
|||||||
brute_resolve_num = 15 # 解析失败时尝试换名称服务器重查次数
|
brute_resolve_num = 15 # 解析失败时尝试换名称服务器重查次数
|
||||||
# 爆破所使用的字典路径(默认None则使用data/subdomains.txt,自定义字典请使用绝对路径)
|
# 爆破所使用的字典路径(默认None则使用data/subdomains.txt,自定义字典请使用绝对路径)
|
||||||
brute_wordlist_path = None
|
brute_wordlist_path = None
|
||||||
|
use_china_nameservers = True # 使用中国域名服务器 如果你所在网络不在中国则建议设置False
|
||||||
# 域名的权威DNS名称服务器的保存路径 当域名开启了泛解析时会使用该名称服务器来进行A记录查询
|
# 域名的权威DNS名称服务器的保存路径 当域名开启了泛解析时会使用该名称服务器来进行A记录查询
|
||||||
authoritative_dns_path = data_storage_dir.joinpath('authoritative_dns.txt')
|
authoritative_dns_path = data_storage_dir.joinpath('authoritative_dns.txt')
|
||||||
enable_recursive_brute = False # 是否使用递归爆破(默认False)
|
enable_recursive_brute = False # 是否使用递归爆破(默认False)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ relative_directory = pathlib.Path(__file__).parent.parent # OneForAll代码相
|
|||||||
data_storage_dir = relative_directory.joinpath('data') # 数据存放目录
|
data_storage_dir = relative_directory.joinpath('data') # 数据存放目录
|
||||||
|
|
||||||
# OneForAll入口参数设置
|
# OneForAll入口参数设置
|
||||||
|
enable_check_network = True # 开启网络环境检查
|
||||||
enable_check_version = True # 开启最新版本检查
|
enable_check_version = True # 开启最新版本检查
|
||||||
enable_brute_module = True # 使用爆破模块(默认True)
|
enable_brute_module = True # 使用爆破模块(默认True)
|
||||||
enable_dns_resolve = True # 使用DNS解析子域(默认True)
|
enable_dns_resolve = True # 使用DNS解析子域(默认True)
|
||||||
@@ -38,6 +39,7 @@ enable_partial_module = [] # 启用部分收集模块 必须禁用enable_all_mo
|
|||||||
brute_concurrent_num = 2000 # 爆破时并发查询数量(默认2000,最大推荐10000)
|
brute_concurrent_num = 2000 # 爆破时并发查询数量(默认2000,最大推荐10000)
|
||||||
# 爆破所使用的字典路径(默认None则使用data/subdomains.txt,自定义字典请使用绝对路径)
|
# 爆破所使用的字典路径(默认None则使用data/subdomains.txt,自定义字典请使用绝对路径)
|
||||||
brute_wordlist_path = None
|
brute_wordlist_path = None
|
||||||
|
use_china_nameservers = True # 使用中国域名服务器 如果你所在网络不在中国则建议设置False
|
||||||
enable_recursive_brute = False # 是否使用递归爆破(默认False)
|
enable_recursive_brute = False # 是否使用递归爆破(默认False)
|
||||||
brute_recursive_depth = 2 # 递归爆破深度(默认2层)
|
brute_recursive_depth = 2 # 递归爆破深度(默认2层)
|
||||||
# 爆破下一层子域所使用的字典路径(默认None则使用data/subnames_next.txt,自定义字典请使用绝对路径)
|
# 爆破下一层子域所使用的字典路径(默认None则使用data/subnames_next.txt,自定义字典请使用绝对路径)
|
||||||
|
|||||||
+1
-3
@@ -98,7 +98,6 @@ class OneForAll(object):
|
|||||||
self.domains = set() # All domains that are to be collected
|
self.domains = set() # All domains that are to be collected
|
||||||
self.data = list() # The subdomain results of the current domain
|
self.data = list() # The subdomain results of the current domain
|
||||||
self.datas = list() # All subdomain results of the domain
|
self.datas = list() # All subdomain results of the domain
|
||||||
self.in_china = None
|
|
||||||
self.access_internet = False
|
self.access_internet = False
|
||||||
self.enable_wildcard = False
|
self.enable_wildcard = False
|
||||||
|
|
||||||
@@ -166,7 +165,6 @@ class OneForAll(object):
|
|||||||
# may cause other network tasks to be error
|
# may cause other network tasks to be error
|
||||||
brute = Brute(self.domain, word=True, export=False)
|
brute = Brute(self.domain, word=True, export=False)
|
||||||
brute.enable_wildcard = self.enable_wildcard
|
brute.enable_wildcard = self.enable_wildcard
|
||||||
brute.in_china = self.in_china
|
|
||||||
brute.quite = True
|
brute.quite = True
|
||||||
brute.run()
|
brute.run()
|
||||||
|
|
||||||
@@ -237,7 +235,7 @@ class OneForAll(object):
|
|||||||
logger.log('DEBUG', 'Python ' + utils.python_version())
|
logger.log('DEBUG', 'Python ' + utils.python_version())
|
||||||
logger.log('DEBUG', 'OneForAll ' + version)
|
logger.log('DEBUG', 'OneForAll ' + version)
|
||||||
utils.check_dep()
|
utils.check_dep()
|
||||||
self.access_internet, self.in_china = utils.get_net_env()
|
self.access_internet = utils.get_net_env()
|
||||||
if self.access_internet and settings.enable_check_version:
|
if self.access_internet and settings.enable_check_version:
|
||||||
utils.check_version(version)
|
utils.check_version(version)
|
||||||
logger.log('INFOR', 'Start running OneForAll')
|
logger.log('INFOR', 'Start running OneForAll')
|
||||||
|
|||||||
Reference in New Issue
Block a user