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