Skip to content

Commit fb2abd5

Browse files
committed
fixes an issue where providing the incorrect input when choosing an exploit mod list will crash the program (issue #167)
1 parent acab902 commit fb2abd5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/jsonize.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,19 @@ def load_exploits(path, node="exploits"):
4848
"""
4949
retval = []
5050
file_list = os.listdir(path)
51+
selected = False
5152
if len(file_list) != 1:
5253
lib.output.info("total of {} exploit files discovered for use, select one:".format(len(file_list)))
53-
for i, f in enumerate(file_list, start=1):
54-
print("{}. '{}'".format(i, f[:-5]))
55-
action = raw_input(lib.settings.AUTOSPLOIT_PROMPT)
56-
selected_file = file_list[int(action) - 1]
54+
while not selected:
55+
for i, f in enumerate(file_list, start=1):
56+
print("{}. '{}'".format(i, f[:-5]))
57+
action = raw_input(lib.settings.AUTOSPLOIT_PROMPT)
58+
try:
59+
selected_file = file_list[int(action) - 1]
60+
selected = True
61+
except Exception:
62+
lib.output.warning("invalid selection ('{}'), select from below".format(action))
63+
selected = False
5764
else:
5865
selected_file = file_list[0]
5966

0 commit comments

Comments
 (0)