shadowcat 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent/__init__.py +17 -0
- agent/benchmark/__init__.py +11 -0
- agent/benchmark/cli.py +179 -0
- agent/benchmark/config.py +15 -0
- agent/benchmark/docker.py +192 -0
- agent/benchmark/registry.py +99 -0
- agent/core/__init__.py +0 -0
- agent/core/agent.py +362 -0
- agent/core/backend.py +1667 -0
- agent/core/config.py +106 -0
- agent/core/controller.py +638 -0
- agent/core/events.py +177 -0
- agent/core/langfuse.py +320 -0
- agent/core/phantom.py +2327 -0
- agent/core/planner.py +493 -0
- agent/core/profiling.py +58 -0
- agent/core/sanitizer.py +104 -0
- agent/core/session.py +228 -0
- agent/core/tracer.py +137 -0
- agent/interface/__init__.py +0 -0
- agent/interface/components/__init__.py +0 -0
- agent/interface/components/activity_feed.py +202 -0
- agent/interface/components/renderers.py +149 -0
- agent/interface/components/splash.py +112 -0
- agent/interface/main.py +1126 -0
- agent/interface/styles.tcss +421 -0
- agent/interface/tui.py +508 -0
- agent/parsing/html_distiller.py +230 -0
- agent/parsing/tool_parser.py +115 -0
- agent/prompts/__init__.py +0 -0
- agent/prompts/pentesting.py +238 -0
- agent/rag_module/knowledge_base.py +116 -0
- agent/tests/benchmark_phantom.py +455 -0
- agent/tools/__init__.py +14 -0
- agent/tools/base.py +99 -0
- agent/tools/executor.py +345 -0
- agent/tools/registry.py +47 -0
- backend/README.md +244 -0
- backend/__init__.py +10 -0
- backend/api/__init__.py +1 -0
- backend/api/routes_scan.py +932 -0
- backend/authz.py +75 -0
- backend/cli.py +261 -0
- backend/compliance/__init__.py +1 -0
- backend/compliance/pdpa_mapping.py +16 -0
- backend/core/__init__.py +1 -0
- backend/core/coverage.py +93 -0
- backend/core/events.py +166 -0
- backend/core/llm_client.py +614 -0
- backend/core/orchestrator.py +402 -0
- backend/core/scan_memory.py +236 -0
- backend/crawler/__init__.py +1 -0
- backend/crawler/csrf.py +75 -0
- backend/crawler/headless.py +232 -0
- backend/crawler/js_analyzer.py +133 -0
- backend/crawler/spider.py +550 -0
- backend/crawler/subdomains.py +279 -0
- backend/daemon.py +252 -0
- backend/db/README.md +86 -0
- backend/db/__init__.py +17 -0
- backend/db/engine.py +87 -0
- backend/db/models.py +206 -0
- backend/db/repository.py +316 -0
- backend/db/schema.sql +247 -0
- backend/modes/__init__.py +5 -0
- backend/modes/base.py +178 -0
- backend/modes/ctf.py +39 -0
- backend/modes/enterprise.py +210 -0
- backend/modes/general.py +226 -0
- backend/modes/registry.py +34 -0
- backend/reporting/__init__.py +0 -0
- backend/reporting/generator.py +285 -0
- backend/schemas/__init__.py +1 -0
- backend/schemas/api.py +423 -0
- backend/tools/__init__.py +62 -0
- backend/tools/dirbrute_tool.py +304 -0
- backend/tools/general_report_tool.py +135 -0
- backend/tools/http_tool.py +351 -0
- backend/tools/nuclei_tool.py +20 -0
- backend/tools/report_tool.py +145 -0
- backend/tools/shell_tools.py +23 -0
- backend/verification/__init__.py +1 -0
- backend/verification/evidence_store.py +125 -0
- backend/verification/general_oracle.py +369 -0
- backend/verification/idor_oracle.py +131 -0
- backend/waf/__init__.py +0 -0
- backend/waf/detector.py +147 -0
- backend/waf/evasion.py +117 -0
- backend/webui/index.html +713 -0
- backend/workspace.py +182 -0
- shadowcat-2.0.0.dist-info/METADATA +360 -0
- shadowcat-2.0.0.dist-info/RECORD +95 -0
- shadowcat-2.0.0.dist-info/WHEEL +4 -0
- shadowcat-2.0.0.dist-info/entry_points.txt +4 -0
- shadowcat-2.0.0.dist-info/licenses/LICENSE.md +21 -0
backend/waf/evasion.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Payload mutation for WAF evasion.
|
|
2
|
+
|
|
3
|
+
Generates encoding and syntactic variants of a test payload so the agent can
|
|
4
|
+
try alternatives when a WAF blocks the canonical form. The oracle evaluates only
|
|
5
|
+
variants that received a non-blocked (non-403/429) response.
|
|
6
|
+
|
|
7
|
+
Usage::
|
|
8
|
+
|
|
9
|
+
from backend.waf.evasion import mutate, browser_headers
|
|
10
|
+
|
|
11
|
+
variants = mutate("' OR '1'='1")
|
|
12
|
+
headers = browser_headers(index=0) # rotate index per request
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import re
|
|
18
|
+
import urllib.parse
|
|
19
|
+
|
|
20
|
+
# Browser User-Agent pool — rotated per request to avoid UA fingerprinting.
|
|
21
|
+
_USER_AGENTS = [
|
|
22
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
|
|
23
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 14_4_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
|
|
24
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0",
|
|
25
|
+
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
|
|
26
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 14.4; rv:125.0) Gecko/20100101 Firefox/125.0",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
_BROWSER_COMMON = {
|
|
30
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
|
31
|
+
"Accept-Language": "en-US,en;q=0.9",
|
|
32
|
+
"Accept-Encoding": "gzip, deflate, br",
|
|
33
|
+
"Connection": "keep-alive",
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# SQL keywords that benefit from comment-injection splitting.
|
|
37
|
+
_SQL_KEYWORDS = re.compile(
|
|
38
|
+
r"\b(SELECT|UNION|INSERT|UPDATE|DELETE|DROP|WHERE|FROM|AND|OR|HAVING|ORDER|GROUP)\b",
|
|
39
|
+
re.IGNORECASE,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def browser_headers(index: int = 0) -> dict[str, str]:
|
|
44
|
+
"""Return browser-like headers. Rotate *index* per request for UA diversity."""
|
|
45
|
+
return {
|
|
46
|
+
"User-Agent": _USER_AGENTS[index % len(_USER_AGENTS)],
|
|
47
|
+
"X-Forwarded-For": "127.0.0.1",
|
|
48
|
+
**_BROWSER_COMMON,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def mutate(payload: str) -> list[str]:
|
|
53
|
+
"""Return encoding/syntactic variants of *payload* for WAF bypass.
|
|
54
|
+
|
|
55
|
+
The canonical payload is always first; subsequent entries are tried only
|
|
56
|
+
when the canonical attempt is blocked (403/406/429).
|
|
57
|
+
"""
|
|
58
|
+
variants: list[str] = [payload]
|
|
59
|
+
|
|
60
|
+
def _add(v: str) -> None:
|
|
61
|
+
if v and v not in variants:
|
|
62
|
+
variants.append(v)
|
|
63
|
+
|
|
64
|
+
# URL-encode special chars (' < > " space)
|
|
65
|
+
url_enc = urllib.parse.quote(payload, safe="=&+")
|
|
66
|
+
_add(url_enc)
|
|
67
|
+
|
|
68
|
+
# Double URL-encode (%27 → %2527)
|
|
69
|
+
double_enc = url_enc.replace("%", "%25")
|
|
70
|
+
_add(double_enc)
|
|
71
|
+
|
|
72
|
+
# Unicode escapes for common injection chars
|
|
73
|
+
_add(
|
|
74
|
+
payload.replace("'", "\\u0027")
|
|
75
|
+
.replace('"', "\\u0022")
|
|
76
|
+
.replace("<", "\\u003C")
|
|
77
|
+
.replace(">", "\\u003E")
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# Alternating-case (breaks keyword blocklists)
|
|
81
|
+
_add(_alternating_case(payload))
|
|
82
|
+
|
|
83
|
+
# SQL comment injection: SELECT → SE/**/LECT
|
|
84
|
+
_add(_comment_split(payload))
|
|
85
|
+
|
|
86
|
+
# Null-byte suffix (some WAF parsers stop at %00)
|
|
87
|
+
_add(payload + "%00")
|
|
88
|
+
|
|
89
|
+
# HTML entity encoding for XSS payloads
|
|
90
|
+
_add(
|
|
91
|
+
payload.replace("<", "<")
|
|
92
|
+
.replace(">", ">")
|
|
93
|
+
.replace('"', """)
|
|
94
|
+
.replace("'", "'")
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
return variants
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _alternating_case(s: str) -> str:
|
|
101
|
+
result, upper = [], True
|
|
102
|
+
for ch in s:
|
|
103
|
+
if ch.isalpha():
|
|
104
|
+
result.append(ch.upper() if upper else ch.lower())
|
|
105
|
+
upper = not upper
|
|
106
|
+
else:
|
|
107
|
+
result.append(ch)
|
|
108
|
+
return "".join(result)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _comment_split(s: str) -> str:
|
|
112
|
+
def _split_kw(m: re.Match[str]) -> str:
|
|
113
|
+
kw = m.group(0)
|
|
114
|
+
mid = len(kw) // 2
|
|
115
|
+
return str(kw[:mid] + "/**/" + kw[mid:])
|
|
116
|
+
|
|
117
|
+
return _SQL_KEYWORDS.sub(_split_kw, s)
|