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

Method search

api_calls/shodan.py:28–45  ·  view source on GitHub ↗

connect to the API and grab all IP addresses associated with the provided query

(self)

Source from the content-addressed store, hash-verified

26 self.save_mode = save_mode
27
28 def search(self):
29 """
30 connect to the API and grab all IP addresses associated with the provided query
31 """
32 start_animation("searching Shodan with given query '{}'".format(self.query))
33 discovered_shodan_hosts = set()
34 try:
35 req = requests.get(
36 API_URLS["shodan"].format(query=self.query, token=self.token),
37 proxies=self.proxy, headers=self.user_agent
38 )
39 json_data = json.loads(req.content)
40 for match in json_data["matches"]:
41 discovered_shodan_hosts.add(match["ip_str"])
42 write_to_file(discovered_shodan_hosts, self.host_file, mode=self.save_mode)
43 return True
44 except Exception as e:
45 raise AutoSploitAPIConnectionError(str(e))
46
47

Callers

nothing calls this directly

Calls 3

start_animationFunction · 0.90
write_to_fileFunction · 0.90

Tested by

no test coverage detected