mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-10-30 05:05:51 +08:00
修改为api调用
This commit is contained in:
+55
-61
@@ -1,61 +1,55 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
import queue
|
|
||||||
|
import config
|
||||||
import config
|
from common.query import Query
|
||||||
from common.query import Query
|
from config import logger
|
||||||
from config import logger
|
|
||||||
|
|
||||||
|
class ThreatBookAPI(Query):
|
||||||
class ThreatBookAPI(Query):
|
def __init__(self, domain):
|
||||||
def __init__(self, domain):
|
Query.__init__(self)
|
||||||
Query.__init__(self)
|
self.domain = self.register(domain)
|
||||||
self.domain = self.register(domain)
|
self.module = 'Intelligence'
|
||||||
self.module = 'Intelligence'
|
self.source = 'ThreatBookAPIQuery'
|
||||||
self.source = 'ThreatBookAPIQuery'
|
self.addr = 'https://x.threatbook.cn/api/v1/domain/query'
|
||||||
self.addr = 'https://x.threatbook.cn/api/v1/domain/query'
|
self.key = config.threatbook_api_key
|
||||||
self.key = config.threatbook_api_key
|
|
||||||
|
def query(self, domain):
|
||||||
def query(self, domain):
|
"""
|
||||||
"""
|
向接口查询子域并做子域匹配
|
||||||
向接口查询子域并做子域匹配
|
"""
|
||||||
"""
|
self.header = self.get_header()
|
||||||
self.header = self.get_header()
|
self.proxy = self.get_proxy(self.source)
|
||||||
self.proxy = self.get_proxy(self.source)
|
params = {'apikey': self.key, 'domain': domain, 'field': 'sub_domains'}
|
||||||
params = {'apikey': self.key, 'domain': domain, 'field': 'sub_domains'}
|
resp = self.post(self.addr, params)
|
||||||
resp = self.post(self.addr, params)
|
if not resp:
|
||||||
if not resp:
|
return
|
||||||
return
|
subdomain_find = self.match(self.domain, str(resp.json()))
|
||||||
subdomain_find = self.match(self.domain, str(resp.json()))
|
self.subdomains = self.subdomains.union(subdomain_find)
|
||||||
self.subdomains = self.subdomains.union(subdomain_find)
|
|
||||||
|
def run(self):
|
||||||
def run(self, rx_queue):
|
"""
|
||||||
"""
|
类执行入口
|
||||||
类执行入口
|
"""
|
||||||
"""
|
if not self.check(self.key):
|
||||||
if not self.key:
|
return
|
||||||
logger.log('ERROR', f'{self.source}模块API配置错误')
|
self.begin()
|
||||||
logger.log('ALERT', f'不执行{self.source}模块')
|
self.query(self.domain)
|
||||||
return
|
self.save_json()
|
||||||
self.begin()
|
self.gen_result()
|
||||||
self.query(self.domain)
|
self.save_db()
|
||||||
self.save_json()
|
self.finish()
|
||||||
self.gen_result()
|
|
||||||
self.save_db()
|
|
||||||
rx_queue.put(self.results)
|
def do(domain): # 统一入口名字 方便多线程调用
|
||||||
self.finish()
|
"""
|
||||||
|
类统一调用入口
|
||||||
|
|
||||||
def do(domain, rx_queue): # 统一入口名字 方便多线程调用
|
:param str domain: 域名
|
||||||
"""
|
"""
|
||||||
类统一调用入口
|
query = ThreatBookAPI(domain)
|
||||||
|
query.run()
|
||||||
:param str domain: 域名
|
|
||||||
:param rx_queue: 结果集队列
|
|
||||||
"""
|
if __name__ == '__main__':
|
||||||
query = ThreatBookAPI(domain)
|
do('example.com')
|
||||||
query.run(rx_queue)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
result_queue = queue.Queue()
|
|
||||||
do('example.com', result_queue)
|
|
||||||
Reference in New Issue
Block a user