Skip to content

Commit

Permalink
fix baddns tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer committed May 11, 2024
1 parent 490c486 commit 6d6d602
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
14 changes: 14 additions & 0 deletions bbot/core/helpers/web/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ class BBOTAsyncClient(httpx.AsyncClient):
200
"""

@classmethod
def from_config(cls, config, target, *args, **kwargs):
kwargs["_config"] = config
kwargs["_target"] = target
retries = kwargs.pop("retries", config.get("http_retries", 1))
ssl_verify = config.get("ssl_verify", False)
if ssl_verify is False:
from .ssl_context import ssl_context_noverify

ssl_verify = ssl_context_noverify
kwargs["transport"] = httpx.AsyncHTTPTransport(retries=retries, verify=ssl_verify)
kwargs["verify"] = ssl_verify
return cls(*args, **kwargs)

def __init__(self, *args, **kwargs):
self._config = kwargs.pop("_config")
self._target = kwargs.pop("_target")
Expand Down
15 changes: 1 addition & 14 deletions bbot/core/helpers/web/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,7 @@ def __init__(self, socket_path, target, config={}):
self.config = config
self.http_debug = self.config.get("http_debug", False)
self._ssl_context_noverify = None
self.ssl_verify = self.config.get("ssl_verify", False)
if self.ssl_verify is False:
from .ssl_context import ssl_context_noverify

self.ssl_verify = ssl_context_noverify
self.web_client = self.AsyncClient(persist_cookies=False)

def AsyncClient(self, *args, **kwargs):
kwargs["_config"] = self.config
kwargs["_target"] = self.target
retries = kwargs.pop("retries", self.config.get("http_retries", 1))
kwargs["transport"] = httpx.AsyncHTTPTransport(retries=retries, verify=self.ssl_verify)
kwargs["verify"] = self.ssl_verify
return BBOTAsyncClient(*args, **kwargs)
self.web_client = BBOTAsyncClient.from_config(self.config, self.target, persist_cookies=False)

async def request(self, *args, **kwargs):
raise_error = kwargs.pop("raise_error", False)
Expand Down
9 changes: 8 additions & 1 deletion bbot/core/helpers/web/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@ class WebHelper(EngineClient):

def __init__(self, parent_helper):
self.parent_helper = parent_helper
self.config = self.parent_helper.config
self.preset = self.parent_helper.preset
self.config = self.preset.config
self.target = self.preset.target
self.ssl_verify = self.config.get("ssl_verify", False)
super().__init__(server_kwargs={"config": self.config, "target": self.parent_helper.preset.target.radix_only})

def AsyncClient(self, *args, **kwargs):
from .client import BBOTAsyncClient

return BBOTAsyncClient.from_config(self.config, self.target, *args, persist_cookies=False, **kwargs)

async def request(self, *args, **kwargs):
"""
Asynchronous function for making HTTP requests, intended to be the most basic web request function
Expand Down
12 changes: 6 additions & 6 deletions bbot/test/test_step_2/module_tests/test_module_baddns.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ async def setup_after_prep(self, module_test):
module_test.monkeypatch.setattr(WhoisManager, "dispatchWHOIS", self.dispatchWHOIS)

def check(self, module_test, events):
assert any(e.data == "baddns.azurewebsites.net" for e in events), "CNAME detection failed"
assert any(e.type == "VULNERABILITY" for e in events), "Failed to emit VULNERABILITY"
assert any("baddns-cname" in e.tags for e in events), "Failed to add baddns tag"
assert any([e.data == "baddns.azurewebsites.net" for e in events]), "CNAME detection failed"
assert any([e.type == "VULNERABILITY" for e in events]), "Failed to emit VULNERABILITY"
assert any(["baddns-cname" in e.tags for e in events]), "Failed to add baddns tag"


class TestBaddns_cname_signature(BaseTestBaddns):
Expand All @@ -60,8 +60,8 @@ def set_target(self, target):
module_test.monkeypatch.setattr(WhoisManager, "dispatchWHOIS", self.dispatchWHOIS)

def check(self, module_test, events):
assert any(e for e in events)
assert any([e for e in events])
assert any(
e.type == "VULNERABILITY" and "bigcartel.com" in e.data["description"] for e in events
[e.type == "VULNERABILITY" and "bigcartel.com" in e.data["description"] for e in events]
), "Failed to emit VULNERABILITY"
assert any("baddns-cname" in e.tags for e in events), "Failed to add baddns tag"
assert any(["baddns-cname" in e.tags for e in events]), "Failed to add baddns tag"

0 comments on commit 6d6d602

Please sign in to comment.