示例#1
0
 def shodan(self):
     """
     connect to the API and grab all IP addresses associated with the provided query
     """
     start_animation("searching Shodan with given query '{}'".format(
         self.query))
     discovered_shodan_hosts = set()
     try:
         req = requests.get(API_URLS["shodan"].format(query=self.query,
                                                      token=self.token),
                            proxies=self.proxy,
                            headers=self.user_agent)
         json_data = json.loads(req.content)
         for match in json_data["matches"]:
             discovered_shodan_hosts.add(match["ip_str"])
         write_to_file(discovered_shodan_hosts, self.host_file)
         return True
     except Exception as e:
         raise AutoSploitAPIConnectionError(str(e))
示例#2
0
 def censys(self):
     """
     connect to the Censys API and pull all IP addresses from the provided query
     """
     discovered_censys_hosts = set()
     try:
         lib.settings.start_animation(
             "searching Censys with given query '{}'".format(self.query))
         req = requests.post(API_URLS["censys"],
                             auth=(self.id, self.token),
                             json={"query": self.query},
                             headers=self.user_agent,
                             proxies=self.proxy)
         json_data = req.json()
         for item in json_data["results"]:
             discovered_censys_hosts.add(str(item["ip"]))
         write_to_file(discovered_censys_hosts, self.host_file)
         return True
     except Exception as e:
         raise AutoSploitAPIConnectionError(str(e))
示例#3
0
文件: zoomeye.py 项目: bambeero1/as
 def search(self):
     """
     connect to the API and pull all the IP addresses that are associated with the
     given query
     """
     start_animation("searching ZoomEye with given query '{}'".format(
         self.query))
     discovered_zoomeye_hosts = set()
     try:
         token = self.__get_auth()
         if self.user_agent is None:
             headers = {
                 "Authorization":
                 "JWT {}".format(str(token["access_token"]))
             }
         else:
             headers = {
                 "Authorization":
                 "JWT {}".format(str(token["access_token"])),
                 "User-Agent": self.user_agent["User-Agent"]  # oops
             }
         params = {"query": self.query, "page": "1", "facet": "ipv4"}
         req = requests.get(API_URLS["zoomeye"][1].format(query=self.query),
                            params=params,
                            headers=headers,
                            proxies=self.proxy)
         _json_data = req.json()
         for item in _json_data["matches"]:
             if len(item["ip"]) > 1:
                 for ip in item["ip"]:
                     discovered_zoomeye_hosts.add(ip)
             else:
                 discovered_zoomeye_hosts.add(str(item["ip"][0]))
         write_to_file(discovered_zoomeye_hosts,
                       self.host_file,
                       mode=self.save_mode)
         return True
     except Exception as e:
         raise AutoSploitAPIConnectionError(str(e))