mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-26 12:57:50 +08:00
重构
This commit is contained in:
@@ -261,7 +261,7 @@ class AIOBrute(Module):
|
||||
logger.log('INFOR', f'发现{self.domain}的子域: {hostname} '
|
||||
f'解析到: {name} IP: {ips}')
|
||||
self.subdomains.add(hostname)
|
||||
self.records[hostname] = str(ips)
|
||||
self.records[hostname] = str(ips)[1:-1]
|
||||
|
||||
async def main(self, domain, rx_queue):
|
||||
if not self.fuzz: # fuzz模式不探测域名是否使用泛解析
|
||||
|
||||
@@ -198,7 +198,8 @@ async def bulk_get_request(datas, port):
|
||||
futures = asyncio.as_completed(tasks)
|
||||
for future in tqdm.tqdm(futures,
|
||||
total=len(tasks),
|
||||
desc='Progress'):
|
||||
desc='Progress',
|
||||
ncols=60):
|
||||
await future
|
||||
|
||||
logger.log('INFOR', f'完成异步进行子域的GET请求')
|
||||
|
||||
+19
-17
@@ -1,5 +1,6 @@
|
||||
import asyncio
|
||||
import functools
|
||||
import socket
|
||||
|
||||
import tqdm
|
||||
from dns.resolver import Resolver
|
||||
@@ -32,7 +33,7 @@ async def dns_query_a(hostname):
|
||||
except Exception as e:
|
||||
logger.log('TRACE', e.args)
|
||||
answer = e
|
||||
return answer
|
||||
return hostname, answer
|
||||
|
||||
|
||||
async def aiodns_query_a(hostname):
|
||||
@@ -44,11 +45,15 @@ async def aiodns_query_a(hostname):
|
||||
"""
|
||||
try:
|
||||
loop = asyncio.get_event_loop()
|
||||
answer = await loop.getaddrinfo(hostname, 'http')
|
||||
except Exception as e:
|
||||
socket.setdefaulttimeout(20)
|
||||
# answer = await loop.getaddrinfo(hostname, 80)
|
||||
answer = await loop.run_in_executor(None,
|
||||
socket.gethostbyname_ex,
|
||||
hostname)
|
||||
except BaseException as e:
|
||||
logger.log('TRACE', e.args)
|
||||
answer = e
|
||||
return answer
|
||||
return hostname, answer
|
||||
|
||||
|
||||
def resolve_callback(future, index, datas):
|
||||
@@ -59,18 +64,13 @@ def resolve_callback(future, index, datas):
|
||||
:param index: 下标
|
||||
:param datas: 结果集
|
||||
"""
|
||||
try:
|
||||
answer = future.result()
|
||||
except Exception as e:
|
||||
datas[index]['ips'] = str(e.args)
|
||||
hostname, answer = future.result()
|
||||
if isinstance(answer, Exception):
|
||||
datas[index]['reason'] = str(answer.args)
|
||||
datas[index]['valid'] = 0
|
||||
else:
|
||||
if isinstance(answer, list):
|
||||
ips = {item[4][0] for item in answer}
|
||||
if isinstance(answer, tuple):
|
||||
ips = answer[2]
|
||||
datas[index]['ips'] = str(ips)[1:-1]
|
||||
else:
|
||||
datas[index]['ips'] = 'Something error'
|
||||
datas[index]['valid'] = 0
|
||||
|
||||
|
||||
async def bulk_query_a(datas):
|
||||
@@ -87,15 +87,17 @@ async def bulk_query_a(datas):
|
||||
if not data.get('ips'):
|
||||
subdomain = data.get('subdomain')
|
||||
task = asyncio.ensure_future(aiodns_query_a(subdomain))
|
||||
task.add_done_callback(functools.partial(resolve_callback,
|
||||
wrapped_callback = functools.partial(resolve_callback,
|
||||
index=i,
|
||||
datas=datas)) # 回调
|
||||
datas=datas)
|
||||
task.add_done_callback(wrapped_callback) # 回调
|
||||
tasks.append(task)
|
||||
if tasks: # 任务列表里有任务不空时才进行解析
|
||||
futures = asyncio.as_completed(tasks)
|
||||
for future in tqdm.tqdm(futures,
|
||||
total=len(tasks),
|
||||
desc='Progress'):
|
||||
desc='Progress',
|
||||
ncols=60):
|
||||
await future
|
||||
# await asyncio.wait(tasks) # 等待所有task完成
|
||||
logger.log('INFOR', '完成异步查询子域的A记录')
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ enable_http_request = True # HTTP请求子域(默认True)
|
||||
enable_wildcard_check = True # 开启泛解析检测 会去掉泛解析的子域
|
||||
# 爆破时使用的进程数(根据系统中CPU数量情况设置 不宜大于CPU数量 默认为系统中的CPU数量)
|
||||
brute_process_num = os.cpu_count()
|
||||
brute_coroutine_num = 128 # 爆破时每个进程下的协程数(不宜大于500)
|
||||
brute_coroutine_num = 2048 # 爆破时每个进程下的协程数(不宜大于500)
|
||||
# 爆破所使用的字典路径 默认data/subdomains.txt
|
||||
brute_wordlist_path = data_storage_path.joinpath('subnames.txt')
|
||||
brute_task_segment = 500
|
||||
|
||||
@@ -34,7 +34,9 @@ banner = f"""{yellow}
|
||||
___ _ _
|
||||
___ ___ ___| _|___ ___ ___| | | {version}{green}
|
||||
| . | | -_| _| . | _| .'| | | {blue}
|
||||
|___|_|_|___|_| |___|_| |__,|_|_| {white}git.io/fjHT1{end}
|
||||
|___|_|_|___|_| |___|_| |__,|_|_| {white}git.io/fjHT1
|
||||
|
||||
{red}OneForAll处于开发中,会进行版本快速迭代,请每次在使用前进行更新!{end}
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ class Takeover(Module):
|
||||
bar = tqdm()
|
||||
bar.total = len(self.subdomains)
|
||||
bar.desc = 'Progress'
|
||||
bar.ncols = 60
|
||||
while True:
|
||||
done = bar.total - self.subdomainq.qsize()
|
||||
bar.n = done
|
||||
|
||||
Reference in New Issue
Block a user