mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-10-25 00:56:14 +08:00
use censys v2 api
This commit is contained in:
@@ -9,7 +9,7 @@ class CensysAPI(Query):
|
|||||||
self.domain = domain
|
self.domain = domain
|
||||||
self.module = 'Certificate'
|
self.module = 'Certificate'
|
||||||
self.source = "CensysAPIQuery"
|
self.source = "CensysAPIQuery"
|
||||||
self.addr = 'https://search.censys.io/api/v1/search/certificates'
|
self.addr = 'https://search.censys.io/api/v2/certificates/search'
|
||||||
self.id = settings.censys_api_id
|
self.id = settings.censys_api_id
|
||||||
self.secret = settings.censys_api_secret
|
self.secret = settings.censys_api_secret
|
||||||
self.delay = 3.0 # Censys 接口查询速率限制 最快2.5秒查1次
|
self.delay = 3.0 # Censys 接口查询速率限制 最快2.5秒查1次
|
||||||
@@ -20,26 +20,30 @@ class CensysAPI(Query):
|
|||||||
"""
|
"""
|
||||||
self.header = self.get_header()
|
self.header = self.get_header()
|
||||||
self.proxy = self.get_proxy(self.source)
|
self.proxy = self.get_proxy(self.source)
|
||||||
data = {
|
params = {
|
||||||
'query': f'parsed.names: {self.domain}',
|
'q': f'names: {self.domain}',
|
||||||
'page': 1,
|
'per_page': 100,
|
||||||
'fields': ['parsed.subject_dn', 'parsed.names'],
|
}
|
||||||
'flatten': True}
|
resp = self.get(self.addr, params=params, auth=(self.id, self.secret))
|
||||||
resp = self.post(self.addr, json=data, auth=(self.id, self.secret))
|
|
||||||
if not resp:
|
if not resp:
|
||||||
return
|
return
|
||||||
json = resp.json()
|
json = resp.json()
|
||||||
status = json.get('status')
|
status = json.get('status')
|
||||||
if status != 'ok':
|
if status != 'OK':
|
||||||
logger.log('ALERT', f'{self.source} module {status}')
|
logger.log('ALERT', f'{self.source} module {status}')
|
||||||
return
|
return
|
||||||
subdomains = self.match_subdomains(resp.text)
|
subdomains = self.match_subdomains(resp.text)
|
||||||
self.subdomains.update(subdomains)
|
self.subdomains.update(subdomains)
|
||||||
pages = json.get('metadata').get('pages')
|
next_cursor = json.get("result").get("links").get("next")
|
||||||
for page in range(2, pages + 1):
|
while next_cursor:
|
||||||
data['page'] = page
|
tmp_params = {
|
||||||
resp = self.post(self.addr, json=data, auth=(self.id, self.secret))
|
'q': f'names: {self.domain}',
|
||||||
self.subdomains = self.collect_subdomains(resp)
|
'per_page': 100,
|
||||||
|
"cursor": next_cursor
|
||||||
|
}
|
||||||
|
tmp_resp = self.get(self.addr, params=tmp_params, auth=(self.id, self.secret))
|
||||||
|
self.subdomains = self.collect_subdomains(tmp_resp)
|
||||||
|
next_cursor = tmp_resp.json().get("result").get("links").get("next")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user