MCPcopy
hub / github.com/NullArray/AutoSploit / load_exploits

Function load_exploits

lib/jsonize.py:43–76  ·  view source on GitHub ↗

load exploits from a given path, depending on how many files are loaded into the beginning `file_list` variable it will display a list of them and prompt or just select the one in the list

(path, node="exploits")

Source from the content-addressed store, hash-verified

41
42
43def load_exploits(path, node="exploits"):
44 """
45 load exploits from a given path, depending on how many files are loaded into
46 the beginning `file_list` variable it will display a list of them and prompt
47 or just select the one in the list
48 """
49 retval = []
50 file_list = os.listdir(path)
51 selected = False
52 if len(file_list) != 1:
53 lib.output.info("total of {} exploit files discovered for use, select one:".format(len(file_list)))
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
64 else:
65 selected_file = file_list[0]
66
67 selected_file_path = os.path.join(path, selected_file)
68
69 with open(selected_file_path) as exploit_file:
70 # loading it like this has been known to cause Unicode issues later on down
71 # the road
72 _json = json.loads(exploit_file.read())
73 for item in _json[node]:
74 # so we'll reload it into a ascii string before we save it into the file
75 retval.append(str(item))
76 return retval
77
78
79def text_file_to_dict(path, filename=None):

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected