censys二次开发环境搭建
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了censys二次开发环境搭建相关的知识,希望对你有一定的参考价值。
环境准备
本机环境 ubuntu 17.04,python2.7.13
替换阿里源
wget https://git.io/superupdate.sh
bash superupdate.sh
安装相关依赖
apt install
安装censys
pip install
中间过程报错,缺少setuptools,还需要升级一下pip
分别执行以下命令:
pip install setuptools
pip install
然后再次安装censys即成功
pip install
测试
官方测试代码
Below is a sample Python script that connects to the API and lists raw datasets that are available for download.
import sys
import requests
API_URL = "https://censys.io/api/v1"
UID = "406dd40f-f68e-42c4-b8e6-6a6078185715"
SECRET = "2j7Eoe9RyJLBMXSyLui4fo0a4AJGz3lo"
res = requests.get(API_URL + "/data", auth=(UID, SECRET))
if res.status_code != 200:
print("error occurred: %s" % res.json()["error"])
sys.exit(1)
for name, series in res.json()["raw_series"].items():
print(series["name"], "was last updated at", series["latest_result"]["timestamp"])
Censys Python Library. We also maintain a Python library for interacting with the API, which can be installed with Pip: pip install censys
.
Below is a sample script that iterates over NSS trusted certificates:
import censys.certificates
UID = "406dd40f-f68e-42c4-b8e6-6a6078185715"
SECRET = "2j7Eoe9RyJLBMXSyLui4fo0a4AJGz3lo"
certificates = censys.certificates.CensysCertificates(UID, SECRET)
fields = ["parsed.subject_dn", "parsed.fingerprint_sha256", "parsed.fingerprint_sha1"]
for c in certificates.search("validation.nss.valid: true", fields=fields):
print(c["parsed.subject_dn"])
测试效果
以上是关于censys二次开发环境搭建的主要内容,如果未能解决你的问题,请参考以下文章