MCPcopy Index your code
hub / github.com/NullArray/AutoSploit / single_run_args

Method single_run_args

lib/cmdline/cmd.py:126–239  ·  view source on GitHub ↗

run the arguments provided

(opt, keys, loaded_modules)

Source from the content-addressed store, hash-verified

124
125 @staticmethod
126 def single_run_args(opt, keys, loaded_modules):
127 """
128 run the arguments provided
129 """
130 api_searches = (
131 api_calls.zoomeye.ZoomEyeAPIHook,
132 api_calls.shodan.ShodanAPIHook,
133 api_calls.censys.CensysAPIHook
134 )
135 headers = lib.settings.configure_requests(
136 proxy=opt.proxyConfig, agent=opt.personalAgent, rand_agent=opt.randomAgent
137 )
138 single_search_msg = "using {} as the search engine"
139
140 if opt.displayEthics:
141 ethics_file = "{}/etc/text_files/ethics.lst".format(os.getcwd())
142 with open(ethics_file) as ethics:
143 ethic = random.choice(ethics.readlines()).strip()
144 lib.settings.close(
145 "You should take this ethical lesson into consideration "
146 "before you continue with the use of this tool:\n\n{}\n".format(ethic))
147 if opt.downloadModules is not None:
148 import re
149
150 modules_to_download = opt.downloadModules
151 links_list = "{}/etc/text_files/links.txt".format(lib.settings.CUR_DIR)
152 possibles = open(links_list).readlines()
153 for module in modules_to_download:
154 searcher = re.compile("{}".format(module))
155 for link in possibles:
156 if searcher.search(link) is not None:
157 filename = lib.settings.download_modules(link.strip())
158 download_filename = "{}.json".format(link.split("/")[-1].split(".")[0])
159 download_path = "{}/etc/json".format(os.getcwd())
160 current_files = os.listdir(download_path)
161 if download_filename not in current_files:
162 full_path = "{}/{}".format(download_path, download_filename)
163 lib.jsonize.text_file_to_dict(filename, filename=full_path)
164 lib.output.info("downloaded into: {}".format(download_path))
165 else:
166 lib.output.warning("file already downloaded, skipping")
167 if opt.exploitList:
168 try:
169 lib.output.info("converting {} to JSON format".format(opt.exploitList))
170 done = lib.jsonize.text_file_to_dict(opt.exploitList)
171 lib.output.info("converted successfully and saved under {}".format(done))
172 except IOError as e:
173 lib.output.error("caught IOError '{}' check the file path and try again".format(str(e)))
174 sys.exit(0)
175
176 search_save_mode = None
177 if opt.overwriteHosts:
178 # Create a new empty file, overwriting the previous one.
179 # Set the mode to append afterwards
180 # This way, successive searches will start clean without
181 # overriding each others.
182 open(lib.settings.HOST_FILE, mode="w").close()
183 search_save_mode = "a"

Callers 1

mainFunction · 0.80

Calls 2

start_exploitMethod · 0.80
searchMethod · 0.45

Tested by

no test coverage detected