|
9 | 9 |
|
10 | 10 | from leakix.domain import L9Subdomain |
11 | 11 | from leakix.plugin import APIResult |
12 | | -from leakix.query import EmptyQuery, Query |
| 12 | +from leakix.query import EmptyQuery, Query, RawQuery |
13 | 13 | from leakix.response import ( |
14 | 14 | AbstractResponse, |
15 | 15 | ErrorResponse, |
@@ -243,3 +243,43 @@ def bulk_service(self, queries: list[Query] | None = None) -> AbstractResponse: |
243 | 243 | return ErrorResponse(response=r, response_json=[], status_code=200) |
244 | 244 | else: |
245 | 245 | return ErrorResponse(response=r, response_json=r.json()) |
| 246 | + |
| 247 | + def get_domain(self, domain: str) -> AbstractResponse: |
| 248 | + """ |
| 249 | + Returns the list of services and associated leaks for a given domain. |
| 250 | + """ |
| 251 | + url = f"{self.base_url}/domain/{domain}" |
| 252 | + r = self.__get(url, params=None) |
| 253 | + if r.is_success(): |
| 254 | + response_json = r.json() |
| 255 | + formatted_result = HostResult.from_dict(response_json) |
| 256 | + response_json = { |
| 257 | + "services": formatted_result.Services, |
| 258 | + "leaks": formatted_result.Leaks, |
| 259 | + } |
| 260 | + r.response_json = response_json |
| 261 | + return r |
| 262 | + |
| 263 | + def search(self, query: str, scope: str = "leak", page: int = 0) -> AbstractResponse: |
| 264 | + """ |
| 265 | + Simple search using a query string. |
| 266 | +
|
| 267 | + This is a convenience method that accepts a raw query string like on the website. |
| 268 | + For example: "+plugin:GitConfigHttpPlugin +country:FR" |
| 269 | +
|
| 270 | + Args: |
| 271 | + query: The search query string (same syntax as the website) |
| 272 | + scope: Either "leak" or "service" (default: "leak") |
| 273 | + page: Page number for pagination (default: 0) |
| 274 | +
|
| 275 | + Returns: |
| 276 | + A response object with the search results. |
| 277 | +
|
| 278 | + Example: |
| 279 | + >>> client.search("+plugin:GitConfigHttpPlugin", scope="leak") |
| 280 | + >>> client.search("+country:FR +port:22", scope="service") |
| 281 | + """ |
| 282 | + queries = [RawQuery(query)] |
| 283 | + if scope == "service": |
| 284 | + return self.get_service(queries=queries, page=page) |
| 285 | + return self.get_leak(queries=queries, page=page) |
0 commit comments