connect to the Censys API and pull all IP addresses from the provided query
(self)
| 25 | self.save_mode = save_mode |
| 26 | |
| 27 | def search(self): |
| 28 | """ |
| 29 | connect to the Censys API and pull all IP addresses from the provided query |
| 30 | """ |
| 31 | discovered_censys_hosts = set() |
| 32 | try: |
| 33 | lib.settings.start_animation("searching Censys with given query '{}'".format(self.query)) |
| 34 | req = requests.post( |
| 35 | API_URLS["censys"], auth=(self.id, self.token), |
| 36 | json={"query": self.query}, headers=self.user_agent, |
| 37 | proxies=self.proxy |
| 38 | ) |
| 39 | json_data = req.json() |
| 40 | for item in json_data["results"]: |
| 41 | discovered_censys_hosts.add(str(item["ip"])) |
| 42 | write_to_file(discovered_censys_hosts, self.host_file, mode=self.save_mode) |
| 43 | return True |
| 44 | except Exception as e: |
| 45 | raise AutoSploitAPIConnectionError(str(e)) |
no test coverage detected