<https://censys.io/>

Censys


  Censys持续监控互联网上所有可访问的服务器和设备,以便您可以实时搜索和分析它们,了解你的网络攻击面,发现新的威胁并评估其全球影响。从互联网领先的扫描仪ZMap的创造者来说,我们的使命是通过数据驱动安全。

  Censys跟国外的Shodan <https://www.shodan.io/>和国内的ZoomEye
<https://www.zoomeye.org/>类似,可以搜索世界范围内的联网设备。Shodan和ZoomEye是个人用的比较多的两款,当然国内还有傻蛋
<https://www.oshadan.com/>和fofa <https://fofa.so/>, 国外也有其他类似的搜索引擎,这里就不一一列举了。


  Censys与Shodan相比是一款免费搜索引擎,当然也有一定的限制(速度和搜索结果),而新改版后的ZoomEye对国内的搜索结果做了处理,几乎没有什么价值,对于非天朝的搜索还是可以适用的,如果对这两款搜索引擎感兴趣的朋友可以去试用一下,博客中也有关于这两款搜索引擎介绍,可自行查找。

  先来膜拜一下发表在信息安全顶会CCS'15 : A Search Engine Backed by Internet-Wide Scanning
<https://censys.io/static/censys.pdf> 。

  Censys提供6种API的使用方式,如下:

 



  不过这里我们仅介绍第一种的使用,即获取搜索条件下的ip地址,这个也是我们用的最多的。

使用说明

  当然在使用之前也是需要注册一个账号的,因为在使用API时需要提供API Credentials即你的ID和Secret,可以在个人信息中看到。



 

   最下面是使用的速度限制,我们可以在程序中设置一个延时,比如每查询一次睡眠三秒钟,总体来说,速度还是比较可观的。

官方示例



  初看确实感觉搜索语法好像略微繁琐,没有Shodan和ZoomEye那么简练,而且文档也不够,怎么说呢,简单明了吧。不信你点开看看
<https://censys.io/ipv4/help>

查询语法

  Search <https://censys.io/api/v1/docs/search> 的Data Parameters 主要有四个,分别是

* query:查询语句
* page:查询页
* fields:查询的结果域(可选)
* flatten:平整的结果(可选) Example: { "query":"80.http.get.headers.server: Apache", "
page":1, "fields":["ip", "location.country", "autonomous_system.asn"], "flatten"
:true }
  好了,说明部分差不多到这里了,下面给出一个完整的示例。

示例

  一般来说我们在查询的时候,会加上一定的限制条件,比如天朝的某些设备,如:"query": "weblogic and
location.country_code: CN"。
#!/usr/bin/env python # -*- coding:utf-8 -*- import sys import json import
requestsimport time API_URL = "https://www.censys.io/api/v1" UID = "
aa7c1f3a-b6ab-497d-9788-5e9e4898a655" SECRET = "pay3u4ytGjbdZGftJ8ow50E8hBQVLk7j
" page = 1 PAGES = 50 # the pages you want to fetch def getIp(query, page): '''
Return ips and total amount when doing query''' iplist = [] data = { "query":
query,"page": page, "fields": ["ip", "protocols", "location.country"] } try: res
= requests.post(API_URL +"/search/ipv4", data=json.dumps(data), auth=(UID,
SECRET))except: pass try: results = res.json() except: pass if res.status_code
!= 200: print("error occurred: %s" % results["error"]) sys.exit(1) # total
query result iplist.append("Total_count:%s" % (results["metadata"]["count"])) #
add result in some specific form for result in results["results"]: for i in
result["protocols"]: # iplist.append(result["ip"] + ':' + i + ' in ' +
result["location.country"][0]) iplist.append(result["ip"] + ':' + i) # return
ips and total count return iplist, results["metadata"]["count"] if __name__ == '
__main__': query = input('please input query string : ') print('---', query, '
---') ips, num = getIp(query=query, page=page) print("Total_count:%s" % num) dst
= input('please input file name to save data (censys.txt default) : ') # 保存数据到文件
if dst: dst = dst + '.txt' else: dst = 'censys.txt' # get result and save to
file page by page with open(dst, 'a') as f: while page <= PAGES: print('page :'
+ str(page)) iplist, num = (getIp(query=query, page=page)) page += 1 for i in
iplist:print i[:i.find('/')] for i in iplist: f.write(i[:i.find('/')] + '\n')
time.sleep(3) print('Finished. data saved to file', dst)
Sample:
starnight:censys starnight$ python script.py please input query string : "
weblogic" ('---', 'weblogic', '---') Total_count:11836 please input file name
to save data (censys.txt default) :"weblogic" page :1 Total_count:1183
46.244.104.198:80 46.244.104.198:8080 31.134.202.10:2323 31.134.202.10:80
31.134.202.10:8080 31.134.203.85:2323 31.134.203.85:80 31.134.203.85:8080
31.134.205.92:2323 31.134.205.92:80 31.134.205.92:8080 31.134.206.202:2323
31.134.206.202:80 31.134.206.202:8080 31.134.201.249:80 31.134.201.249:8080
31.134.202.233:80 31.134.202.233:8080 31.134.200.94:80 31.134.200.94:8080
31.134.201.248:80 31.134.201.248:8080 31.134.200.6:80 31.134.200.6:8080
46.244.105.216:80 46.244.105.216:8080 31.134.206.131:80 31.134.206.131:2323
31.134.206.131:8080 31.134.204.127:80 31.134.204.127:8080 46.244.10.173:80
46.244.10.173:23 46.244.10.173:8080 31.134.202.82:80 31.134.202.82:8080
46.244.105.252:80 46.244.105.252:2323 46.244.105.252:8080 31.134.205.186:2323
31.134.205.186:80 31.134.205.186:8080 31.134.204.223:80 31.134.204.223:8080
31.134.207.182:2323 31.134.207.182:80 31.134.207.182:8080
  好像结果不是很准确 ~ 哈哈 ~ 另外,个人可以对返回iplist做相应的改变以方便自己使用 ~ 

  今天上午收到一封邮件,说Censys的商业版本要出来了 ~ 敬请期待 (2017.11.14)

  

  最后,Github地址: censys
<https://github.com/starnightcyber/scripts/tree/master/censys>

References

  信息收集之censys <http://www.cnblogs.com/Dleo/p/5725479.html>

  Censys 搜索语法
<https://censys.io/ipv4/_help?q=jbos+and+location.country_code%3A+CN%22#syntax1>

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:637538335
关注微信