Skip to content

Commit ecb3243

Browse files
wh0am1iwh0am1i
wh0am1i
authored and
wh0am1i
committed
support grapvhiz file output&generate network map,format png
1 parent 52fb03f commit ecb3243

File tree

8 files changed

+107
-28
lines changed

8 files changed

+107
-28
lines changed

README.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ Use ``zoomeye domain -h`` to view parameters provided by the ``domain``.
562562
::
563563

564564
$ python cli.py domain -h
565-
usage: zoomeye domain [-h] [-page PAGE] q {0,1}
565+
usage: zoomeye domain [-h] [-page PAGE] [-dot] q {0,1}
566566

567567
positional arguments:
568568
q search key word(eg:baidu.com)
@@ -571,6 +571,7 @@ Use ``zoomeye domain -h`` to view parameters provided by the ``domain``.
571571
optional arguments:
572572
-h, --help show this help message and exit
573573
-page PAGE view the page of the query result
574+
-dot generate a network map of the domain name
574575

575576

576577

@@ -599,7 +600,12 @@ The following is a demonstration of ``-page`` :(default query for the first page
599600

600601
total: 90/79882
601602

603+
The ``-dot`` parameter can generate a network map of domain name and IP,Before using this function, you need to install ``grapvhiz``.
604+
Please refer to `grapvhiz <https://graphviz.org/download/>`_ for the installation tutorial. It is supported on Windows/Linux/Mac.
605+
The ``-dot`` parameter will generate a picture in ``png`` format and save the original dot language script at the same time.
602606

607+
.. figure:: images/image-20211208112710711.png
608+
:width: 500px
603609

604610
0x03 video
605611
~~~~~~~~~~
@@ -663,6 +669,8 @@ The following are the interfaces and instructions provided by the SDK:
663669
traverse the web-search result set, and output the domain name and ip address
664670
10.show_ip_port(data)
665671
traverse the host-search result set and output the ip address and port
672+
11.generate_dot(self, q, source=0, page=1)
673+
Generate graphviz files and pictures written in the domain center
666674

667675
3.SDK example
668676
^^^^^^^^^^^^^

docs/README_CN.md

+31-23
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ total: 1/58277850
106106
-filter 查询数据结果集中某个字段的详情,或根据内容进行筛选
107107
-save 可按照筛选条件将结果集进行导出
108108
-force 忽略本地缓存文件,直接从 ZoomEye 获取数据
109-
-type 指定搜索源,host 或 web
109+
-type 指定搜索源,host 或 web
110110

111111
#### 4.数据数量
112112
通过 `-num` 参数可以指定我们搜索和显示的数量,指定的数目即消耗的配额数量。而通过 `-count` 参数可以查询该 `dork` 在 ZoomEye 数据库的总量,如下:
@@ -122,14 +122,14 @@ $ zoomeye search "telnet" -count
122122
我们可以通过 `-facet``-stat` 进行数据的聚合统计,使用 `-facet` 可以查询该 dork 全量数据的聚合情况(由 `ZoomEye` 聚合统计后通过 `API` 获取),而 `-stat` 可以对查询到的结果集进行聚合统计。两个命令支持的聚合字段包括:
123123

124124
# host search
125-
app 按应用类型进行统计
126-
device 按设备类型进行统计
127-
service 按照服务类型进行统计
128-
os 按照操作系统类型进行统计
129-
port 按照端口进行统计
130-
country 按照国家进行统计
131-
city 按照城市进行统计
132-
125+
app 按应用类型进行统计
126+
device 按设备类型进行统计
127+
service 按照服务类型进行统计
128+
os 按照操作系统类型进行统计
129+
port 按照端口进行统计
130+
country 按照国家进行统计
131+
city 按照城市进行统计
132+
133133
# web search
134134
webapp 按照 Web 应用进行统计
135135
component 按照 Web 容器进行统计
@@ -173,17 +173,17 @@ Pocket CMD telnetd 1
173173
使用 `-filter` 参数可以查询数据结果集中某个字段的详情,或根据内容进行筛选,该命令支持的字段包括:
174174

175175
# host/search
176-
app 显示应用类型详情
177-
version 显示版本信息详情
178-
device 显示设备类型详情
179-
port 显示端口信息详情
180-
city 显示城市详情
181-
country 显示国家详情
182-
asn 显示as number详情
183-
banner 显示特征响应报文详情
184-
timestamp 显示数据更新时间
185-
* 在包含该符号时,显示所有字段详情
186-
176+
app 显示应用类型详情
177+
version 显示版本信息详情
178+
device 显示设备类型详情
179+
port 显示端口信息详情
180+
city 显示城市详情
181+
country 显示国家详情
182+
asn 显示as number详情
183+
banner 显示特征响应报文详情
184+
timestamp 显示数据更新时间
185+
* 在包含该符号时,显示所有字段详情
186+
187187
# web/search
188188
app 显示应用类型详情
189189
headers HTTP 头
@@ -444,7 +444,7 @@ total: 30/79882
444444
使用 `zoomeye domain -h` 可以查看 `domain` 提供的参数。
445445
```
446446
$ python cli.py domain -h
447-
usage: zoomeye domain [-h] [-page PAGE] q {0,1}
447+
usage: zoomeye domain [-h] [-page PAGE] [-dot] q {0,1}
448448
449449
positional arguments:
450450
q search key word(eg:baidu.com)
@@ -453,7 +453,7 @@ positional arguments:
453453
optional arguments:
454454
-h, --help show this help message and exit
455455
-page PAGE view the page of the query result
456-
456+
-dot generate a network map of the domain name
457457
```
458458

459459
下面对 `-page` 进行演示:(不指定时默认查询第一页)
@@ -480,8 +480,14 @@ zjnfza.baidu.3dtops.com 2021-06-27 204.11.56.
480480
total: 90/79882
481481
```
482482

483+
`-dot` 参数可以生成域名和 IP 的网络图,在使用该功能的之前需要安装 `grapvhiz`,安装教程请参考 [grapvhiz](https://graphviz.org/download/) 支持在Windows/Linux/Mac上使用。`-dot` 参数会生成 `png` 格式的图片,同时保存原始 dot 语言脚本。
484+
485+
`-dot`使用效果如下:
486+
487+
![image-20211208112710711](../images/image-20211208112710711.png)
483488

484489
### 0x03 演示视频
490+
485491
[在 Windows、Mac、Linux、FreeBSD 演示视频](https://video.weibo.com/show?fid=1034:4597603044884556)
486492

487493
[![asciicast](https://asciinema.org/a/qyDaJw9qQc7UjffD04HzMApWa.svg)](https://asciinema.org/a/qyDaJw9qQc7UjffD04HzMApWa)
@@ -530,6 +536,8 @@ zm = ZoomEye(api_key="01234567-acbd-00000-1111-22222222222")
530536
遍历 web-search 结果集,并输出域名和ip地址
531537
10.show_ip_port(data)
532538
遍历 host-search 结果集,并输出ip地址和端口
539+
11.generate_dot(self, q, source=0, page=1)
540+
生成以域名中心写出graphviz文件和图片
533541

534542
#### 3.使用示例
535543

@@ -584,7 +592,7 @@ soft********11180040.b***c.net ['126.***.***.40']
584592

585593

586594
### 0x05 contributions
587-
[r0oike@knownsec 404](https://github.com/r0oike)
595+
[wh0ami1@knownsec 404](https://github.com/wh0ami1)
588596
[0x7F@knownsec 404](https://github.com/0x7Fancy)
589597
[dawu@knownsec 404](https://github.com/d4wu)
590598
[fenix@knownsec 404](https://github.com/13ph03nix)

images/image-20211208112710711.png

182 KB
Loading

requirements.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
requests>=2.2.1
2-
colorama
1+
certifi==2021.10.8
2+
charset-normalizer==2.0.8
3+
colorama==0.4.4
4+
graphviz==0.19
5+
idna==3.3
6+
requests==2.26.0
7+
urllib3==1.26.7

zoomeye/cli.py

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def main():
217217
parser_domain.add_argument("type", type=int, help="0: search associated domain;1: search sub domain",
218218
choices=(0, 1), default=0)
219219
parser_domain.add_argument("-page", type=int, help="view the page of the query result", default=1)
220+
parser_domain.add_argument('-dot', help="generate a network map of the domain name", action='store_true')
220221
parser_domain.set_defaults(func=core.associated_domain_query)
221222

222223
args = parser.parse_args()

zoomeye/core.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,12 @@ def associated_domain_query(args):
224224
q = args.q
225225
resource = args.type
226226
page = args.page
227-
# show information for user
228-
DomainSearch(q, resource, page).show_information()
227+
dot = args.dot
228+
if dot:
229+
# generate network map
230+
DomainSearch(q, resource, page).generate_dot()
231+
else:
232+
# show information for user
233+
DomainSearch(q, resource, page).show_information()
229234
return None
230235

zoomeye/data.py

+10
Original file line numberDiff line numberDiff line change
@@ -765,3 +765,13 @@ def show_information(self):
765765
show.show_domain_info(info_data, total, self.page)
766766
# return None
767767

768+
def generate_dot(self):
769+
result, msg = self.zm.generate_dot(self.q, self.source, self.page)
770+
if result:
771+
show.printf(msg, color='green')
772+
else:
773+
show.printf(msg, color='red')
774+
775+
776+
777+

zoomeye/sdk.py

+42
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
"""
1111

1212
import getpass
13+
import os
14+
1315
import requests
1416

17+
import graphviz
18+
1519
fields_tables_host = {
1620
"ip": "ip",
1721
"app": "portinfo.app",
@@ -326,6 +330,44 @@ def domain_search(self, q, source=0, page=1) -> list:
326330

327331
return [self.data_list, self.total]
328332

333+
def generate_dot(self, q, source=0, page=1):
334+
"""
335+
336+
"""
337+
error_info = ''
338+
search_api = self.search_api.format('domain')
339+
headers = {'Authorization': 'JWT %s' % self.access_token, 'API-KEY': self.api_key}
340+
try:
341+
request_result = self._request(search_api, params={"q": q, "type": source, "page": page}, headers=headers)
342+
except Exception as e:
343+
error_info = e
344+
request_result = None
345+
if not request_result:
346+
return False, error_info
347+
# the request data is successful, and the domain name network map is generated.
348+
domain = q.replace('.', '_')
349+
grap_obj = graphviz.Digraph(
350+
name=domain,
351+
filename='{}.gv'.format(domain),
352+
engine='sfdp',
353+
format='png',
354+
)
355+
result = {}
356+
for item in request_result.get('list'):
357+
if len(item.get('ip')) != 0:
358+
for ip in item.get('ip'):
359+
result[ip] = item.get('name')
360+
361+
for ip, name in result.items():
362+
grap_obj.edge(name, ip)
363+
364+
try:
365+
grap_obj.render()
366+
except Exception as e:
367+
return False, e
368+
return True, "successful! saving in {}".format(os.getcwd())
369+
370+
329371

330372
def show_site_ip(data):
331373
"""

0 commit comments

Comments
 (0)