MCPcopy Create free account
hub / github.com/blacklanternsecurity/bbot / query

Method query

bbot/modules/dehashed.py:90–120  ·  view source on GitHub ↗
(self, domain)

Source from the content-addressed store, hash-verified

88 )
89
90 async def query(self, domain):
91 url = self.base_url
92 json = {
93 "query": "",
94 "page": 1,
95 "size": 10000, # The maximum permitted size and pagination.
96 }
97 json["query"] = f"domain:{domain}"
98 json["page"] = 1
99 max_pages = 1
100 agen = self.api_page_iter(url=url, headers=self.headers, _json=False, method="POST", json=json)
101 async for result in agen:
102 result_json = {}
103 with suppress(Exception):
104 result_json = result.json()
105 total = result_json.get("total", 0)
106 entries = result_json.get("entries", [])
107 json["page"] += 1
108 if result is not None and result.status_code != 200:
109 self.warning(
110 f"Error retrieving results from dehashed.com (status code {result.status_code}): {result.text}"
111 )
112 elif (json["page"] > max_pages) and (total > (json["size"] * max_pages)):
113 self.info(
114 f"{domain} has {total:,} results in Dehashed. The API can only process the first 10,000 results. Please check dehashed.com to get the remaining results."
115 )
116 if entries:
117 yield entries
118 if not entries or json["page"] > max_pages:
119 await agen.aclose()
120 break

Callers 1

handle_eventMethod · 0.95

Calls 5

api_page_iterMethod · 0.45
jsonMethod · 0.45
getMethod · 0.45
warningMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected