From d2dc83ebb2a39fc121577d116d766b84f0a87613 Mon Sep 17 00:00:00 2001 From: shmilylty Date: Fri, 16 Aug 2019 16:22:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ThreatCrowd=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oneforall/modules/datasets/threatcrowd.py | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 oneforall/modules/datasets/threatcrowd.py diff --git a/oneforall/modules/datasets/threatcrowd.py b/oneforall/modules/datasets/threatcrowd.py new file mode 100644 index 0000000..5787ddb --- /dev/null +++ b/oneforall/modules/datasets/threatcrowd.py @@ -0,0 +1,55 @@ +import cloudscraper + +from common.query import Query +from config import logger + + +class ThreatCrowd(Query): + def __init__(self, domain): + Query.__init__(self) + self.domain = self.register(domain) + self.source = 'ThreatCrowdQuery' + self.addr = 'https://www.threatcrowd.org/searchApi' \ + '/v2/domain/report?domain=' + + def query(self): + # 绕过cloudFlare验证 + scraper = cloudscraper.create_scraper() + scraper.interpreter = 'js2py' + scraper.proxies = self.get_proxy(self.source) + url = self.addr + self.domain + try: + resp = scraper.get(url) + except Exception as e: + logger.log('ERROR', e.args) + return + if not resp: + return + subdomains_find = self.match(self.domain, str(resp.json())) + # 合并搜索子域名搜索结果 + self.subdomains = self.subdomains.union(subdomains_find) + + def run(self): + """ + 类执行入口 + """ + self.begin() + self.query() + self.finish() + self.save_json() + self.gen_result() + self.save_db() + + +def do(domain): # 统一入口名字 方便多线程调用 + """ + 类统一调用入口 + + :param str domain: 域名 + """ + query = ThreatCrowd(domain) + query.run() + + +if __name__ == '__main__': + do('example.com')