Skip to content

Commit e4db934

Browse files
don't follow redirects in wafw00f
1 parent 75d31cd commit e4db934

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

bbot/modules/wafw00f.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ class wafw00f(BaseModule):
2626
in_scope_only = True
2727
per_hostport_only = True
2828

29+
async def filter_event(self, event):
30+
http_status = getattr(event, "http_status", 0)
31+
if not http_status or str(http_status).startswith("3"):
32+
return False, f"Invalid HTTP status code: {http_status}"
33+
return True, ""
34+
2935
async def handle_event(self, event):
3036
url = f"{event.parsed.scheme}://{event.parsed.netloc}/"
31-
WW = await self.scan.run_in_executor(wafw00f_main.WAFW00F, url)
37+
WW = await self.scan.run_in_executor(wafw00f_main.WAFW00F, url, followredirect=False)
3238
waf_detections = await self.scan.run_in_executor(WW.identwaf)
3339
if waf_detections:
3440
for waf in waf_detections:

bbot/test/test_step_2/module_tests/test_module_wafw00f.py

+16
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,19 @@ async def setup_after_prep(self, module_test):
1212

1313
def check(self, module_test, events):
1414
assert any(e.type == "WAF" and "LiteSpeed" in e.data["WAF"] for e in events)
15+
16+
17+
class TestWafw00f_noredirect(ModuleTestBase):
18+
targets = ["http://127.0.0.1:8888"]
19+
modules_overrides = ["httpx", "wafw00f"]
20+
21+
async def setup_after_prep(self, module_test):
22+
expect_args = {"method": "GET", "uri": "/"}
23+
respond_args = {"status": 301, "headers": {"Location": "/redirect"}}
24+
module_test.set_expect_requests(expect_args=expect_args, respond_args=respond_args)
25+
expect_args = {"method": "GET", "uri": "/redirect"}
26+
respond_args = {"response_data": "Proudly powered by litespeed web server"}
27+
module_test.set_expect_requests(expect_args=expect_args, respond_args=respond_args)
28+
29+
def check(self, module_test, events):
30+
assert not any(e.type == "WAF" for e in events)

0 commit comments

Comments
 (0)