专栏名称: Seebug漏洞平台
Seebug,原 Sebug 漏洞平台,洞悉漏洞,让你掌握第一手漏洞情报!
目录
相关文章推荐
山东省交通运输厅  ·  正式获批! ·  16 小时前  
单向街书店  ·  三打白骨精|皮影戏体验工作坊 ·  2 天前  
德州晚报  ·  杨晓军(副厅级),被逮捕! ·  2 天前  
德州晚报  ·  全德州免费使用! ·  2 天前  
51好读  ›  专栏  ›  Seebug漏洞平台

关于 ZoomEye-python 更新这件事

Seebug漏洞平台  · 公众号  ·  · 2021-03-23 16:20

正文


0x01 前言

不知道大家是否还记得 Heige 的这篇文章 《使用 ZoomEye 寻找 APT 攻击的蛛丝马迹》,Heige 在文章中阐述利用 ZoomEye 开放的历史数据 API 接口尝试追踪 APT 的案例。那篇文章虽然过去很久了,但是仍然具有参考价值。为了让广大的安全研究者能够更简单、更方便的实现这些类似的操作,于是在 ZoomEye-python v2.0.4.2 中新增加 history clear 命令。

0x02 更新内容

值得注意的是,由于本工具依赖于 ZoomEye 提供的 API ,所以仅支持高级用户和 VIP 用户使用 history 命令。
1. Search
本次更新在 search 命令新增了对扫描时间的展示和筛选, 通过 -filter 参数对扫描时间展示筛选,筛选的语法同样是 -filter "key" / -filter "key=value" (支持正则表达式)。 例如展示扫描时间,如:
zoomeye search "cidr:118.*.*.15/24" -filter "time"                                   ip                            time                          118.*.*.9                  2021-03-23 02:34:34           118.*.*.9                  2021-03-22 18:12:37           118.*.*.11                 2021-03-20 22:19:47           118.*.*.3                  2021-03-20 19:58:58           118.*.*.5                  2021-03-18 10:58:47           118.*.*.29                 2021-03-16 09:32:15           118.*.*.11                 2021-03-13 15:59:35           118.*.*.12                 2021-03-13 15:11:42           118.*.*.37                 2021-03-10 04:28:43           118.*.*.36                 2021-03-08 22:02:40           118.*.*.9                  2021-03-08 18:48:42           118.*.*.48                 2021-03-08 18:48:32           118.*.*.24                 2021-03-08 18:48:31           118.*.*.27                 2021-03-08 18:48:27           118.*.*.11                 2021-03-08 18:48:26           118.*.*.8                  2021-03-08 00:08:51           118.*.*.29                 2021-03-08 00:08:31           118.*.*.41                 2021-03-05 23:47:51           118.*.*.23                 2021-02-26 20:08:28           118.*.*.8                  2021-02-25 09:01:39
对扫描时间进行筛选:
zoomeye search "cidr:118.*.*.15/24" -filter "time=^2021-03" -num 3 ip                         time                          118.*.*.9                  2021-03-23 02:34:34           118.*.*.9                  2021-03-22 18:12:37           118.*.*.11                 2021-03-20 22:19:47
在实际工作中有时候需要从 ZoomEye 获取实时数据,因此在本次更新中为 search 命令添加了 force 参数,可以绕过本地缓存数据,直接从 ZoomEye 获取数据,让获取数据的方式更加灵活。
2. 管道符
ZoomEye-python 能够配合 sed/awk/grep 对输出在屏幕上的内容进行二次操作,这里以 awk 为例做一个演示:
# 正常的输出$ zoomeye search "cidr:118.*.*.15/24"                             ip:port          service   country   app       banner118.*.*.9:22     ssh       China     OpenSSH   SSH-2.0-OpenSSH_8.4p1-hpn14v22...118.*.*.9:443    https     China     nginx     HTTP/1.1 403 Forbidden\r\nServ...118.*.*.11:443   https     China     nginx     HTTP/1.1 403 Forbidden\r\nServ...118.*.*.3:80     http      China               HTTP/1.1  403 Forbidden\nConte...118.*.*.5:22     ssh       China     OpenSSH   SSH-2.0-OpenSSH_8.4p1-hpn14v22...118.*.*.29:80    http      China               HTTP/1.0 404 Not Found\r\nCont...118.*.*.11:22    ssh       China     OpenSSH   SSH-2.0-OpenSSH_8.4p1-hpn14v22.........total: 20
# awk 筛选后输出$ zoomeye search "cidr:118.*.*.15/24"|awk '/403 Forbidden/{print}'118.*.*.9:443 https China nginx HTTP/1.1 403 Forbidden\r\nServ...118.*.*.11:443 https China nginx HTTP/1.1 403 Forbidden\r\nServ...118.*.*.3:80 http China HTTP/1.1 403 Forbidden\nConte...118.*.*.37:80 http China HTTP/1.1 403 Forbidden\r\nServ...118.*.*.9:80 http China nginx HTTP/1.1 403 Forbidden\r\nServ.........
在上述案例中通过 awk ZoomEye-python 的输出进行了筛选,筛选出了 banner 含有 403 Forbidden 的内容,当还可以支持其他的一些操作,大家可以在日常使用中去发现。
3. 清理数据
在新版本的 ZoomEye-python 中添加了清理用户数据和缓存数据命令 clear ,为了防止缓存数据越用越多,占用存储空间以及防止在公共设备上使用导致用户数据泄漏。使用方式如下:
$zoomeye clear -husage: zoomeye clear [-h] [-setting] [-cache]
optional arguments: -h, --help show this help message and exit -setting clear user api key and access token -cache clear local cache file
clear 命令的参数解释:
1.setting   清理用户的 API KEY 和 ACCESS TOKEN2.cache         清理本地缓存的数据
4. 历史数据查询
ZoomEye 在去年一月开放了历史数据查询,在 ZoomEye 提供的历史数据中不管你覆盖不覆盖都可以查询出每次扫描得到的 banner 数据,但是目前提供的 ZoomEye 历史 API 只能通过 IP 去查询,而不能通过关键词匹配搜索。在 history 命令中同样如此,举个例子:
$zoomeye history 108.*.*.65 -num 3108.*.*.65Hostnames:                    [unknown]Country:                      United StatesCity:                         San JoseOrganization:                 [unknown]Lastupdated:                  2021-02-25T01:09:26Number of open ports:         2Number of historical probes:  3
timestamp port/service app raw_data 2021-02-25 01:09:26 21/ftp Pure-FTPd 220---------- Welcome to Pure-...2021-02-11 14:36:21 80/http nginx HTTP/1.1 200 OK\r\nServer: ngi...2021-02-10 19:31:11 80/http nginx HTTP/1.1 200 OK\r\nServer: ngi...
在上述案例中我们使用 zoomeye history 搜索了 IP 是 108.*.*.65 的历史数据, -num 3 限定展示了数据展示的数量为 3 。展示了我们认为比较重要的五个字段,分别是:
1.tiemstamp             扫描的时间2.port                  开放的端口3.service               运行的服务4.app                   运行的应用5.raw_data              每次扫描的 banner
现阶段 history 展示的结果只有这个五个字段,后续将根据需求添加相应字段。
$zoomeye history [-h] [-filter filed=regexp] [-force] [-num value] ip
positional arguments: ip search historical device IP
optional arguments: -h, --help show this help message and exit -filter filed=regexp filter data and print raw data detail. field: [time,port,service,country,raw,*] -force ignore the local cache and force the data to be obtained from the API -num value the number of search results that should be returned
history 命令中提供了一下参数:
1.filter    对历史数据进行筛选,可以指定字段 (key) 也可以指定字段和值 (key=value)2.force     强制从 API 获取数据3.num       限定展示数据的数量
history 命令筛选功能和 search 命令的筛选功能类似,支持单独的 key 也支持 key=value 的方式,同时也是支持正则表达式的。看个例子:
$zoomeye history 108.*.*.65 -filter "time=^2020-10,port,service"108.*.*.65Hostnames:                    [unknown]Country:                      United StatesCity:                         San JoseOrganization:                 [unknown]Lastupdated:                  2020-10-30T02:18:01Number of open ports:         3Number of historical probes:  5
time port service 2020-10-30 02:18:01 80 http 2020-10-12 07:17:26 80 http 2020-10-07 21:33:03 80 http 2020-10-06 06:59:48 443 https 2020-10-05 06:42:30 21 ftp
注意: history 在查询 IP 的历史数据时会消耗用户的配额,有多少条数据就会扣除多少配额,因此我对 history 也做了缓存设置,失效日期为 5 天。
如果你需要从 API 获取实时的数据请使用 -force 参数, -force 会强制从 ZoomEye API 获取数据,同时消耗用户配额。






请到「今天看啥」查看全文