python调用censys接口进行ipv4查询
2021-07-12 10:05
标签:查询 pass res on() protoc www. def result com python调用censys接口进行ipv4查询 标签:查询 pass res on() protoc www. def result com 原文地址:https://www.cnblogs.com/websec/p/9547412.htmldef censysApi(searchQuery):
API_URL = "https://www.censys.io/api/v1"
UID = "51645b5b-b129-499f-a008-c7cf602ed76b"
SECRET = "xJVPTgyQmgNb8O8JdGYZZOJw8MBk0RtT"
dataFirstForPage = {
"query": searchQuery,
"page": 1,
"fields": []
}
resData = requests.post(API_URL + "/search/ipv4", data=json.dumps(dataFirstForPage),auth=(UID, SECRET),headers=headers)
resultForPage = resData.json()
pages = int(resultForPage[‘metadata‘][‘pages‘])
try:
for page in range(1,pages+1):
data = {
"query": searchQuery,
"page": page,
"fields": ["ip","protocols"]
}
sleep(1)
req = requests.post(API_URL + "/search/ipv4", data=json.dumps(data), auth=(UID, SECRET))
resForResult = req.json()
for result in resForResult["results"]:
print result[‘ip‘]+","+result[‘protocols‘]
except:
pass
censysApi("baidu.com")
文章标题:python调用censys接口进行ipv4查询
文章链接:http://soscw.com/index.php/essay/104107.html