From c43b30c8452a44c5138d94de018cd86046e36522 Mon Sep 17 00:00:00 2001 From: TheTechromancer Date: Mon, 18 Sep 2023 16:10:30 -0400 Subject: [PATCH] fix minor but with waf events scope distance --- bbot/core/event/base.py | 15 +++++++++++++++ bbot/modules/wafw00f.py | 13 +++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/bbot/core/event/base.py b/bbot/core/event/base.py index c4fca0d83..22326fb49 100644 --- a/bbot/core/event/base.py +++ b/bbot/core/event/base.py @@ -947,6 +947,21 @@ class AZURE_TENANT(DictEvent): _always_emit = True +class WAF(DictHostEvent): + _always_emit = True + + class _data_validator(BaseModel): + url: str + host: str + WAF: str + info: Optional[str] + _validate_url = validator("url", allow_reuse=True)(validators.validate_url) + _validate_host = validator("host", allow_reuse=True)(validators.validate_host) + + def _pretty_string(self): + return self.data["WAF"] + + def make_event( data, event_type=None, diff --git a/bbot/modules/wafw00f.py b/bbot/modules/wafw00f.py index 192cf83c8..f15b82263 100644 --- a/bbot/modules/wafw00f.py +++ b/bbot/modules/wafw00f.py @@ -21,18 +21,23 @@ class wafw00f(BaseModule): per_host_only = True async def handle_event(self, event): - host = f"{event.parsed.scheme}://{event.parsed.netloc}/" - WW = await self.scan.run_in_executor(wafw00f_main.WAFW00F, host) + url = f"{event.parsed.scheme}://{event.parsed.netloc}/" + WW = await self.scan.run_in_executor(wafw00f_main.WAFW00F, url) waf_detections = await self.scan.run_in_executor(WW.identwaf) if waf_detections: for waf in waf_detections: - self.emit_event({"host": host, "WAF": waf}, "WAF", source=event) + self.emit_event({"host": str(event.host), "url": url, "WAF": waf}, "WAF", source=event) else: if self.config.get("generic_detect") == True: generic = await self.scan.run_in_executor(WW.genericdetect) if generic: self.emit_event( - {"host": host, "WAF": "generic detection", "info": WW.knowledge["generic"]["reason"]}, + { + "host": str(event.host), + "url": url, + "WAF": "generic detection", + "info": WW.knowledge["generic"]["reason"], + }, "WAF", source=event, )