Skip to content

Commit a83fcaf

Browse files
authored
Merge branch 'master' into master
2 parents cb2a175 + b104225 commit a83fcaf

9 files changed

Lines changed: 52 additions & 46 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

zoomeye/cli.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@ def main():
5151
parser_info.set_defaults(func=core.info)
5252

5353
# query zoomeye data
54-
parser_search = subparsers.add_parser(
54+
P_search = subparsers.add_parser(
5555
"search",
5656
help="Search the ZoomEye database"
5757
)
5858

59-
parser_search.add_argument(
59+
P_search.add_argument(
6060
"dork",
6161
help="The ZoomEye search keyword or ZoomEye exported file"
6262
)
63-
parser_search.add_argument(
63+
P_search.add_argument(
6464
"-num",
6565
default=20,
6666
help="The number of search results that should be returned, support 'all'",
6767
type=str,
6868
metavar='value'
6969
)
70-
parser_search.add_argument(
70+
P_search.add_argument(
7171
"-facet",
7272
default=None,
7373
nargs='?',
@@ -80,7 +80,7 @@ def main():
8080
'''),
8181
metavar='field'
8282
)
83-
parser_search.add_argument(
83+
P_search.add_argument(
8484
"-filter",
8585
default=None,
8686
metavar='field=regexp',
@@ -93,7 +93,7 @@ def main():
9393
web field: [app,headers,keywords,title,site,city,country,webapp,component,framework,server,waf,os,timestamp,*]
9494
''')
9595
)
96-
parser_search.add_argument(
96+
P_search.add_argument(
9797
'-stat',
9898
default=None,
9999
metavar='field',
@@ -106,7 +106,7 @@ def main():
106106
web field: [webapp,component,framework,server,waf,os,country]
107107
''')
108108
)
109-
parser_search.add_argument(
109+
P_search.add_argument(
110110
"-save",
111111
default=None,
112112
metavar='field=regexp',
@@ -118,18 +118,18 @@ def main():
118118
type=str,
119119
const='all'
120120
)
121-
parser_search.add_argument(
121+
P_search.add_argument(
122122
"-count",
123123
help="The total number of results in ZoomEye database for a search",
124124
action="store_true"
125125
)
126-
parser_search.add_argument(
126+
P_search.add_argument(
127127
"-figure",
128128
help="Pie chart or bar chart showing data,can only be used under facet and stat",
129129
choices=('pie', 'hist'),
130130
default=None
131131
)
132-
parser_search.add_argument(
132+
P_search.add_argument(
133133
"-type",
134134
help=(
135135
"""
@@ -139,7 +139,7 @@ def main():
139139
choices={'web', 'host'},
140140
default="host"
141141
)
142-
parser_search.add_argument(
142+
P_search.add_argument(
143143
"-force",
144144
help=(
145145
"""
@@ -148,12 +148,12 @@ def main():
148148
),
149149
action="store_true"
150150
)
151-
parser_search.set_defaults(func=core.search)
151+
P_search.set_defaults(func=core.search)
152152

153153
# initial account configuration related commands
154-
parser_init = subparsers.add_parser("init", help="Initialize the token for ZoomEye-python")
155-
parser_init.add_argument("-apikey", help="ZoomEye API Key", default=None, metavar='[api key]')
156-
parser_init.set_defaults(func=core.init)
154+
P_init = subparsers.add_parser("init", help="Initialize the token for ZoomEye-python")
155+
P_init.add_argument("-apikey", help="ZoomEye API Key", default=None, metavar='[api key]')
156+
P_init.set_defaults(func=core.init)
157157

158158
parser_ip_info = subparsers.add_parser("ip", help="Query IP information")
159159
parser_ip_info.add_argument("ip", help="search device IP", metavar='ip', type=str)
@@ -219,8 +219,9 @@ def main():
219219
parser_domain.set_defaults(func=core.associated_domain_query)
220220

221221
args = parser.parse_args()
222+
ver=args.version()
222223

223-
if args.version:
224+
if ver:
224225
get_version()
225226
exit(0)
226227

zoomeye/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212
from zoomeye import __version__, __site__
1313

14+
seconds_of_fiveday = 60 * 60 * 24 * 5
1415

1516
# save api key file and json web token file path
1617
ZOOMEYE_CONFIG_PATH = "~/.config/zoomeye/setting"
@@ -19,7 +20,7 @@
1920
ZOOMEYE_CACHE_PATH = "~/.config/zoomeye/cache"
2021

2122
# cache expired time, five day
22-
EXPIRED_TIME = 60 * 60 * 24 * 5
23+
EXPIRED_TIME = seconds_of_fiveday
2324

2425
# print data max length
2526
STRING_MAX_LENGTH = 23

zoomeye/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
zoomeye_dir = os.path.expanduser(config.ZOOMEYE_CONFIG_PATH)
1717

1818

19-
def key_init(key):#初始化API密钥并将其保存在本地配置文件中
19+
def init_key(key): #初始化API密钥并将其保存在本地配置文件中
20+
2021
"""
2122
initialize through the api key, write the api key to the local configuration file,
2223
theoretically it will never expire unless you remake the api key
@@ -52,7 +53,7 @@ def init(args):#根据用户输入的参数来选择初始化方法,可以通
5253
api_key = args.apikey
5354
# use api key init
5455
if api_key:
55-
key_init(api_key)
56+
init_key(api_key)
5657
return
5758
# invalid parameter
5859
show.printf("input parameter error", color="red")

zoomeye/data.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ def regexp(keys, field_table, data_list):
162162
return result
163163

164164

165-
def filter_search_data(keys, field_table, data):
165+
def filter_search_data(datakeys, field_table, data):
166166
"""
167167
get the data of the corresponding field
168-
:param keys: list, user input field
168+
:param datakeys: list, user input field
169169
:param field_table: dict, fileds
170170
:param data: list, zoomeye api data
171171
:return: list, ex: [[1,2,3...],[1,2,3...],[1,2,3...]...]
@@ -174,7 +174,7 @@ def filter_search_data(keys, field_table, data):
174174
for d in data:
175175
item = []
176176
zmdict = ZoomEyeDict(d)
177-
for key in keys:
177+
for key in datakeys:
178178
if field_table.get(key.strip()) is None:
179179
support_fields = ','.join(list(field_table.keys()))
180180
show.printf("filter command has unsupport fields [{}], support fields has [{}]"
@@ -736,11 +736,11 @@ def filter_information(self, filters):
736736
result_data, has_equal, not_equal = process_filter(filters, info_data, fields_ip)
737737
if len(result_data) == 0:
738738
return
739-
for item in not_equal:
740-
if fields_ip.get(item.strip()) is None:
739+
for items in not_equal:
740+
if fields_ip.get(items.strip()) is None:
741741
support_fields = ','.join(list(fields_ip.keys()))
742742
show.printf(
743-
"filter command has unsupport fields [{}], support fields has [{}]".format(item, support_fields),
743+
"filter command has unsupport fields [{}], support fields has [{}]".format(items, support_fields),
744744
color='red')
745745
exit(0)
746746
show.print_info_filter(not_equal, result_data, has_equal)

zoomeye/file.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,25 @@
1616
zoomeye_dir = os.path.expanduser(config.ZOOMEYE_CONFIG_PATH)
1717

1818

19+
20+
1921
def get_api_key(path) -> str:
2022
"""
2123
obtain api key from local configuration when querying data
2224
:param path:
2325
:return:
2426
"""
25-
key_file = zoomeye_dir + "/apikey"
27+
key_fl = zoomeye_dir + "/apikey"
2628
# api key config does not exits
2729
# raise FileNotFoundError
28-
if not os.path.exists(key_file):
30+
if not os.path.exists(key_fl):
2931
raise FileNotFoundError("not found api key config")
3032
# determine whether the permission of the configuration file is read-only,
3133
# if not, set it to read-only
32-
if not oct(os.stat(key_file).st_mode).endswith("600"):
33-
os.chmod(key_file, 0o600)
34+
if not oct(os.stat(key_fl).st_mode).endswith("600"):
35+
os.chmod(key_fl, 0o600)
3436
# return read file content
35-
with open(key_file, 'r') as f:
37+
with open(key_fl, 'r') as f:
3638
return f.read().strip()
3739

3840

@@ -42,18 +44,19 @@ def get_jwt_token(path) -> str:
4244
:param path:
4345
:return:
4446
"""
45-
key_file = zoomeye_dir + "/jwt"
47+
key_fl = zoomeye_dir + "/jwt"
4648
# json web token does not exits
4749
# raise FileNotFoundError
48-
if not os.path.exists(key_file):
50+
if not os.path.exists(key_fl):
4951
raise FileNotFoundError("not found access token config")
5052

53+
5154
# determine whether the permission of the configuration file is read-only,
5255
# if not, set it to read-only
53-
if not oct(os.stat(key_file).st_mode).endswith("600"):
54-
os.chmod(key_file, 0o600)
56+
if not oct(os.stat(key_fl).st_mode).endswith("600"):
57+
os.chmod(key_fl, 0o600)
5558
# return read config content
56-
with open(key_file, 'r') as f:
59+
with open(key_fl, 'r') as f:
5760
return f.read().strip()
5861

5962

zoomeye/plotlib.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,20 @@ def generate_histogram(values, labels=None, force_ascii=False):
134134
else:
135135
chars = [" ", "#", "#", "#", "#", "#", "#", "#", "#"]
136136

137-
fmt = []
137+
ft = []
138138
if labels is not None:
139139
cfmt = "{{:{}s}}".format(max([len(str(label)) for label in labels]))
140-
fmt.append(cfmt)
140+
ft.append(cfmt)
141141
# show values
142142
all_int = all(val == int(val) for val in values)
143143
if all_int:
144144
cfmt = "{{:{}d}}".format(max([len(str(val)) for val in values]))
145145
else:
146146
cfmt = "{}"
147-
fmt.append("[" + cfmt + "]")
147+
ft.append("[" + cfmt + "]")
148148

149-
fmt.append("{}")
150-
fmt = " ".join(fmt)
149+
ft.append("{}")
150+
ft = " ".join(ft)
151151

152152
out = []
153153
for k, (val, row) in enumerate(zip(values, matrix)):
@@ -159,7 +159,7 @@ def generate_histogram(values, labels=None, force_ascii=False):
159159
# cut off trailing zeros
160160
r = trim_zeros(row)
161161
data.append("".join(chars[item] for item in r))
162-
out.append(fmt.format(*data))
162+
out.append(ft.format(*data))
163163
for item in out:
164164
print(' ' + item)
165165

zoomeye/sdk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import requests
1616

17-
import graphviz
17+
import graphviz # Attention!
1818

1919
fields_tables_host = {
2020
"ip": "ip",

zoomeye/show.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def show_web_default_data(data_list, count):
110110
"site", "title", "country", "banner"), color="green")
111111
num = 0
112112
for item in data_list:
113-
num += 1
113+
num = num+1
114114
item_dict = ZoomEyeDict(item)
115115
content = ''
116116
for item_key in data.default_table_web.keys():
@@ -427,7 +427,7 @@ def print_info_filter(filters, raw_data, condition=None):
427427
printf(content)
428428

429429

430-
def show_domain_info(info_list, total, page):
430+
def show_domain_info(information_list, total, page):
431431
"""
432432
show query domain info
433433
Args:
@@ -437,10 +437,10 @@ def show_domain_info(info_list, total, page):
437437
None
438438
"""
439439

440-
if len(info_list) == 0:
440+
if len(information_list) == 0:
441441
return
442442
printf("{:<55}{:<15}{:<25}".format("name", "timestamp", "ip"), color="green")
443-
for d in info_list:
443+
for d in information_list:
444444
name, timestamp, ip = d.values()
445445
printf("{:<55}{:<15}{:<25}".format(name, timestamp, json.dumps(ip)))
446446
print()

0 commit comments

Comments
 (0)