connect to the API and grab all IP addresses associated with the provided query
(self)
| 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 |
nothing calls this directly
no test coverage detected