mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-26 04:47:48 +08:00
优化
This commit is contained in:
@@ -8,7 +8,6 @@ class ShodanAPI(Search):
|
|||||||
self.domain = domain
|
self.domain = domain
|
||||||
self.module = 'Search'
|
self.module = 'Search'
|
||||||
self.source = 'ShodanAPISearch'
|
self.source = 'ShodanAPISearch'
|
||||||
self.addr = 'https://api.shodan.io/shodan/host/search'
|
|
||||||
self.key = settings.shodan_api_key
|
self.key = settings.shodan_api_key
|
||||||
|
|
||||||
def search(self):
|
def search(self):
|
||||||
@@ -17,17 +16,14 @@ class ShodanAPI(Search):
|
|||||||
"""
|
"""
|
||||||
self.header = self.get_header()
|
self.header = self.get_header()
|
||||||
self.proxy = self.get_proxy(self.source)
|
self.proxy = self.get_proxy(self.source)
|
||||||
query = 'hostname:.' + self.domain
|
url = f'https://api.shodan.io/dns/domain/{self.domain}?key={self.key}'
|
||||||
page = 1
|
resp = self.get(url)
|
||||||
while True:
|
if not resp:
|
||||||
params = {'key': self.key, 'page': page, 'query': query,
|
return
|
||||||
'minify': True, 'facets': {'hostnames'}}
|
data = resp.json()
|
||||||
resp = self.get(self.addr, params)
|
names = data.get('subdomains')
|
||||||
subdomains = self.match_subdomains(resp)
|
subdomain_str = str(set(map(lambda name: f'{name}.{self.domain}', names)))
|
||||||
if not subdomains: # 搜索没有发现子域名则停止搜索
|
self.subdomains = self.collect_subdomains(subdomain_str)
|
||||||
break
|
|
||||||
self.subdomains.update(subdomains)
|
|
||||||
page += 1
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
@@ -54,4 +50,4 @@ def run(domain):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run('example.com')
|
run('freebuf.com')
|
||||||
|
|||||||
Reference in New Issue
Block a user