mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-26 04:47:48 +08:00
优化
This commit is contained in:
@@ -10,7 +10,6 @@ class VirusTotal(Query):
|
|||||||
Query.__init__(self)
|
Query.__init__(self)
|
||||||
self.source = 'VirusTotalQuery'
|
self.source = 'VirusTotalQuery'
|
||||||
self.module = 'Intelligence'
|
self.module = 'Intelligence'
|
||||||
self.addr = 'https://www.virustotal.com/ui/domains/{}/subdomains'
|
|
||||||
self.domain = domain
|
self.domain = domain
|
||||||
|
|
||||||
def query(self):
|
def query(self):
|
||||||
@@ -24,26 +23,16 @@ class VirusTotal(Query):
|
|||||||
'TE': 'Trailers'})
|
'TE': 'Trailers'})
|
||||||
self.proxy = self.get_proxy(self.source)
|
self.proxy = self.get_proxy(self.source)
|
||||||
params = {'limit': '40', 'cursor': next_cursor}
|
params = {'limit': '40', 'cursor': next_cursor}
|
||||||
resp = self.get(url=self.addr.format(self.domain), params=params)
|
addr = f'https://www.virustotal.com/ui/domains/{self.domain}/subdomains'
|
||||||
|
resp = self.get(url=addr, params=params)
|
||||||
if not resp:
|
if not resp:
|
||||||
return
|
break
|
||||||
data = resp.json()
|
subdomains = self.match_subdomains(resp)
|
||||||
subdomains = set()
|
if not subdomains:
|
||||||
datas = data.get('data')
|
|
||||||
|
|
||||||
if datas:
|
|
||||||
for data in datas:
|
|
||||||
subdomain = data.get('id')
|
|
||||||
if subdomain:
|
|
||||||
subdomains.add(subdomain)
|
|
||||||
else:
|
|
||||||
break
|
break
|
||||||
self.subdomains = self.subdomains.union(subdomains)
|
self.subdomains = self.subdomains.union(subdomains)
|
||||||
meta = data.get('meta')
|
data = resp.json()
|
||||||
if meta:
|
next_cursor = data.get('meta').get('cursor')
|
||||||
next_cursor = meta.get('cursor')
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
@@ -68,4 +57,4 @@ def run(domain):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run('example.com')
|
run('mi.com')
|
||||||
|
|||||||
@@ -8,24 +8,26 @@ class VirusTotalAPI(Query):
|
|||||||
self.domain = domain
|
self.domain = domain
|
||||||
self.module = 'Intelligence'
|
self.module = 'Intelligence'
|
||||||
self.source = 'VirusTotalAPIQuery'
|
self.source = 'VirusTotalAPIQuery'
|
||||||
self.addr = 'https://www.virustotal.com/vtapi/v2/domain/report'
|
|
||||||
self.key = settings.virustotal_api_key
|
self.key = settings.virustotal_api_key
|
||||||
|
|
||||||
def query(self):
|
def query(self):
|
||||||
"""
|
"""
|
||||||
向接口查询子域并做子域匹配
|
向接口查询子域并做子域匹配
|
||||||
"""
|
"""
|
||||||
self.header = self.get_header()
|
next_cursor = ''
|
||||||
self.proxy = self.get_proxy(self.source)
|
while True:
|
||||||
params = {'apikey': self.key, 'domain': self.domain}
|
self.header = self.get_header()
|
||||||
resp = self.get(self.addr, params)
|
self.header.update({'x-apikey': self.key})
|
||||||
if not resp:
|
self.proxy = self.get_proxy(self.source)
|
||||||
return
|
params = {'limit': '40', 'cursor': next_cursor}
|
||||||
json = resp.json()
|
addr = f'https://www.virustotal.com/api/v3/domains/{self.domain}/subdomains'
|
||||||
data = json.get('subdomains')
|
resp = self.get(url=addr, params=params)
|
||||||
if data:
|
subdomains = self.match_subdomains(resp)
|
||||||
subdomains = set(data)
|
if not subdomains:
|
||||||
|
break
|
||||||
self.subdomains = self.subdomains.union(subdomains)
|
self.subdomains = self.subdomains.union(subdomains)
|
||||||
|
data = resp.json()
|
||||||
|
next_cursor = data.get('meta').get('cursor')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
@@ -52,4 +54,4 @@ def run(domain):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run('example.com')
|
run('mi.com')
|
||||||
|
|||||||
Reference in New Issue
Block a user