The recursive internet scanner for hackers. 🧡
Python asmattack-surface-managementautomationbugbountyclieasmhackingneo4josintosint-frameworkpentestingpythonreconrecursionscannersubdomain-enumerationsubdomain-scannersubdomainsthreat-intelligencethreatintel
access_bypass: compare a probe the catch-all control can't match with two more made-up paths
liquidsecd64bac14b697
diff --git a/bbot/modules/access_bypass/submodules/base.py b/bbot/modules/access_bypass/submodules/base.pyindex 228a3dd32..5c447c35b 100644--- a/bbot/modules/access_bypass/submodules/base.py+++ b/bbot/modules/access_bypass/submodules/base.py@@ -21,6 +21,8 @@ class Probe:# way (reflected paths, timestamps and all) is filtered out by HttpCompare itselfsibling_url: str | None = Nonesibling_url_2: str | None = None+ # the same mutation on two more made-up paths, for a second look at a probe the first two answered differently from+ sibling_urls_again: tuple[str, str] | None = Nonedef is_allowed_status(status_code):@@ -161,20 +163,29 @@ class BaseAccessBypass:reflected paths, timestamps and other volatile content before deciding whether the realtarget's response matches the junk template. If the two random paths aren't answered alike,there's nothing to tell a bypass from, so it may.++ A probe answered differently is compared again with two more random paths: a page that changed between requests,+ like one caught mid-deploy, differs once, while a bypass differs every time."""if not probe.sibling_url_2:return False- try:- control = self.helpers.http_compare(- probe.sibling_url,- baseline_url_2=probe.sibling_url_2,- method=probe.method,- headers=probe.headers,- allow_redirects=self.follow_redirects,- include_cache_buster=False,- )- match, _, _, _ = await control.compare(probe.url, headers=probe.headers, method=probe.method)- except HttpCompareError:- # the two junk samples disagreed, so a bypass can't be told from a catch-all- return True- return match is True+ pairs = [(probe.sibling_url, probe.sibling_url_2)]+ if probe.sibling_urls_again:+ pairs.append(probe.sibling_urls_again)+ for url, url_2 in pairs:+ try:+ control = self.helpers.http_compare(+ url,+ baseline_url_2=url_2,+ method=probe.method,+ headers=probe.headers,+ allow_redirects=self.follow_redirects,+ include_cache_buster=False,+ )+ match, _, _, _ = await control.compare(probe.url, headers=probe.headers, method=probe.method)+ except HttpCompareError:+ # the two junk samples disagreed, so a bypass can't be told from a catch-all+ return True+ if match is True:+ return True+ return Falsediff --git a/bbot/modules/access_bypass/submodules/path.py b/bbot/modules/access_bypass/submodules/path.pyindex 0b9a62330..b85f8493e 100644--- a/bbot/modules/access_bypass/submodules/path.py+++ b/bbot/modules/access_bypass/submodules/path.py@@ -54,23 +54,23 @@ class path(BaseAccessBypass):friendly_name = "Path Manipulation"def probes(self):- # two random sibling paths, so the catch-all control can baseline against the junk template- sibling_mutations_1 = self.mutations(self.sibling_path(self.parsed_url.path))- sibling_mutations_2 = self.mutations(self.sibling_path(self.parsed_url.path))+ # random sibling paths, so the catch-all control can baseline against the junk template: two, and two more for+ # a second look+ siblings = [self.mutations(self.sibling_path(self.parsed_url.path)) for _ in range(4)]seen = set()for key, mutated in self.mutations(self.parsed_url.path).items():if mutated in seen:continueseen.add(mutated)url = f"{self.base_url}{mutated}"- sibling_1 = sibling_mutations_1.get(key)- sibling_2 = sibling_mutations_2.get(key)+ sibling_urls = [f"{self.base_url}{s[key]}" if key in s else None for s in siblings]yield Probe(key=key,label=f"Modified URL: GET {url}",url=url,- sibling_url=f"{self.base_url}{sibling_1}" if sibling_1 else None,- sibling_url_2=f"{self.base_url}{sibling_2}" if sibling_2 else None,+ sibling_url=sibling_urls[0],+ sibling_url_2=sibling_urls[1],+ sibling_urls_again=(sibling_urls[2], sibling_urls[3]) if all(sibling_urls[2:]) else None,)def sibling_path(self, path):diff --git a/bbot/test/test_step_2/module_tests/test_module_access_bypass.py b/bbot/test/test_step_2/module_tests/test_module_access_bypass.pyindex 32de9f670..9e12f22b1 100644--- a/bbot/test/test_step_2/module_tests/test_module_access_bypass.py+++ b/bbot/test/test_step_2/module_tests/test_module_access_bypass.py@@ -647,3 +647,58 @@ class TestAccessBypass_nextjs(ModuleTestBase):def check(self, module_test, events):findings = [e for e in events if e.type == "FINDING"]assert any("Next.js" in f.data["description"] for f in findings)+++# a folder of static files on a CDN, closed to listing, in front of an app that answers any other path with its own page+STATIC_DENIED = "<Error><Code>AccessDenied</Code></Error>"+APP_PAGE = "<html><head><title>Home</title></head><body>the app, build {build}</body></html>"+++def catch_all(changes_once=None, secret_uris=()):+ """+ A handler for that site. The page at `changes_once` comes back from another build on its second request only, like a+ page caught mid-deploy. `secret_uris` get the folder's own content.+ """+ requests = {}++ def handler(request):+ uri = request.environ.get("REQUEST_URI")+ if uri in secret_uris:+ return Response("the static folder's index: app.js, config.json")+ if uri.startswith("/static/"):+ return Response(STATIC_DENIED, status=403)+ requests[uri] = requests.get(uri, 0) + 1+ build = 2 if uri == changes_once and requests[uri] == 2 else 1+ return Response(APP_PAGE.format(build=build))++ return handler+++class TestAccessBypass_catch_all_changed_once(ModuleTestBase):+ """A probe that gets the site's catch-all page isn't a bypass, even if the page changed between it and the control"""++ targets = [f"{HTTPSERVER_URL}/static/app/"]+ modules_overrides = ["access_bypass", "http"]+ module_name = "access_bypass"+ config_overrides = {"modules": {"access_bypass": {"enabled_submodules": ["path"]}}}++ async def setup_after_prep(self, module_test):+ handler = catch_all(changes_once="/%2e/static/app/")+ module_test.httpserver.expect_request(re.compile(r"/.*")).respond_with_handler(handler)++ def check(self, module_test, events):+ findings = [e.data["description"] for e in events if e.type == "FINDING" and e.data["severity"] == "MEDIUM"]+ assert not findings, findings+++class TestAccessBypass_catch_all_real_bypass(TestAccessBypass_catch_all_changed_once):+ """On the same site, a probe that gets the folder's own content is still a bypass"""++ async def setup_after_prep(self, module_test):+ handler = catch_all(secret_uris={"/static/app..;/"})+ module_test.httpserver.expect_request(re.compile(r"/.*")).respond_with_handler(handler)++ def check(self, module_test, events):+ findings = [e.data["description"] for e in events if e.type == "FINDING" and e.data["severity"] == "MEDIUM"]+ assert len(findings) == 1, findings+ assert f"{HTTPSERVER_URL}/static/app..;/" in findings[0]