Skip to content

Commit 06e957b

Browse files
authored
Merge pull request #31 from knownsec/dev
Dev
2 parents 4e9dcbe + 157d390 commit 06e957b

File tree

5 files changed

+73
-24
lines changed

5 files changed

+73
-24
lines changed

zoomeye/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111

1212
__name__ = 'zoomeye'
1313
__package__ = 'zoomeye'
14-
__version__ = '2.0.4.2'
14+
__version__ = ' 2.0.4.3'
15+
__site__ = "https://www.zoomeye.org/doc"

zoomeye/cli.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
sys.path.insert(1, module_path)
1818

1919
from zoomeye import core
20-
from zoomeye import __version__
20+
from zoomeye.config import BANNER
2121

2222

2323
def get_version():
24-
return "ZoomEye-python version number {}".format(__version__)
24+
print(BANNER)
2525

2626

2727
class ZoomEyeParser(argparse.ArgumentParser):
@@ -36,19 +36,19 @@ def main():
3636
:return:
3737
"""
3838

39-
parser = ZoomEyeParser()
39+
parser = ZoomEyeParser(prog='zoomeye')
4040
subparsers = parser.add_subparsers()
41+
# show ZoomEye-python version number
42+
parser.add_argument(
43+
"-v",
44+
"--version",
45+
action="store_true",
46+
help="show program's version number and exit"
47+
)
4148

4249
# zoomeye account info
4350
parser_info = subparsers.add_parser("info", help="Show ZoomEye account info")
4451
parser_info.set_defaults(func=core.info)
45-
# show version number
46-
parser.add_argument(
47-
'-v', '--version',
48-
action='version',
49-
version=get_version(),
50-
help="Show program's version number and exit"
51-
)
5252

5353
# query zoomeye data
5454
parser_search = subparsers.add_parser(
@@ -88,7 +88,7 @@ def main():
8888
type=str,
8989
help=('''
9090
Output more clearer search results by set filter field,
91-
field: [app,version,device,port,city,country,asn,banner,*]
91+
field: [app,version,device,port,city,country,asn,banner,time,*]
9292
''')
9393
)
9494
parser_search.add_argument(
@@ -190,6 +190,10 @@ def main():
190190

191191
args = parser.parse_args()
192192

193+
if args.version:
194+
get_version()
195+
exit(0)
196+
193197
try:
194198
args.func(args)
195199
except AttributeError:

zoomeye/config.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Author: liuf5
1010
*/
1111
"""
12-
import string
12+
from zoomeye import __version__, __site__
1313

1414

1515
# save api key file and json web token file path
@@ -38,3 +38,22 @@
3838
"\x1b[91m", "\x1b[92m"]
3939

4040
COLOR_RESET = "\x1b[0m"
41+
42+
BANNER = """\033[01;33m
43+
,----,
44+
.' .`| ____ ,---,.
45+
.' .' ; ,' , `. ,' .' |
46+
,---, ' .' ,---. ,---. ,-+-,.' _ |,---.' |
47+
| : ./ ' ,'\ ' ,'\ ,-+-. ; , ||| | .'
48+
; | .' / / / | / / | ,--.'|' | ||: : |-, .--, ,---. \033[01;37m{%s }\033[01;33m
49+
`---' / ; . ; ,. :. ; ,. :| | ,', | |,: | ;/| /_ ./| / \
50+
/ ; / ' | |: :' | |: :| | / | |--' | : .' , ' , ' : / / |
51+
; / /--,' | .; :' | .; :| : | | , | | |-,/___/ \: |. ' / |
52+
/ / / .`|| : || : || : | |/ ' : ;/| . \ ' |' ; /|
53+
./__; : \ \ / \ \ / | | |`-' | | \ \ ; :' | / |
54+
| : .' `----' `----' | ;/ | : .' \ \ ;| : |
55+
; | .' '---' | | ,' : \ \\ \ / \033[01;37m %s \033[01;33m
56+
`---' `----' \ ' ; `----'
57+
`--` \033[0m\033[4;37m\033[0m
58+
59+
""" % (__version__, __site__)

zoomeye/data.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def regexp_data(self, keys):
342342
"""
343343
keys = keys.split(",")
344344
result = []
345-
self.zoomeye.data_list = self.dork_data[:self.num]
345+
self.zoomeye.data_list = self.dork_data
346346

347347
data_list = self.zoomeye.data_list
348348
return regexp(keys, fields_tables_host, data_list)
@@ -390,13 +390,13 @@ def cli_filter(self, keys, save=False):
390390
# the filter condition is app, port
391391
# ex: ip,port,app
392392
else:
393-
equal_data = self.dork_data[:self.num]
393+
equal_data = self.dork_data
394394
# get result
395395
result = filter_search_data(not_equal, fields_tables_host, equal_data)
396396
equal = ','.join(not_equal)
397397
if save:
398398
return equal, result
399-
show.print_filter(equal, result)
399+
show.print_filter(equal, result[:self.num], has_equal)
400400

401401
def save(self, fields):
402402
"""
@@ -611,9 +611,9 @@ def filter_fields(self, fields):
611611
not_equal.append(field_item)
612612
# match filters that contain specific data
613613
if len(has_equal) != 0:
614-
result_data = regexp(has_equal, fields_tables_history_host, data[:self.num])
614+
result_data = regexp(has_equal, fields_tables_history_host, data)
615615
else:
616-
result_data = data[:self.num]
616+
result_data = data
617617
# no regexp data
618618
if len(result_data) == 0:
619619
return
@@ -625,4 +625,4 @@ def filter_fields(self, fields):
625625
"filter command has unsupport fields [{}], support fields has [{}]".format(item, support_fields),
626626
color='red')
627627
exit(0)
628-
show.print_filter_history(not_equal, result_data)
628+
show.print_filter_history(not_equal, result_data[:self.num], has_equal)

zoomeye/show.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Author: liuf5
66
*/
77
"""
8-
import datetime
8+
import re
99
from colorama import init
1010

1111
from zoomeye import config, data, plotlib
@@ -110,11 +110,12 @@ def print_data(data_list):
110110
printf("total: {}".format(total))
111111

112112

113-
def print_filter(keys, data):
113+
def print_filter(keys, data_list, condition=None):
114114
"""
115115
used to display user filtered data on the terminal
116116
:param keys: user input key, is str
117-
:param data: filter data ,is list
117+
:param data_list: filter data ,is list
118+
:param condition: list,
118119
:return:
119120
"""
120121
total = 0
@@ -125,10 +126,19 @@ def print_filter(keys, data):
125126
printf("{}".format(title), color="green")
126127

127128
# print data
128-
for i in data:
129+
for i in data_list:
129130
items = ""
130131
for j in i:
131132
j_hex = convert_str(str(j))
133+
# match to content highlight
134+
if condition:
135+
for item in condition:
136+
k, v = item.split('=')
137+
result_re = re.search(v, j_hex, re.I | re.M)
138+
if result_re:
139+
# replace to highlight
140+
color_content = "\033[31m{}\033[0m".format(result_re.group())
141+
j_hex = j_hex.replace(result_re.group(), color_content)
132142
items += "{:<30}".format(j_hex)
133143
total += 1
134144
printf(items)
@@ -244,6 +254,9 @@ def print_host_data(host_data):
244254
"""
245255
:param host_data, list,
246256
"""
257+
# host data is None
258+
if len(host_data) == 0:
259+
return
247260
# parser hostname,country,city... information
248261
first_item = host_data[0]
249262
all_data, port_count = data.filter_history_data(data.fields_tables_history_host.keys(), host_data)
@@ -272,17 +285,20 @@ def print_host_data(host_data):
272285
printf(content)
273286

274287

275-
def print_filter_history(fileds, hist_data):
288+
def print_filter_history(fileds, hist_data, condition=None):
276289
"""
277290
print user filter history data,
278291
:param fileds list,user input field
279292
:param hist_data dict, from ZoomEye API get data
293+
:param condition list, filter condition
280294
"""
281295
filter_title = ''
282296
first_item = hist_data[0]
297+
# filter data
283298
all_data, port_count = data.filter_history_data(fileds, hist_data, omit=False)
284299
printf(first_item.get('ip'))
285300
dict_first_item = data.ZoomEyeDict(first_item)
301+
# parser filter data title
286302
for dict_item in data.tables_history_info.keys():
287303
result = dict_first_item.find(data.tables_history_info.get(dict_item))
288304
if result == "" or result is None or result == "Unknown":
@@ -299,5 +315,14 @@ def print_filter_history(fileds, hist_data):
299315
for data_item in all_data:
300316
content = ""
301317
for item_item in data_item:
318+
# match to content highlight
319+
if condition:
320+
for condition_item in condition:
321+
k, v = condition_item.split('=')
322+
re_result = re.search(str(v), str(item_item), re.I | re.M)
323+
content = "\033[31m{}\033[0m".format(re_result.group())
324+
# replace to highlight
325+
if re_result:
326+
item_item = item_item.replace(re_result.group(), content)
302327
content += "{:<27}".format(item_item)
303328
printf(content)

0 commit comments

Comments
 (0)