From 1709e0cf0a7ed808bfd0aafc66fbe2e830b43458 Mon Sep 17 00:00:00 2001 From: surya Date: Mon, 6 Jul 2026 18:00:52 +0530 Subject: [PATCH] [fix]: preserve pre-encoded payloads in simulator requests urllib.parse.quote(path, safe='/?&=') was re-encoding % to %25 in already-encoded attack paths (XXE, XSS, traversal payloads). Replaced with a manual first-? split: path component encoded with safe='/%\' (preserving existing percent sequences and backslash traversal vectors), query string passed through untouched. Covers all 53 attack payloads across 7 simulation modes. Inline comments removed from XXE_PAYLOADS to match the style of all other payload lists. --- .../ai-threat-detection/dev-log/simulate.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PROJECTS/advanced/ai-threat-detection/dev-log/simulate.py b/PROJECTS/advanced/ai-threat-detection/dev-log/simulate.py index afaaa8a0..6eab8177 100755 --- a/PROJECTS/advanced/ai-threat-detection/dev-log/simulate.py +++ b/PROJECTS/advanced/ai-threat-detection/dev-log/simulate.py @@ -120,15 +120,10 @@ SSRF_PAYLOADS = [ ] XXE_PAYLOADS = [ - # Classic file disclosure via internal entity "/api/test?data=%3C!DOCTYPE+foo+%5B%3C!ENTITY+xxe+SYSTEM+%22file%3A%2F%2F%2Fetc%2Fpasswd%22%3E%5D%3E", - # SYSTEM keyword targeting /etc/hosts "/api/test?xml=]>", - # XInclude (xmlns:xi) attempt "/api/test?body=", - # URL-encoded ]>&q=&xxe;", ] @@ -169,8 +164,13 @@ ATTACK_POOLS = { def send(target, path, user_agent=None, method="GET"): - encoded_path = urllib.parse.quote(path, safe="/?&=") - url = f"{target}{encoded_path}" + if "?" in path: + _raw_path, _raw_query = path.split("?", 1) + _encoded_path = urllib.parse.quote(_raw_path, safe="/%") + _url_path = f"{_encoded_path}?{_raw_query}" + else: + _url_path = urllib.parse.quote(path, safe="/%\\") + url = f"{target}{_url_path}" ua = user_agent or random.choice(NORMAL_USER_AGENTS) req = urllib.request.Request(url, headers={"User-Agent": ua}) if method == "POST":