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

Method do_api_search

lib/term/terminal.py:210–302  ·  view source on GitHub ↗

Explanation: ------------ Search the API with a provided query for potentially exploitable hosts. Parameters: ----------- :param requested_api_data: data to be used with the API tuple of info :param query: the query to be searched :pa

(self, requested_api_data, query, tokens)

Source from the content-addressed store, hash-verified

208 lib.output.warning("program must be restarted for the new tokens to initialize")
209
210 def do_api_search(self, requested_api_data, query, tokens):
211 """
212 Explanation:
213 ------------
214 Search the API with a provided query for potentially exploitable hosts.
215
216 Parameters:
217 -----------
218 :param requested_api_data: data to be used with the API tuple of info
219 :param query: the query to be searched
220 :param tokens: an argument dict that will contain the token information
221
222 Command Format:
223 --------------
224 search[/api/gather] API_NAME[API_NAME,...](shodan,censys,zoomeye) QUERY
225
226 Examples:
227 ---------
228 search shodan,censys,zoomeye windows 10
229 search shodan windows 7
230 """
231 acceptable_api_names = ("shodan", "censys", "zoomeye")
232 api_checker = lambda l: all(i.lower() in acceptable_api_names for i in l)
233
234 try:
235 if len(query) < 1:
236 query = "".join(query)
237 else:
238 query = " ".join(query)
239 except:
240 query = query
241
242 if query == "" or query.isspace():
243 lib.output.warning("looks like you forgot the query")
244 return
245 try:
246 api_list = requested_api_data.split(",")
247 except:
248 api_list = [requested_api_data]
249 prompt_for_save = len(open(lib.settings.HOST_FILE).readlines()) != 0
250 if prompt_for_save:
251 save_mode = lib.output.prompt(
252 "would you like to [a]ppend or [o]verwrite the file[a/o]", lowercase=True
253 )
254 if save_mode.startswith("o"):
255 backup = lib.settings.backup_host_file(lib.settings.HOST_FILE, lib.settings.HOST_FILE_BACKUP)
256 lib.output.misc_info("current host file backed up under: '{}'".format(backup))
257 save_mode = "w"
258 else:
259 if not any(save_mode.startswith(s) for s in ("a", "o")):
260 lib.output.misc_info("provided option is not valid, defaulting to 'a'")
261 save_mode = "a+"
262 else:
263 save_mode = "a+"
264
265 proxy = lib.output.prompt("enter your proxy or press enter for none", lowercase=False)
266 if proxy.isspace() or proxy == "":
267 proxy = {"http": "", "https": ""}

Callers 1

terminal_main_displayMethod · 0.95

Calls 1

searchMethod · 0.45

Tested by

no test coverage detected