Skip to content

armgit / bbot

Public Imported from GitHub
0

The recursive internet scanner for hackers. 🧡

Add method-tampering submodule and parser-confusion path families to access_bypass

liquidsecf3bf8af76986
diff --git a/bbot/modules/access_bypass/access_bypass.py b/bbot/modules/access_bypass/access_bypass.py
index 7ffb1a4ba..326c828fd 100644
--- a/bbot/modules/access_bypass/access_bypass.py
+++ b/bbot/modules/access_bypass/access_bypass.py
@@ -5,7 +5,7 @@ from bbot.modules.base import BaseModule
from bbot.core.helpers.misc import get_waf_strings
from bbot.core.config.models import BaseModuleConfig, Field
-SUBMODULES = ["path", "headers", "auth", "extension_routing", "nextjs"]
+SUBMODULES = ["path", "headers", "method", "auth", "extension_routing", "nextjs"]
class access_bypass(BaseModule):
@@ -22,13 +22,18 @@ class access_bypass(BaseModule):
class Config(BaseModuleConfig):
enabled_submodules: list[str] = Field(
- ["path", "headers", "auth", "extension_routing", "nextjs"],
+ ["path", "headers", "method", "auth", "extension_routing", "nextjs"],
description="Which access_bypass submodules to run. Empty list enables all.",
)
allow_redirects: bool = Field(
True,
description="Follow redirects when comparing responses. Disabling trades false positives for false negatives.",
)
+ state_changing_methods: bool = Field(
+ False,
+ description="Let the 'method' submodule send state-changing verbs (POST/PUT/PATCH/DELETE) and "
+ "method-override headers. These can modify the target, so enabling this makes the module invasive.",
+ )
# when more than this many signatures fire on one URL, collapse into a single finding
collapse_threshold = 6
diff --git a/bbot/modules/access_bypass/submodules/headers.py b/bbot/modules/access_bypass/submodules/headers.py
index 5389dd79e..ef286337a 100644
--- a/bbot/modules/access_bypass/submodules/headers.py
+++ b/bbot/modules/access_bypass/submodules/headers.py
@@ -64,4 +64,3 @@ class headers(BaseAccessBypass):
method="POST",
headers={"Content-Length": "0"},
)
- yield Probe(key="trace", label="Modified URL: TRACE", url=url, method="TRACE")
diff --git a/bbot/modules/access_bypass/submodules/method.py b/bbot/modules/access_bypass/submodules/method.py
new file mode 100644
index 000000000..0b86d52a1
--- /dev/null
+++ b/bbot/modules/access_bypass/submodules/method.py
@@ -0,0 +1,47 @@
+from .base import BaseAccessBypass, Probe
+
+# Side-effect-free verbs. HEAD/OPTIONS can't modify state; an unknown verb (ACB) is routed as GET
+# by servers that don't recognize it, bypassing GET-specific deny rules without touching anything.
+safe_methods = ["HEAD", "OPTIONS", "ACB"]
+
+# State-changing verbs. Only sent when `state_changing_methods` is enabled (makes the module invasive).
+state_changing_verbs = ["POST", "PUT", "PATCH", "DELETE"]
+
+# Headers that rewrite the effective method at the application layer while the wire verb stays POST.
+# A POST on the wire may trigger actions, so these are gated behind `state_changing_methods` too.
+override_headers = ["X-HTTP-Method-Override", "X-HTTP-Method", "X-Method-Override"]
+
+
+class method(BaseAccessBypass):
+ friendly_name = "Method Manipulation"
+
+ def probes(self):
+ url = f"{self.base_url}/{self.parsed_url.path.lstrip('/')}"
+ sibling = f"{self.base_url}/{self.helpers.rand_string(8, digits=False)}"
+ sibling_2 = f"{self.base_url}/{self.helpers.rand_string(8, digits=False)}"
+
+ verbs = list(safe_methods)
+ state_changing = self.access_bypass.config.get("state_changing_methods", False)
+ if state_changing:
+ verbs += state_changing_verbs
+
+ for verb in verbs:
+ yield Probe(
+ key=f"method:{verb}",
+ label=f"Modified Method: {verb}",
+ url=url,
+ method=verb,
+ sibling_url=sibling,
+ sibling_url_2=sibling_2,
+ )
+ if state_changing:
+ for header in override_headers:
+ yield Probe(
+ key=f"override:{header}",
+ label=f"Added Header: {header}: GET (POST)",
+ url=url,
+ method="POST",
+ headers={header: "GET"},
+ sibling_url=sibling,
+ sibling_url_2=sibling_2,
+ )
diff --git a/bbot/modules/access_bypass/submodules/path.py b/bbot/modules/access_bypass/submodules/path.py
index 8243cd48d..0b9a62330 100644
--- a/bbot/modules/access_bypass/submodules/path.py
+++ b/bbot/modules/access_bypass/submodules/path.py
@@ -37,6 +37,18 @@ static_extensions = [".ico", ".css", ".js", ".png", ".jpg", ".svg", ".woff2", ".
# extensions that may route the request to a different handler at the origin
routing_extensions = [".html", ".php", ".json"]
+# Parser-confusion families (Orange Tsai: Breaking Parser Logic / Confusion Attacks).
+# Each exploits a disagreement between how an edge/proxy and the origin parse a path.
+# Encoded '?' truncation: the edge/auth module sees the full string, the origin (mod_proxy +
+# PHP-FPM, rewrite targets) truncates at the decoded '?', dropping the appended suffix.
+qmark_suffixes = ["%3F", "%3F.css", "%3F.php", "%3Fa"]
+# Double-encoded and encoded separators: proxy and origin disagree on how many times to decode.
+separator_payloads = ["%252e", "%252f", "%255c", "%5c"]
+# Encoded control characters that truncate the path at the origin if decoded.
+truncation_suffixes = ["%00", "%0a", "%0d", "%0c", "%26"]
+# Encoded dot-segment traversal: the edge ACL matches the literal prefix, the origin resolves it away.
+traversal_prefixes = ["..%2f", "%2e%2e/", "..%252f", "..%5c"]
+
class path(BaseAccessBypass):
friendly_name = "Path Manipulation"
@@ -95,6 +107,17 @@ class path(BaseAccessBypass):
for ext in static_extensions + routing_extensions:
mutations[f"ext:{ext}"] = f"/{stripped}{ext}"
+
+ # parser-confusion families
+ for qp in qmark_suffixes:
+ mutations[f"enc-qmark:{qp}"] = f"/{stripped}{qp}"
+ for sp in separator_payloads:
+ mutations[f"enc-sep-suffix:{sp}"] = f"/{stripped}{sp}"
+ mutations[f"enc-sep-prefix:{sp}"] = f"/{sp}/{stripped}"
+ for cp in truncation_suffixes:
+ mutations[f"enc-trunc:{cp}"] = f"/{stripped}{cp}"
+ for tp in traversal_prefixes:
+ mutations[f"traversal:{tp}"] = f"/{tp}{stripped}"
return mutations
async def confirm(self, probe, response):
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.py
index 5fc9d99e2..212a08bc7 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
@@ -371,6 +371,89 @@ class TestAccessBypass_nextjs_redirected(ModuleTestBase):
assert not any(e.type == "FINDING" and "Next.js" in e.data["description"] for e in events)
+class TestAccessBypass_method(ModuleTestBase):
+ """A GET-only block is lifted when the same path is replayed as POST (state_changing enabled)."""
+
+ targets = [f"{HTTPSERVER_URL}/secure"]
+ modules_overrides = ["access_bypass", "http"]
+ module_name = "access_bypass"
+ config_overrides = {"modules": {"access_bypass": {"state_changing_methods": True}}}
+
+ async def setup_after_prep(self, module_test):
+ module_test.httpserver.expect_request("/secure", method="POST").respond_with_data(
+ "admin area reached", status=200
+ )
+ module_test.httpserver.no_handler_status_code = 403
+
+ def check(self, module_test, events):
+ findings = [e for e in events if e.type == "FINDING"]
+ assert any("Modified Method: POST" in f.data["description"] for f in findings)
+
+
+class TestAccessBypass_method_gated(ModuleTestBase):
+ """With the default config, state-changing verbs are not sent, so a POST-only bypass is missed."""
+
+ targets = [f"{HTTPSERVER_URL}/secure"]
+ modules_overrides = ["access_bypass", "http"]
+ module_name = "access_bypass"
+
+ async def setup_after_prep(self, module_test):
+ module_test.httpserver.expect_request("/secure", method="POST").respond_with_data(
+ "admin area reached", status=200
+ )
+ module_test.httpserver.no_handler_status_code = 403
+
+ def check(self, module_test, events):
+ findings = [e for e in events if e.type == "FINDING"]
+ assert not any("Modified Method" in f.data["description"] for f in findings)
+
+
+class TestAccessBypass_method_options_catchall(ModuleTestBase):
+ """A server that answers OPTIONS 200 for every path is not a bypass (catch-all)."""
+
+ targets = [f"{HTTPSERVER_URL}/secure"]
+ modules_overrides = ["access_bypass", "http"]
+ module_name = "access_bypass"
+
+ async def setup_after_prep(self, module_test):
+ def handler(request):
+ if request.method == "OPTIONS":
+ return Response("", status=200)
+ return Response("", status=403)
+
+ module_test.httpserver.expect_request(re.compile(r"/.*")).respond_with_handler(handler)
+
+ def check(self, module_test, events):
+ findings = [e for e in events if e.type == "FINDING"]
+ assert not any("Modified Method: OPTIONS" in f.data["description"] for f in findings)
+
+
+class TestAccessBypass_encoded_qmark(ModuleTestBase):
+ """Family 1: /admin%3F truncates at the origin to /admin, bypassing the block on /admin."""
+
+ targets = [f"{HTTPSERVER_URL}/admin"]
+ modules_overrides = ["access_bypass", "http"]
+ module_name = "access_bypass"
+
+ async def setup_after_prep(self, module_test):
+ def handler(request):
+ raw = request.environ.get("RAW_URI") or request.environ.get("REQUEST_URI") or ""
+ if "%3f" in raw.lower():
+ # origin truncates at the (decoded) '?', routing by what's left of it
+ truncated = re.split(r"%3[fF]", raw)[0].rstrip("/")
+ if truncated == "/admin":
+ return Response("admin content reached", status=200)
+ return Response("", status=404)
+ # direct access is blocked
+ return Response("", status=403)
+
+ module_test.httpserver.expect_request(re.compile(r"/.*")).respond_with_handler(handler)
+
+ def check(self, module_test, events):
+ findings = [e for e in events if e.type == "FINDING"]
+ assert any("/admin%3F" in f.data["description"] for f in findings)
+
+
class TestAccessBypass_nextjs(ModuleTestBase):
"""T2.2: a page that redirects to /auth/signin is reachable via its _next/data route."""
diff --git a/docs/modules/list_of_modules.md b/docs/modules/list_of_modules.md
index 822dba809..8e42fd21f 100644
--- a/docs/modules/list_of_modules.md
+++ b/docs/modules/list_of_modules.md
@@ -16,8 +16,8 @@
| bucket_google | scan | No | Check for Google object storage related to target | active, cloud-enum, safe, web | DNS_NAME, STORAGE_BUCKET | FINDING, STORAGE_BUCKET | @TheTechromancer | 2022-11-04 |
| bucket_hetzner | scan | No | Check for Hetzner Object Storage buckets related to target | active, cloud-enum, safe, slow, web-heavy | DNS_NAME, STORAGE_BUCKET | FINDING, STORAGE_BUCKET | @ChrisJr404 | 2026-05-04 |
| bucket_microsoft | scan | No | Check for Azure storage blobs related to target | active, cloud-enum, safe, web | DNS_NAME, STORAGE_BUCKET | FINDING, STORAGE_BUCKET | @TheTechromancer | 2022-11-04 |
-| dnsbrute | scan | No | Brute-force subdomains with massdns + static wordlist | active, loud, subdomain-enum | DNS_NAME | DNS_NAME | @TheTechromancer | 2024-04-24 |
-| dnsbrute_mutations | scan | No | Brute-force subdomains with massdns + target-specific mutations | active, loud, slow, subdomain-enum | DNS_NAME | DNS_NAME | @TheTechromancer | 2024-04-25 |
+| dnsbrute | scan | No | Brute-force subdomains with a static wordlist | active, loud, subdomain-enum | DNS_NAME | DNS_NAME | @TheTechromancer | 2024-04-24 |
+| dnsbrute_mutations | scan | No | Brute-force subdomains with target-specific mutations | active, loud, slow, subdomain-enum | DNS_NAME | DNS_NAME | @TheTechromancer | 2024-04-25 |
| dnscommonsrv | scan | No | Check for common SRV records | active, safe, subdomain-enum | DNS_NAME | DNS_NAME | @TheTechromancer | 2022-05-15 |
| dotnetnuke | scan | No | Scan for critical DotNetNuke (DNN) vulnerabilities | active, invasive, loud, web-heavy | HTTP_RESPONSE | FINDING, TECHNOLOGY | @liquidsec | 2023-11-21 |
| favicon | scan | No | Identify web technologies by the mmh3 hash of their favicon | active, safe, web-heavy | HTTP_RESPONSE | TECHNOLOGY | @liquidsec | 2026-10-16 |
diff --git a/docs/scanning/advanced.md b/docs/scanning/advanced.md
index 4368d3916..78188d7bb 100644
--- a/docs/scanning/advanced.md
+++ b/docs/scanning/advanced.md
@@ -50,6 +50,7 @@ usage: bbot [-h] [-t TARGET [TARGET ...]] [-s SEEDS [SEEDS ...]]
--ignore-failed-deps] [--install-all-deps] [--version]
[--reset-config] [--reset-secrets] [--proxy HTTP_PROXY]
[--no-proxy HOST [HOST ...]]
+ [--custom-nameservers NAMESERVER [NAMESERVER ...]]
[-H CUSTOM_HEADERS [CUSTOM_HEADERS ...]]
[-C CUSTOM_COOKIES [CUSTOM_COOKIES ...]]
[--custom-yara-rules CUSTOM_YARA_RULES]
@@ -138,6 +139,8 @@ Misc:
--proxy HTTP_PROXY Use this proxy for all HTTP requests
--no-proxy HOST [HOST ...]
Exclude these hosts from proxy (e.g. localhost *.internal.corp 10.0.0.0/8)
+ --custom-nameservers NAMESERVER [NAMESERVER ...]
+ Use these nameservers instead of the system ones (e.g. 1.1.1.1 8.8.8.8:53)
-H, --custom-headers CUSTOM_HEADERS [CUSTOM_HEADERS ...]
List of custom headers as key value pairs (header=value).
-C, --custom-cookies CUSTOM_COOKIES [CUSTOM_COOKIES ...]
diff --git a/docs/scanning/configuration.md b/docs/scanning/configuration.md
index ef7f8d54c..4f0c9d7aa 100644
--- a/docs/scanning/configuration.md
+++ b/docs/scanning/configuration.md
@@ -478,7 +478,8 @@ In addition to the stated options for each module, the following universal optio
| Config Option | Type | Description | Default |
|--------------------------------------------------------|------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| modules.access_bypass.allow_redirects | bool | Follow redirects when comparing responses. Disabling trades false positives for false negatives. | True |
-| modules.access_bypass.enabled_submodules | list[str] | Which access_bypass submodules to run. Empty list enables all. | ['path', 'headers', 'auth', 'extension_routing', 'nextjs'] |
+| modules.access_bypass.enabled_submodules | list[str] | Which access_bypass submodules to run. Empty list enables all. | ['path', 'headers', 'method', 'auth', 'extension_routing', 'nextjs'] |
+| modules.access_bypass.state_changing_methods | bool | Let the 'method' submodule send state-changing verbs (POST/PUT/PATCH/DELETE) and method-override headers. These can modify the target, so enabling this makes the module invasive. | False |
| modules.baddns.custom_nameservers | list[str] | Force BadDNS to use a list of custom nameservers | [] |
| modules.baddns.enabled_submodules | list[str] | A list of submodules to enable. Empty list (default) enables CNAME, MX, TXT and DELEGATION Only | [] |
| modules.baddns.min_confidence | ConfidenceLiteral | Minimum confidence to emit | MEDIUM |