ether-core 0.1.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.
- ether/__init__.py +32 -0
- ether/assets/wordlists/common_dirs.txt.gz +0 -0
- ether/assets/wordlists/common_params.txt.gz +0 -0
- ether/assets/wordlists/common_passwords.txt.gz +0 -0
- ether/assets/wordlists/common_usernames.txt.gz +0 -0
- ether/assets/wordlists/subdomains_500.txt.gz +0 -0
- ether/cli/__init__.py +5 -0
- ether/cli/__main__.py +8 -0
- ether/cli/commands/__init__.py +1 -0
- ether/cli/commands/doctor.py +21 -0
- ether/cli/commands/graph.py +311 -0
- ether/cli/commands/logs.py +45 -0
- ether/cli/commands/mcp.py +49 -0
- ether/cli/commands/run.py +146 -0
- ether/cli/commands/session.py +61 -0
- ether/cli/commands/telemetry.py +51 -0
- ether/cli/commands/tool.py +131 -0
- ether/cli/context.py +71 -0
- ether/cli/formatters.py +39 -0
- ether/cli/router.py +368 -0
- ether/common/__init__.py +201 -0
- ether/common/algorithms.py +407 -0
- ether/common/canonicalize.py +93 -0
- ether/common/context.py +25 -0
- ether/common/crypto.py +183 -0
- ether/common/embeddings.py +93 -0
- ether/common/exceptions.py +13 -0
- ether/common/logging.py +386 -0
- ether/common/secure_memory.py +159 -0
- ether/common/ssrf.py +93 -0
- ether/core/__init__.py +25 -0
- ether/core/diagnostics.py +368 -0
- ether/core/executor.py +296 -0
- ether/core/sandbox.py +118 -0
- ether/core/session.py +956 -0
- ether/gateway/__init__.py +21 -0
- ether/gateway/gate.py +392 -0
- ether/gateway/network.py +98 -0
- ether/gateway/preflight.py +802 -0
- ether/graph/__init__.py +13 -0
- ether/graph/analytics.py +334 -0
- ether/graph/store.py +1615 -0
- ether/graph/telemetry.py +334 -0
- ether/graph/timeline.py +185 -0
- ether/mcp/__init__.py +5 -0
- ether/mcp/server.py +382 -0
- ether/paths.py +176 -0
- ether/py.typed +0 -0
- ether/registry/__init__.py +7 -0
- ether/registry/adapter.py +194 -0
- ether/registry/manifest.py +53 -0
- ether/registry/registry.py +150 -0
- ether/registry/wordlists.py +156 -0
- ether/schemas/__init__.py +50 -0
- ether/schemas/base.py +122 -0
- ether/schemas/credential.py +50 -0
- ether/schemas/dns.py +116 -0
- ether/schemas/host_internal.py +58 -0
- ether/schemas/network.py +142 -0
- ether/schemas/power.py +68 -0
- ether/schemas/vulnerability.py +221 -0
- ether/schemas/web.py +172 -0
- ether_core-0.1.0.dist-info/METADATA +440 -0
- ether_core-0.1.0.dist-info/RECORD +104 -0
- ether_core-0.1.0.dist-info/WHEEL +4 -0
- ether_core-0.1.0.dist-info/entry_points.txt +2 -0
- ether_core-0.1.0.dist-info/licenses/LICENSE +21 -0
- tools/__init__.py +0 -0
- tools/dnspython/__init__.py +1 -0
- tools/dnspython/adapter.py +302 -0
- tools/dnspython/cli.py +202 -0
- tools/dnspython/manifest.toml +138 -0
- tools/ffuf/__init__.py +1 -0
- tools/ffuf/adapter.py +183 -0
- tools/ffuf/manifest.toml +121 -0
- tools/gobuster/__init__.py +0 -0
- tools/gobuster/adapter.py +90 -0
- tools/gobuster/manifest.toml +104 -0
- tools/http_probe/adapter.py +256 -0
- tools/http_probe/manifest.toml +40 -0
- tools/netexec/__init__.py +1 -0
- tools/netexec/adapter.py +163 -0
- tools/netexec/manifest.toml +83 -0
- tools/nikto/__init__.py +0 -0
- tools/nikto/adapter.py +145 -0
- tools/nikto/manifest.toml +108 -0
- tools/nmap/__init__.py +0 -0
- tools/nmap/adapter.py +97 -0
- tools/nmap/manifest.toml +159 -0
- tools/nuclei/__init__.py +1 -0
- tools/nuclei/adapter.py +171 -0
- tools/nuclei/manifest.toml +117 -0
- tools/searchsploit/__init__.py +1 -0
- tools/searchsploit/adapter.py +139 -0
- tools/searchsploit/manifest.toml +103 -0
- tools/sqlmap/__init__.py +1 -0
- tools/sqlmap/adapter.py +214 -0
- tools/sqlmap/manifest.toml +89 -0
- tools/subfinder/__init__.py +0 -0
- tools/subfinder/adapter.py +71 -0
- tools/subfinder/manifest.toml +104 -0
- tools/whois/__init__.py +0 -0
- tools/whois/adapter.py +80 -0
- tools/whois/manifest.toml +95 -0
|
@@ -0,0 +1,802 @@
|
|
|
1
|
+
"""Pre-flight dependency, asset, capability, and parameter verification for Ether."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import shutil
|
|
8
|
+
import urllib.parse
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from typing import Any, List, Literal, Optional, Set, Tuple
|
|
11
|
+
|
|
12
|
+
from ether import paths
|
|
13
|
+
from ether.gateway.gate import GatePolicy, is_blocked_destination
|
|
14
|
+
from ether.registry.wordlists import (
|
|
15
|
+
DEFAULT_WORDLIST_NAME,
|
|
16
|
+
WORDLIST_MACRO_REGEX,
|
|
17
|
+
seed_bundled_wordlists,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
WORDLIST_FLAG_REGEX = re.compile(
|
|
21
|
+
r"(?:^|\s)(?:-w|--wordlist)(?:=|\s+)(\S+)",
|
|
22
|
+
re.IGNORECASE,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
INSTALLATION_HINTS: dict[str, str] = {
|
|
26
|
+
"nmap": "sudo apt install nmap (or: brew install nmap)",
|
|
27
|
+
"gobuster": "sudo apt install gobuster (or: go install github.com/OJ/gobuster/v3@v3.6.0)",
|
|
28
|
+
"nikto": "sudo apt install nikto (or: brew install nikto)",
|
|
29
|
+
"subfinder": "go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@v2.6.6",
|
|
30
|
+
"whois": "sudo apt install whois (or: brew install whois)",
|
|
31
|
+
"dnspython": "pip install dnspython",
|
|
32
|
+
"ffuf": "go install github.com/ffuf/ffuf/v2@latest (or: sudo apt install ffuf)",
|
|
33
|
+
"nuclei": "go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest",
|
|
34
|
+
"sqlmap": "sudo apt install sqlmap (or: pip install sqlmap)",
|
|
35
|
+
"netexec": "pipx install netexec (or: pip install netexec)",
|
|
36
|
+
"searchsploit": "sudo apt install exploitdb (or: git clone https://gitlab.com/exploit-database/exploitdb.git)",
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
WEB_TOOLS: Set[str] = {"gobuster", "ffuf", "nikto", "nuclei", "sqlmap"}
|
|
40
|
+
NETWORK_TOOLS: Set[str] = {"nmap", "netexec", "nxc"}
|
|
41
|
+
DOMAIN_TOOLS: Set[str] = {"subfinder", "whois", "dnspython"}
|
|
42
|
+
WORDLIST_TOOLS: Set[str] = {"gobuster", "ffuf"}
|
|
43
|
+
|
|
44
|
+
DEFAULT_TOOL_TARGETS: dict[str, str] = {
|
|
45
|
+
"nmap": "127.0.0.1",
|
|
46
|
+
"netexec": "127.0.0.1",
|
|
47
|
+
"gobuster": "http://scanme.nmap.org",
|
|
48
|
+
"nikto": "http://scanme.nmap.org",
|
|
49
|
+
"ffuf": "http://scanme.nmap.org",
|
|
50
|
+
"nuclei": "http://scanme.nmap.org",
|
|
51
|
+
"sqlmap": "http://testphp.vulnweb.com/listproducts.php?cat=1",
|
|
52
|
+
"subfinder": "example.com",
|
|
53
|
+
"whois": "example.com",
|
|
54
|
+
"dnspython": "example.com",
|
|
55
|
+
"searchsploit": "Apache 2.4.49",
|
|
56
|
+
"http_probe": "http://scanme.nmap.org",
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
TOOL_TARGET_GUIDANCE: dict[str, dict[str, Any]] = {
|
|
60
|
+
"nmap": {
|
|
61
|
+
"expected_format": "IPv4 (127.0.0.1), IPv6 (::1), CIDR (192.168.1.0/24), IP Range (10.0.0.1-50), or Hostname (scanme.nmap.org)",
|
|
62
|
+
"safe_sandbox": "127.0.0.1 (local loopback) or scanme.nmap.org (Nmap authorized test server)",
|
|
63
|
+
"permissible": [
|
|
64
|
+
"Local loopback (127.0.0.1, localhost) for inspecting locally listening daemons and ports.",
|
|
65
|
+
"Official Nmap project sandbox (scanme.nmap.org) for testing version and script scans.",
|
|
66
|
+
"Private lab subnets (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) and container bridge networks with explicit authorization.",
|
|
67
|
+
],
|
|
68
|
+
"prohibited": [
|
|
69
|
+
"Cloud metadata endpoints (169.254.169.254, 169.254.169.250, fd00:ec2::254) — potential SSRF vulnerability.",
|
|
70
|
+
"Third-party production infrastructure, government, banking, healthcare, or military IP ranges without written Rules of Engagement (RoE).",
|
|
71
|
+
"Broadcast or multicast addresses (e.g. 255.255.255.255, 224.0.0.1) which can cause network amplification storms.",
|
|
72
|
+
],
|
|
73
|
+
"precautions": [
|
|
74
|
+
"Aggressive timing templates (-T4, -T5) and full port sweeps (-p-) can saturate network firewalls, exhaust state tables, or crash fragile legacy embedded hardware.",
|
|
75
|
+
"SYN half-open scans (-sS) require raw socket capabilities (root/sudo privileges).",
|
|
76
|
+
"UDP scanning (-sU) is subject to OS-level ICMP rate limits (RFC 1812); expect scans to run significantly slower.",
|
|
77
|
+
],
|
|
78
|
+
"general_knowledge": "Nmap interrogates the target's TCP/IP stack implementation using raw socket probes. It distinguishes open, closed, and filtered states via SYN-ACK, RST, or ICMP unreachable responses. Service versioning (-sV) probes matching service banners against nmap-service-probes.",
|
|
79
|
+
},
|
|
80
|
+
"netexec": {
|
|
81
|
+
"expected_format": "Target IPv4 (127.0.0.1), CIDR subnet (192.168.1.0/24), or NetBIOS/FQDN hostname (dc01.corp.local)",
|
|
82
|
+
"safe_sandbox": "127.0.0.1 (local Samba/SSH services) or dedicated Active Directory lab ranges (e.g., GOAD, HackTheBox)",
|
|
83
|
+
"permissible": [
|
|
84
|
+
"Local machine (127.0.0.1) for testing null sessions or guest share enumerations against local SMB daemons.",
|
|
85
|
+
"Isolated Active Directory lab environments configured specifically for pentesting education.",
|
|
86
|
+
"Authorized enterprise client subnets during approved engagement windows.",
|
|
87
|
+
],
|
|
88
|
+
"prohibited": [
|
|
89
|
+
"Production Active Directory Domain Controllers during business hours without explicit change approval.",
|
|
90
|
+
"Internet-facing public SMB (port 445) endpoints not owned by you.",
|
|
91
|
+
"Cloud metadata endpoints.",
|
|
92
|
+
],
|
|
93
|
+
"precautions": [
|
|
94
|
+
"NetExec can trigger Active Directory account lockouts if password spraying against domains with aggressive lockout policies (badPwdCount thresholds).",
|
|
95
|
+
"SMB credential checks generate event ID 4625 (failed logon) and 4624 (successful logon) on the Domain Controller security event log.",
|
|
96
|
+
"The --rid-brute flag generates sequential RPC queries that can alert SIEM rules detecting credential access.",
|
|
97
|
+
],
|
|
98
|
+
"general_knowledge": "NetExec (formerly CrackMapExec) is a post-exploitation and network reconnaissance tool automating assessment of large Active Directory networks via SMB, WMI, WinRM, LDAP, MSSQL, and SSH protocols.",
|
|
99
|
+
},
|
|
100
|
+
"gobuster": {
|
|
101
|
+
"expected_format": "Complete HTTP or HTTPS URL (http://127.0.0.1:8080, https://scanme.nmap.org)",
|
|
102
|
+
"safe_sandbox": "http://scanme.nmap.org or local containerized test targets (http://127.0.0.1:8080)",
|
|
103
|
+
"permissible": [
|
|
104
|
+
"Local loopback web servers (http://127.0.0.1, http://localhost:8000) for testing wordlist traversal.",
|
|
105
|
+
"Authorized client web applications during penetration tests.",
|
|
106
|
+
"Dedicated CTF or training web targets (DVWA, OWASP Juice Shop).",
|
|
107
|
+
],
|
|
108
|
+
"prohibited": [
|
|
109
|
+
"Third-party websites, production e-commerce platforms, or SaaS portals without explicit scope inclusion.",
|
|
110
|
+
"Cloud metadata URIs (http://169.254.169.254/latest/meta-data/).",
|
|
111
|
+
],
|
|
112
|
+
"precautions": [
|
|
113
|
+
"High concurrency (-t 50+) can overwhelm low-spec web servers, exhausting Apache/Nginx worker pools and causing HTTP 503 Service Unavailable.",
|
|
114
|
+
"Brute-forcing on applications with automatic WAF or anti-bot systems (Cloudflare, AWS WAF) will trigger IP bans.",
|
|
115
|
+
"Be mindful of wordlist size: large wordlists (100k+ paths) generate massive access log files that consume server disk space.",
|
|
116
|
+
],
|
|
117
|
+
"general_knowledge": "Gobuster performs deterministic dictionary traversal by appending wordlist entries to the base URL and inspecting HTTP response status codes (200 OK, 301/302 Redirect, 403 Forbidden). It runs concurrent goroutines for maximum throughput.",
|
|
118
|
+
},
|
|
119
|
+
"nikto": {
|
|
120
|
+
"expected_format": "Hostname (scanme.nmap.org), IP (127.0.0.1), or HTTP/HTTPS URL (http://scanme.nmap.org)",
|
|
121
|
+
"safe_sandbox": "http://scanme.nmap.org or local Apache/Nginx web server instances",
|
|
122
|
+
"permissible": [
|
|
123
|
+
"Local web servers (http://127.0.0.1:8080) to inspect default files, outdated modules, and missing security headers.",
|
|
124
|
+
"Authorized client web applications during penetration tests.",
|
|
125
|
+
"Designated academic or lab targets.",
|
|
126
|
+
],
|
|
127
|
+
"prohibited": [
|
|
128
|
+
"Third-party production websites without written authorization.",
|
|
129
|
+
"Any target where stealth is required: Nikto is completely unstealthy and intentionally issues thousands of noisy exploit requests.",
|
|
130
|
+
"Cloud metadata endpoints (169.254.169.254).",
|
|
131
|
+
],
|
|
132
|
+
"precautions": [
|
|
133
|
+
"Nikto issues over 6,700 known vulnerability checks, dangerous CGI paths, and obsolete file requests. It WILL trigger IDS/IPS and SOC alerts.",
|
|
134
|
+
"Avoid running full scans (-Tuning 2,4,b) against fragile legacy web servers or embedded IoT web interfaces, as old CGIs may cause crashes.",
|
|
135
|
+
"Use -ssl when targeting HTTPS endpoints, and -p to specify custom ports.",
|
|
136
|
+
],
|
|
137
|
+
"general_knowledge": "Nikto is a comprehensive web server misconfiguration scanner. It checks for over 6,700 potentially dangerous files/CGIs, outdated server software, insecure HTTP methods (TRACE, PUT), and missing defense headers (X-Frame-Options, CSP, HSTS).",
|
|
138
|
+
},
|
|
139
|
+
"ffuf": {
|
|
140
|
+
"expected_format": "Complete HTTP/HTTPS URL containing the 'FUZZ' keyword (http://scanme.nmap.org/FUZZ, http://target/?FUZZ=1)",
|
|
141
|
+
"safe_sandbox": "http://scanme.nmap.org/FUZZ or local lab applications (http://127.0.0.1:8000/FUZZ)",
|
|
142
|
+
"permissible": [
|
|
143
|
+
"Local and lab web services for directory fuzzing, virtual host discovery, and parameter enumeration.",
|
|
144
|
+
"Authorized bug bounty targets that permit automated fuzzing within scope.",
|
|
145
|
+
"scanme.nmap.org/FUZZ for syntax and rate testing.",
|
|
146
|
+
],
|
|
147
|
+
"prohibited": [
|
|
148
|
+
"Form endpoints that trigger emails, database writes, or financial transactions (e.g. /contact.php?email=FUZZ, /checkout?item=FUZZ).",
|
|
149
|
+
"Cloud metadata endpoints (http://169.254.169.254).",
|
|
150
|
+
"Out-of-scope third-party websites.",
|
|
151
|
+
],
|
|
152
|
+
"precautions": [
|
|
153
|
+
"ffuf is written in Go and can exceed 2,000+ requests per second. Always enforce rate limits (-rate 30 -p 0.1) on shared infrastructure.",
|
|
154
|
+
"Match and filter flags (-mc, -fc, -fs, -fl) are essential: without proper filtering, wildcard responses will flood your results.",
|
|
155
|
+
"Virtual host fuzzing requires proper Host header syntax (-H 'Host: FUZZ.domain.com') with a clean domain name.",
|
|
156
|
+
],
|
|
157
|
+
"general_knowledge": "ffuf (Fuzz Faster U Fool) replaces the FUZZ keyword in URLs, headers, or request bodies with entries from a wordlist. It analyzes response length, word count, line count, and status code distributions to identify anomalous responses.",
|
|
158
|
+
},
|
|
159
|
+
"nuclei": {
|
|
160
|
+
"expected_format": "Complete HTTP or HTTPS URL (http://scanme.nmap.org, https://example.com) or network host",
|
|
161
|
+
"safe_sandbox": "http://scanme.nmap.org or intentionally vulnerable test applications (Vulnweb, DVWA)",
|
|
162
|
+
"permissible": [
|
|
163
|
+
"Local lab applications, Dockerized targets, and authorized bug bounty scopes.",
|
|
164
|
+
"scanme.nmap.org for benign technology and SSL/TLS fingerprinting.",
|
|
165
|
+
"Production assets when restricted to informational or passive templates (-severity info -tags tech).",
|
|
166
|
+
],
|
|
167
|
+
"prohibited": [
|
|
168
|
+
"Running intrusive exploit templates (-tags rce,sqli,takeover) against production systems without explicit authorization.",
|
|
169
|
+
"Cloud metadata endpoints (169.254.169.254).",
|
|
170
|
+
"Denial of service templates (-tags dos).",
|
|
171
|
+
],
|
|
172
|
+
"precautions": [
|
|
173
|
+
"Nuclei executes YAML-based protocol templates (HTTP, DNS, TCP, SSL). Running full template sets without severity filters sends tens of thousands of requests.",
|
|
174
|
+
"Always specify severity levels (-severity low,medium) during initial recon.",
|
|
175
|
+
"Use -rate-limit to keep requests per second within acceptable thresholds for the target infrastructure.",
|
|
176
|
+
],
|
|
177
|
+
"general_knowledge": "Nuclei uses community-curated YAML templates to send targeted protocol requests and match patterns in responses. It enables fast zero-day detection and automated vulnerability confirmation.",
|
|
178
|
+
},
|
|
179
|
+
"sqlmap": {
|
|
180
|
+
"expected_format": "Target HTTP/HTTPS URL with parameters (http://testphp.vulnweb.com/listproducts.php?cat=1)",
|
|
181
|
+
"safe_sandbox": "http://testphp.vulnweb.com/listproducts.php?cat=1 (Acrobot authorized testbed) or local DVWA/bWAPP targets",
|
|
182
|
+
"permissible": [
|
|
183
|
+
"Authorized penetration test endpoints with confirmed dynamic SQL parameters.",
|
|
184
|
+
"Intentionally vulnerable testbeds (testphp.vulnweb.com, DVWA, WebGoat).",
|
|
185
|
+
"Local applications you developed and have root database access to verify.",
|
|
186
|
+
],
|
|
187
|
+
"prohibited": [
|
|
188
|
+
"Any third-party database without explicit pentest contract authorizing active SQL injection attempts.",
|
|
189
|
+
"Financial, healthcare, or personal identity endpoints where data corruption or leakage is catastrophic.",
|
|
190
|
+
"Cloud metadata URIs.",
|
|
191
|
+
],
|
|
192
|
+
"precautions": [
|
|
193
|
+
"Time-based blind SQLi (WAITFOR DELAY, pg_sleep) locks database threads and can lead to resource starvation.",
|
|
194
|
+
"Do NOT use --os-shell or --sql-shell unless explicitly permitted by your Rules of Engagement.",
|
|
195
|
+
"Be cautious with --risk 3 and --level 5: heavy OR-based injection tests can inadvertently UPDATE or DELETE database rows.",
|
|
196
|
+
],
|
|
197
|
+
"general_knowledge": "sqlmap automates the detection and exploitation of SQL injection flaws. It fingerprints database management systems (DBMS), extracts schema hierarchies, retrieves table data, and can access the underlying operating system file system.",
|
|
198
|
+
},
|
|
199
|
+
"subfinder": {
|
|
200
|
+
"expected_format": "Base root domain name without protocol or path (example.com, nmap.org)",
|
|
201
|
+
"safe_sandbox": "example.com (IANA reserved domain) or your own registered domain assets",
|
|
202
|
+
"permissible": [
|
|
203
|
+
"example.com for testing passive query execution and verifying DNS parsing pipelines.",
|
|
204
|
+
"Client domains explicitly in scope for reconnaissance during authorized pentest engagements.",
|
|
205
|
+
"Bug bounty programs that permit passive subdomain enumeration.",
|
|
206
|
+
],
|
|
207
|
+
"prohibited": [
|
|
208
|
+
"Internal network names (e.g. .local, .internal, .lan) which have no public DNS presence.",
|
|
209
|
+
"URLs with protocols (http://) or paths (/api) — subfinder strictly expects a clean domain name.",
|
|
210
|
+
"IP addresses (subfinder resolves subdomains for domain names, not IP addresses).",
|
|
211
|
+
],
|
|
212
|
+
"precautions": [
|
|
213
|
+
"Subfinder is completely passive: it queries public data sources (Search engines, Certificate Transparency logs, VirusTotal, Censys) and never sends packets to the target domain directly.",
|
|
214
|
+
"Respect public API rate limits: configure provider API keys in subfinder configuration to avoid IP throttling.",
|
|
215
|
+
"Subdomains discovered may point to decommissioned servers (potential Subdomain Takeover vulnerability).",
|
|
216
|
+
],
|
|
217
|
+
"general_knowledge": "Subfinder discovers valid subdomains for websites by using passive online sources. It operates silently without generating IDS/IPS alerts on the target's infrastructure, making it ideal for the initial OSINT phase.",
|
|
218
|
+
},
|
|
219
|
+
"whois": {
|
|
220
|
+
"expected_format": "Domain name (example.com), Autonomous System Number (AS15169), or IP address (93.184.216.34)",
|
|
221
|
+
"safe_sandbox": "example.com (IANA test domain) or public IP addresses (e.g. 8.8.8.8)",
|
|
222
|
+
"permissible": [
|
|
223
|
+
"example.com for verifying registrar and ownership data structures.",
|
|
224
|
+
"Any public domain, IP address, or ASN within standard registry lookup terms.",
|
|
225
|
+
"Client domains and allocated netblocks during initial reconnaissance.",
|
|
226
|
+
],
|
|
227
|
+
"prohibited": [
|
|
228
|
+
"High-frequency automated scraping loops that violate Regional Internet Registry (RIR) acceptable use policies.",
|
|
229
|
+
"Internal private IP addresses (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12) which yield no public registry data.",
|
|
230
|
+
],
|
|
231
|
+
"precautions": [
|
|
232
|
+
"WHOIS servers (TCP port 43) strictly enforce IP rate limits. Exceeding query thresholds will result in temporary or permanent IP bans.",
|
|
233
|
+
"Modern GDPR and ICANN privacy redaction policies frequently mask personal registrant names and emails behind privacy proxies.",
|
|
234
|
+
"Use -h to query specific regional registries directly (e.g., whois.arin.net, whois.ripe.net).",
|
|
235
|
+
],
|
|
236
|
+
"general_knowledge": "The WHOIS protocol (RFC 3912) queries distributed databases maintained by TLD registries, registrars, and Regional Internet Registries (ARIN, RIPE NCC, APNIC, LACNIC, AFRINIC) to determine domain registration, nameservers, and IP allocations.",
|
|
237
|
+
},
|
|
238
|
+
"dnspython": {
|
|
239
|
+
"expected_format": "Domain name (example.com) or IPv4 address for reverse pointer lookups (e.g. 93.184.216.34)",
|
|
240
|
+
"safe_sandbox": "example.com (RFC 2606 safe domain) or local DNS test environments (BIND9, CoreDNS)",
|
|
241
|
+
"permissible": [
|
|
242
|
+
"example.com for querying A, AAAA, MX, NS, TXT, and SOA records.",
|
|
243
|
+
"Your authorized target domains for DNS configuration auditing and mail routing inspection.",
|
|
244
|
+
"Local or lab DNS servers for testing Zone Transfers (AXFR).",
|
|
245
|
+
],
|
|
246
|
+
"prohibited": [
|
|
247
|
+
"Unauthorized Zone Transfer (AXFR) attempts against production third-party nameservers.",
|
|
248
|
+
"DNS amplification or flooding attacks against public recursive resolvers (8.8.8.8, 1.1.1.1).",
|
|
249
|
+
"Cloud metadata endpoints.",
|
|
250
|
+
],
|
|
251
|
+
"precautions": [
|
|
252
|
+
"Zone Transfers (AXFR) will be logged on authoritative nameservers. An open zone transfer is a high-severity finding that leaks entire internal network namespaces.",
|
|
253
|
+
"When auditing email anti-spoofing (SPF, DMARC), verify that TXT records are syntactically valid and enforce reject policies (p=reject).",
|
|
254
|
+
"Be aware of DNS caching: queries might return cached intermediate results from your upstream resolver rather than authoritative values.",
|
|
255
|
+
],
|
|
256
|
+
"general_knowledge": "dnspython is a pure-Python DNS toolkit. It constructs standard RFC 1035 UDP/TCP wire packets to interrogate nameservers directly. It verifies record types (A, MX, NS, TXT, PTR) and evaluates defensive controls like DNSSEC and zone transfer ACLs.",
|
|
257
|
+
},
|
|
258
|
+
"searchsploit": {
|
|
259
|
+
"expected_format": "Software name and version string (Apache 2.4.49, OpenSSH 7.2p2) or CVE ID (2021-41773). Do NOT use URLs or IPs.",
|
|
260
|
+
"safe_sandbox": "Apache 2.4.49 (famous CVE-2021-41773 RCE), ProFTPD 1.3.5, vsftpd 2.3.4",
|
|
261
|
+
"permissible": [
|
|
262
|
+
"Searching for known public exploits, PoC scripts, and papers from the local Exploit-DB archive.",
|
|
263
|
+
"Filtering by title, CVE identifier, platform (Linux/Windows), or remote exploit type.",
|
|
264
|
+
"Offline query analysis with zero network footprint.",
|
|
265
|
+
],
|
|
266
|
+
"prohibited": [
|
|
267
|
+
"NEVER compile or execute downloaded public exploit code against live systems without auditing the source code in an isolated VM sandbox first!",
|
|
268
|
+
"Do not enter raw IP addresses or URLs as search terms; searchsploit searches text descriptions and version metadata.",
|
|
269
|
+
],
|
|
270
|
+
"precautions": [
|
|
271
|
+
"Public exploits on Exploit-DB often require modification (offsets, shellcode, return addresses) to function on specific target builds.",
|
|
272
|
+
"Malicious actors sometimes upload backdoored exploit scripts to public databases. Always perform code review before running third-party exploit code.",
|
|
273
|
+
"Keep the local exploit database updated using searchsploit -u.",
|
|
274
|
+
],
|
|
275
|
+
"general_knowledge": "searchsploit is a command-line search tool for Exploit-DB that operates entirely offline. It matches search terms against an offline index (files_exploits.csv) to discover proof-of-concept exploits, shellcodes, and security papers.",
|
|
276
|
+
},
|
|
277
|
+
"http_probe": {
|
|
278
|
+
"expected_format": "Complete HTTP or HTTPS URL (http://scanme.nmap.org, https://example.com)",
|
|
279
|
+
"safe_sandbox": "http://scanme.nmap.org or https://example.com",
|
|
280
|
+
"permissible": [
|
|
281
|
+
"Local or remote authorized web endpoints for service and title discovery.",
|
|
282
|
+
"scanme.nmap.org or example.com for syntax and response verification.",
|
|
283
|
+
"Authorized client web assets during penetration testing.",
|
|
284
|
+
],
|
|
285
|
+
"prohibited": [
|
|
286
|
+
"Cloud metadata URIs (http://169.254.169.254/latest/meta-data/).",
|
|
287
|
+
"Loopback interfaces under GatePolicy.SAFE without explicit authorization.",
|
|
288
|
+
"Unauthorized external systems.",
|
|
289
|
+
],
|
|
290
|
+
"precautions": [
|
|
291
|
+
"High concurrency can trigger rate limits or WAF blocks.",
|
|
292
|
+
"SSRF pre-connect checks strictly abort attempts against link-local or metadata addresses.",
|
|
293
|
+
],
|
|
294
|
+
"general_knowledge": "http_probe is a high-performance in-process HTTP discovery adapter extracting response codes, server banners, page titles, and web technologies.",
|
|
295
|
+
},
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def get_tool_target_guidance(tool_name: str) -> str:
|
|
300
|
+
"""Return formatted Markdown target guidance for a specified security tool."""
|
|
301
|
+
guidance = TOOL_TARGET_GUIDANCE.get(tool_name.lower())
|
|
302
|
+
if not guidance:
|
|
303
|
+
return f"# Target Guidance: {tool_name}\n\n*General Security Target:* Provide an authorized IP, hostname, or URL."
|
|
304
|
+
|
|
305
|
+
perm_bullets = "\n".join(f"- {p}" for p in guidance["permissible"])
|
|
306
|
+
proh_bullets = "\n".join(f"- {p}" for p in guidance["prohibited"])
|
|
307
|
+
prec_bullets = "\n".join(f"- {p}" for p in guidance["precautions"])
|
|
308
|
+
|
|
309
|
+
return (
|
|
310
|
+
f"# Target Scope & Safety Guidance: {tool_name.upper()}\n\n"
|
|
311
|
+
f"**Expected Format:** `{guidance['expected_format']}`\n\n"
|
|
312
|
+
f"**Safe Sandbox Target:** `{guidance['safe_sandbox']}`\n\n"
|
|
313
|
+
f"## Permissible & Effective Targets\n{perm_bullets}\n\n"
|
|
314
|
+
f"## Strictly Prohibited & Dangerous Targets\n{proh_bullets}\n\n"
|
|
315
|
+
f"## Operational Precautions & Ethics\n{prec_bullets}\n\n"
|
|
316
|
+
f"## Protocol Mechanics & Behavior\n{guidance['general_knowledge']}\n"
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
@dataclass
|
|
321
|
+
class PreflightIssue:
|
|
322
|
+
"""An individual issue or recommendation identified during preflight checks."""
|
|
323
|
+
|
|
324
|
+
category: Literal["binary", "wordlist", "target", "security"]
|
|
325
|
+
severity: Literal["error", "warning", "info"]
|
|
326
|
+
title: str
|
|
327
|
+
description: str
|
|
328
|
+
remediation_hint: str
|
|
329
|
+
can_auto_remedy: bool = False
|
|
330
|
+
remedy_label: Optional[str] = None
|
|
331
|
+
remedy_action: Optional[str] = None
|
|
332
|
+
remedy_payload: Optional[str] = None
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
@dataclass
|
|
336
|
+
class PreflightReport:
|
|
337
|
+
"""Consolidated outcome of preflight verification for a proposed command."""
|
|
338
|
+
|
|
339
|
+
tool_name: str
|
|
340
|
+
target: str
|
|
341
|
+
flags: str
|
|
342
|
+
issues: List[PreflightIssue] = field(default_factory=list)
|
|
343
|
+
|
|
344
|
+
@property
|
|
345
|
+
def is_valid(self) -> bool:
|
|
346
|
+
"""True if there are zero blocking errors."""
|
|
347
|
+
return not any(i.severity == "error" for i in self.issues)
|
|
348
|
+
|
|
349
|
+
@property
|
|
350
|
+
def has_warnings(self) -> bool:
|
|
351
|
+
"""True if there are non-blocking warnings."""
|
|
352
|
+
return any(i.severity == "warning" for i in self.issues)
|
|
353
|
+
|
|
354
|
+
@property
|
|
355
|
+
def errors(self) -> List[PreflightIssue]:
|
|
356
|
+
return [i for i in self.issues if i.severity == "error"]
|
|
357
|
+
|
|
358
|
+
@property
|
|
359
|
+
def warnings(self) -> List[PreflightIssue]:
|
|
360
|
+
return [i for i in self.issues if i.severity == "warning"]
|
|
361
|
+
|
|
362
|
+
@property
|
|
363
|
+
def remediable_issues(self) -> List[PreflightIssue]:
|
|
364
|
+
return [i for i in self.issues if i.can_auto_remedy]
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
class PreflightVerifier:
|
|
368
|
+
"""Deep module verifying tool dependencies, wordlist assets, target parameters,
|
|
369
|
+
|
|
370
|
+
and security boundaries prior to subprocess dispatch.
|
|
371
|
+
"""
|
|
372
|
+
|
|
373
|
+
def __init__(
|
|
374
|
+
self,
|
|
375
|
+
registry: Optional[Any] = None,
|
|
376
|
+
wordlists_dir: Optional[str] = None,
|
|
377
|
+
policy: GatePolicy = GatePolicy.SAFE,
|
|
378
|
+
):
|
|
379
|
+
self.registry = registry
|
|
380
|
+
self.wordlists_dir = wordlists_dir
|
|
381
|
+
self.policy = policy
|
|
382
|
+
|
|
383
|
+
def verify(
|
|
384
|
+
self,
|
|
385
|
+
tool_name: str,
|
|
386
|
+
target: str,
|
|
387
|
+
flags: str = "",
|
|
388
|
+
recipe_idx: Optional[int] = None,
|
|
389
|
+
) -> PreflightReport:
|
|
390
|
+
"""Run comprehensive preflight verification and return a structured report."""
|
|
391
|
+
clean_tool = (tool_name or "").strip().lower()
|
|
392
|
+
clean_target = (target or "").strip()
|
|
393
|
+
clean_flags = (flags or "").strip()
|
|
394
|
+
|
|
395
|
+
report = PreflightReport(
|
|
396
|
+
tool_name=clean_tool,
|
|
397
|
+
target=clean_target,
|
|
398
|
+
flags=clean_flags,
|
|
399
|
+
issues=[],
|
|
400
|
+
)
|
|
401
|
+
|
|
402
|
+
if not clean_tool:
|
|
403
|
+
report.issues.append(
|
|
404
|
+
PreflightIssue(
|
|
405
|
+
category="binary",
|
|
406
|
+
severity="error",
|
|
407
|
+
title="No security tool selected",
|
|
408
|
+
description="An active security tool must be selected before executing scans.",
|
|
409
|
+
remediation_hint="Select a tool from the catalog or registry.",
|
|
410
|
+
)
|
|
411
|
+
)
|
|
412
|
+
return report
|
|
413
|
+
|
|
414
|
+
# 1. Binary Availability Check
|
|
415
|
+
self._check_binary(clean_tool, report)
|
|
416
|
+
|
|
417
|
+
# 2. Security Gating (Sudo & SSRF)
|
|
418
|
+
self._check_security(clean_tool, clean_target, clean_flags, report)
|
|
419
|
+
|
|
420
|
+
# 3. Target Variable & Scheme Validation
|
|
421
|
+
self._check_target(clean_tool, clean_target, report)
|
|
422
|
+
|
|
423
|
+
# 4. Wordlist Assets Validation
|
|
424
|
+
self._check_wordlists(clean_tool, clean_flags, report)
|
|
425
|
+
|
|
426
|
+
return report
|
|
427
|
+
|
|
428
|
+
@staticmethod
|
|
429
|
+
def quick_check(
|
|
430
|
+
tool_name: str,
|
|
431
|
+
target: str,
|
|
432
|
+
flags: str = "",
|
|
433
|
+
policy: GatePolicy = GatePolicy.SAFE,
|
|
434
|
+
) -> Optional[str]:
|
|
435
|
+
"""Perform a fast, non-blocking check returning a single concise warning string if any issue exists."""
|
|
436
|
+
clean_target = (target or "").strip()
|
|
437
|
+
clean_flags = (flags or "").strip()
|
|
438
|
+
clean_tool = (tool_name or "").strip().lower()
|
|
439
|
+
|
|
440
|
+
if policy == GatePolicy.SAFE:
|
|
441
|
+
if re.search(r"\bsudo\b", clean_flags) or re.search(r"\bsudo\b", clean_target):
|
|
442
|
+
return "[!] Sudo execution is prohibited under Safe GatePolicy."
|
|
443
|
+
|
|
444
|
+
if clean_target and is_blocked_destination(clean_target):
|
|
445
|
+
return "[!] Target is blocked by cloud metadata policy."
|
|
446
|
+
|
|
447
|
+
if not clean_target:
|
|
448
|
+
return "[!] Target address or host is required."
|
|
449
|
+
|
|
450
|
+
if any(var in clean_target for var in ("$TARGET", "{target}", "{url}", "$PORT")):
|
|
451
|
+
return "[!] Target contains unexpanded variable placeholder."
|
|
452
|
+
|
|
453
|
+
if clean_tool in WEB_TOOLS:
|
|
454
|
+
if not clean_target.startswith("http://") and not clean_target.startswith("https://"):
|
|
455
|
+
return f"[!] Web tool '{clean_tool}' expects 'http://' or 'https://' prefix."
|
|
456
|
+
|
|
457
|
+
if clean_tool in NETWORK_TOOLS:
|
|
458
|
+
if clean_target.startswith("http://") or clean_target.startswith("https://"):
|
|
459
|
+
return f"[!] Network tool '{clean_tool}' expects bare IP or hostname, not URL."
|
|
460
|
+
|
|
461
|
+
return None
|
|
462
|
+
|
|
463
|
+
def apply_remedy(
|
|
464
|
+
self,
|
|
465
|
+
issue: PreflightIssue,
|
|
466
|
+
target: str,
|
|
467
|
+
flags: str = "",
|
|
468
|
+
) -> Tuple[str, str, Optional[str]]:
|
|
469
|
+
"""Apply an automated one-click remediation to an identified preflight issue.
|
|
470
|
+
|
|
471
|
+
Returns:
|
|
472
|
+
Tuple of (updated_target, updated_flags, feedback_message)
|
|
473
|
+
"""
|
|
474
|
+
action = issue.remedy_action
|
|
475
|
+
payload = issue.remedy_payload
|
|
476
|
+
|
|
477
|
+
if action == "seed_wordlists":
|
|
478
|
+
dest_dir = self.wordlists_dir or paths.get_default_wordlists_dir()
|
|
479
|
+
extracted = seed_bundled_wordlists(dest_dir)
|
|
480
|
+
msg = f"Extracted {len(extracted)} starter wordlists to {dest_dir}."
|
|
481
|
+
return target, flags, msg
|
|
482
|
+
|
|
483
|
+
elif action == "fix_target_scheme":
|
|
484
|
+
new_target = payload if payload else f"http://{target.strip()}"
|
|
485
|
+
return new_target, flags, f"Updated target to: {new_target}"
|
|
486
|
+
|
|
487
|
+
elif action == "strip_url_scheme":
|
|
488
|
+
new_target = payload if payload else self._extract_clean_hostname(target)
|
|
489
|
+
return new_target, flags, f"Stripped URL scheme: {new_target}"
|
|
490
|
+
|
|
491
|
+
elif action == "set_default_target":
|
|
492
|
+
new_target = payload or "127.0.0.1"
|
|
493
|
+
return new_target, flags, f"Set target to test address: {new_target}"
|
|
494
|
+
|
|
495
|
+
elif action == "remove_sudo":
|
|
496
|
+
new_flags = re.sub(r"\bsudo\s*", "", flags).strip()
|
|
497
|
+
return target, new_flags, "Removed 'sudo' from command parameters."
|
|
498
|
+
|
|
499
|
+
elif action == "copy_install_command":
|
|
500
|
+
return target, flags, payload or issue.remediation_hint
|
|
501
|
+
|
|
502
|
+
return target, flags, None
|
|
503
|
+
|
|
504
|
+
# --- Internal Verification Rules ---
|
|
505
|
+
|
|
506
|
+
def _check_binary(self, tool_name: str, report: PreflightReport) -> None:
|
|
507
|
+
"""Verify that the tool's binary or coroutine dependency is installed and discoverable."""
|
|
508
|
+
adapter = None
|
|
509
|
+
manifest = None
|
|
510
|
+
if self.registry:
|
|
511
|
+
tool_data = self.registry.get_tool(tool_name)
|
|
512
|
+
if tool_data:
|
|
513
|
+
adapter = tool_data.get("adapter")
|
|
514
|
+
manifest = tool_data.get("manifest")
|
|
515
|
+
|
|
516
|
+
# Check for native coroutine tier
|
|
517
|
+
is_coroutine = (
|
|
518
|
+
manifest
|
|
519
|
+
and getattr(getattr(manifest, "meta", None), "execution_tier", None) == "coroutine"
|
|
520
|
+
) or (adapter and getattr(adapter, "execution_tier", None) == "coroutine")
|
|
521
|
+
|
|
522
|
+
if is_coroutine or tool_name in ("dnspython", "http_probe"):
|
|
523
|
+
if adapter and hasattr(adapter, "validate_install"):
|
|
524
|
+
try:
|
|
525
|
+
if not adapter.validate_install():
|
|
526
|
+
report.issues.append(
|
|
527
|
+
PreflightIssue(
|
|
528
|
+
category="binary",
|
|
529
|
+
severity="error",
|
|
530
|
+
title=f"Tool dependency for '{tool_name}' is not installed",
|
|
531
|
+
description=f"Required Python libraries for '{tool_name}' are not importable.",
|
|
532
|
+
remediation_hint=INSTALLATION_HINTS.get(
|
|
533
|
+
tool_name, f"pip install {tool_name}"
|
|
534
|
+
),
|
|
535
|
+
)
|
|
536
|
+
)
|
|
537
|
+
except Exception:
|
|
538
|
+
pass
|
|
539
|
+
return
|
|
540
|
+
|
|
541
|
+
is_installed = False
|
|
542
|
+
binary_name = tool_name
|
|
543
|
+
if manifest and hasattr(manifest, "meta") and getattr(manifest.meta, "binary", None):
|
|
544
|
+
binary_name = manifest.meta.binary
|
|
545
|
+
elif adapter and hasattr(adapter, "binary"):
|
|
546
|
+
binary_name = adapter.binary
|
|
547
|
+
|
|
548
|
+
if adapter and hasattr(adapter, "validate_install"):
|
|
549
|
+
try:
|
|
550
|
+
is_installed = bool(adapter.validate_install())
|
|
551
|
+
except Exception:
|
|
552
|
+
is_installed = False
|
|
553
|
+
else:
|
|
554
|
+
is_installed = bool(shutil.which(binary_name))
|
|
555
|
+
|
|
556
|
+
if not is_installed:
|
|
557
|
+
hint = (
|
|
558
|
+
INSTALLATION_HINTS.get(tool_name)
|
|
559
|
+
or INSTALLATION_HINTS.get(binary_name)
|
|
560
|
+
or f"sudo apt install {binary_name}"
|
|
561
|
+
)
|
|
562
|
+
report.issues.append(
|
|
563
|
+
PreflightIssue(
|
|
564
|
+
category="binary",
|
|
565
|
+
severity="error",
|
|
566
|
+
title=f"Tool binary '{binary_name}' is not installed",
|
|
567
|
+
description=f"The executable '{binary_name}' was not found in system PATH.",
|
|
568
|
+
remediation_hint=hint,
|
|
569
|
+
can_auto_remedy=True,
|
|
570
|
+
remedy_label="Copy Install Command",
|
|
571
|
+
remedy_action="copy_install_command",
|
|
572
|
+
remedy_payload=hint,
|
|
573
|
+
)
|
|
574
|
+
)
|
|
575
|
+
|
|
576
|
+
def _check_security(
|
|
577
|
+
self,
|
|
578
|
+
tool_name: str,
|
|
579
|
+
target: str,
|
|
580
|
+
flags: str,
|
|
581
|
+
report: PreflightReport,
|
|
582
|
+
) -> None:
|
|
583
|
+
"""Enforce sandbox security restrictions (sudo ban, SSRF link-local gating under SAFE policy)."""
|
|
584
|
+
if self.policy == GatePolicy.SAFE:
|
|
585
|
+
# Sudo ban in Safe Policy
|
|
586
|
+
if re.search(r"\bsudo\b", flags) or re.search(r"\bsudo\b", target):
|
|
587
|
+
report.issues.append(
|
|
588
|
+
PreflightIssue(
|
|
589
|
+
category="security",
|
|
590
|
+
severity="error",
|
|
591
|
+
title="Privilege escalation ('sudo') is prohibited",
|
|
592
|
+
description="Commands cannot be executed with elevated root privileges under Safe GatePolicy.",
|
|
593
|
+
remediation_hint="Remove 'sudo' from command parameters.",
|
|
594
|
+
can_auto_remedy=True,
|
|
595
|
+
remedy_label="Remove sudo",
|
|
596
|
+
remedy_action="remove_sudo",
|
|
597
|
+
remedy_payload=re.sub(r"\bsudo\s*", "", flags).strip(),
|
|
598
|
+
)
|
|
599
|
+
)
|
|
600
|
+
|
|
601
|
+
# SSRF Link-Local Metadata Protection
|
|
602
|
+
if target and is_blocked_destination(target):
|
|
603
|
+
report.issues.append(
|
|
604
|
+
PreflightIssue(
|
|
605
|
+
category="security",
|
|
606
|
+
severity="error",
|
|
607
|
+
title=f"Target '{target}' is blocked by security policy",
|
|
608
|
+
description="Target destination matches prohibited cloud provider metadata or link-local subnet.",
|
|
609
|
+
remediation_hint="Choose a valid authorized target or local loopback address (127.0.0.1).",
|
|
610
|
+
can_auto_remedy=True,
|
|
611
|
+
remedy_label="Set 127.0.0.1",
|
|
612
|
+
remedy_action="set_default_target",
|
|
613
|
+
remedy_payload="127.0.0.1",
|
|
614
|
+
)
|
|
615
|
+
)
|
|
616
|
+
|
|
617
|
+
def _check_target(
|
|
618
|
+
self,
|
|
619
|
+
tool_name: str,
|
|
620
|
+
target: str,
|
|
621
|
+
report: PreflightReport,
|
|
622
|
+
) -> None:
|
|
623
|
+
"""Validate target presence, unresolved variable placeholders, and tool scheme alignment."""
|
|
624
|
+
is_web = tool_name in WEB_TOOLS
|
|
625
|
+
default_target = DEFAULT_TOOL_TARGETS.get(
|
|
626
|
+
tool_name, "http://127.0.0.1:8888" if is_web else "127.0.0.1"
|
|
627
|
+
)
|
|
628
|
+
|
|
629
|
+
if not target:
|
|
630
|
+
report.issues.append(
|
|
631
|
+
PreflightIssue(
|
|
632
|
+
category="target",
|
|
633
|
+
severity="error",
|
|
634
|
+
title="Target address or host is missing",
|
|
635
|
+
description="Security tools require an active target IP, domain, or URL to execute.",
|
|
636
|
+
remediation_hint=f"Provide a target or use local sandbox target '{default_target}'.",
|
|
637
|
+
can_auto_remedy=True,
|
|
638
|
+
remedy_label=f"Set '{default_target}'",
|
|
639
|
+
remedy_action="set_default_target",
|
|
640
|
+
remedy_payload=default_target,
|
|
641
|
+
)
|
|
642
|
+
)
|
|
643
|
+
return
|
|
644
|
+
|
|
645
|
+
# Check for unexpanded placeholder variables
|
|
646
|
+
unexpanded = [
|
|
647
|
+
var for var in ("$TARGET", "{target}", "{url}", "$PORT", "{domain}") if var in target
|
|
648
|
+
]
|
|
649
|
+
if unexpanded:
|
|
650
|
+
report.issues.append(
|
|
651
|
+
PreflightIssue(
|
|
652
|
+
category="target",
|
|
653
|
+
severity="error",
|
|
654
|
+
title=f"Unexpanded variable placeholder: '{unexpanded[0]}'",
|
|
655
|
+
description=f"The target contains an unresolved token '{unexpanded[0]}' instead of an actual address.",
|
|
656
|
+
remediation_hint="Replace variable with an actual IP address, domain, or URL.",
|
|
657
|
+
can_auto_remedy=True,
|
|
658
|
+
remedy_label=f"Set '{default_target}'",
|
|
659
|
+
remedy_action="set_default_target",
|
|
660
|
+
remedy_payload=default_target,
|
|
661
|
+
)
|
|
662
|
+
)
|
|
663
|
+
return
|
|
664
|
+
|
|
665
|
+
# Scheme rules for Web tools
|
|
666
|
+
if is_web:
|
|
667
|
+
has_scheme = target.startswith("http://") or target.startswith("https://")
|
|
668
|
+
if not has_scheme:
|
|
669
|
+
fixed_target = f"http://{target}"
|
|
670
|
+
report.issues.append(
|
|
671
|
+
PreflightIssue(
|
|
672
|
+
category="target",
|
|
673
|
+
severity="error",
|
|
674
|
+
title=f"Web tool '{tool_name}' requires an HTTP/HTTPS URL",
|
|
675
|
+
description=f"Target '{target}' is missing the protocol scheme ('http://' or 'https://').",
|
|
676
|
+
remediation_hint=f"Prepend 'http://' to the target URL: '{fixed_target}'.",
|
|
677
|
+
can_auto_remedy=True,
|
|
678
|
+
remedy_label=f"Set '{fixed_target}'",
|
|
679
|
+
remedy_action="fix_target_scheme",
|
|
680
|
+
remedy_payload=fixed_target,
|
|
681
|
+
)
|
|
682
|
+
)
|
|
683
|
+
|
|
684
|
+
# Scheme rules for Network and Domain tools (warnings)
|
|
685
|
+
elif tool_name in NETWORK_TOOLS or tool_name in DOMAIN_TOOLS:
|
|
686
|
+
has_scheme = target.startswith("http://") or target.startswith("https://")
|
|
687
|
+
if has_scheme:
|
|
688
|
+
clean_host = self._extract_clean_hostname(target)
|
|
689
|
+
report.issues.append(
|
|
690
|
+
PreflightIssue(
|
|
691
|
+
category="target",
|
|
692
|
+
severity="warning",
|
|
693
|
+
title=f"Tool '{tool_name}' expects a host or IP, not a URL",
|
|
694
|
+
description=f"Target '{target}' contains a URL scheme and/or path which may cause probe errors.",
|
|
695
|
+
remediation_hint=f"Strip URL scheme and path to use bare hostname '{clean_host}'.",
|
|
696
|
+
can_auto_remedy=True,
|
|
697
|
+
remedy_label=f"Strip to '{clean_host}'",
|
|
698
|
+
remedy_action="strip_url_scheme",
|
|
699
|
+
remedy_payload=clean_host,
|
|
700
|
+
)
|
|
701
|
+
)
|
|
702
|
+
|
|
703
|
+
def _check_wordlists(
|
|
704
|
+
self,
|
|
705
|
+
tool_name: str,
|
|
706
|
+
flags: str,
|
|
707
|
+
report: PreflightReport,
|
|
708
|
+
) -> None:
|
|
709
|
+
"""Inspect command flags for wordlist dependencies and ensure required files exist."""
|
|
710
|
+
dest_dir = self.wordlists_dir or paths.get_default_wordlists_dir()
|
|
711
|
+
dest_path = shutil.os.path.abspath(dest_dir)
|
|
712
|
+
|
|
713
|
+
# 1. Macro Tokens: {wordlist:name} or {wordlist}
|
|
714
|
+
macro_matches = WORDLIST_MACRO_REGEX.findall(flags)
|
|
715
|
+
for named in macro_matches:
|
|
716
|
+
wl_key = named.strip() if named else DEFAULT_WORDLIST_NAME
|
|
717
|
+
if wl_key.endswith(".txt"):
|
|
718
|
+
wl_key = wl_key[:-4]
|
|
719
|
+
|
|
720
|
+
candidate_path = paths.get_wordlist_path(wl_key, data_dir=self.wordlists_dir)
|
|
721
|
+
if not os.path.exists(candidate_path):
|
|
722
|
+
report.issues.append(
|
|
723
|
+
PreflightIssue(
|
|
724
|
+
category="wordlist",
|
|
725
|
+
severity="error",
|
|
726
|
+
title=f"Wordlist '{wl_key}' is not available on disk",
|
|
727
|
+
description=f"The required wordlist asset '{wl_key}.txt' is missing from {dest_dir}.",
|
|
728
|
+
remediation_hint=f"Install bundled starter wordlists into {dest_dir}.",
|
|
729
|
+
can_auto_remedy=True,
|
|
730
|
+
remedy_label="Seed Bundled Wordlists",
|
|
731
|
+
remedy_action="seed_wordlists",
|
|
732
|
+
remedy_payload=wl_key,
|
|
733
|
+
)
|
|
734
|
+
)
|
|
735
|
+
|
|
736
|
+
# 2. CLI flags: -w <path> or --wordlist <path> or -w @<macro>
|
|
737
|
+
is_wordlist_tool = tool_name in WORDLIST_TOOLS or "--wordlist" in flags or "-w" in flags
|
|
738
|
+
if is_wordlist_tool:
|
|
739
|
+
flag_matches = WORDLIST_FLAG_REGEX.findall(flags)
|
|
740
|
+
if not flag_matches and tool_name in WORDLIST_TOOLS and not macro_matches:
|
|
741
|
+
report.issues.append(
|
|
742
|
+
PreflightIssue(
|
|
743
|
+
category="wordlist",
|
|
744
|
+
severity="warning",
|
|
745
|
+
title="No wordlist flag specified for enumeration tool",
|
|
746
|
+
description=f"{tool_name.capitalize()} typically requires a wordlist flag (-w) to perform discovery.",
|
|
747
|
+
remediation_hint=f"Add '-w {{{DEFAULT_WORDLIST_NAME}}}' or specify a wordlist path.",
|
|
748
|
+
can_auto_remedy=False,
|
|
749
|
+
)
|
|
750
|
+
)
|
|
751
|
+
|
|
752
|
+
for raw_path in flag_matches:
|
|
753
|
+
clean_path = raw_path.strip().strip("'\"")
|
|
754
|
+
if clean_path.startswith("-") or ("{" in clean_path and "}" in clean_path):
|
|
755
|
+
continue
|
|
756
|
+
|
|
757
|
+
if clean_path.startswith("@"):
|
|
758
|
+
# Legacy @macro syntax
|
|
759
|
+
wl_name = clean_path[1:]
|
|
760
|
+
if wl_name.endswith(".txt"):
|
|
761
|
+
wl_name = wl_name[:-4]
|
|
762
|
+
candidate = paths.get_wordlist_path(wl_name, data_dir=self.wordlists_dir)
|
|
763
|
+
if not os.path.exists(candidate):
|
|
764
|
+
report.issues.append(
|
|
765
|
+
PreflightIssue(
|
|
766
|
+
category="wordlist",
|
|
767
|
+
severity="warning",
|
|
768
|
+
title=f"Wordlist macro '@{wl_name}' is not yet seeded",
|
|
769
|
+
description=f"The requested wordlist file does not exist at '{candidate}'.",
|
|
770
|
+
remediation_hint="Extract bundled wordlists to initialize local dictionaries.",
|
|
771
|
+
can_auto_remedy=True,
|
|
772
|
+
remedy_label="Extract Wordlists",
|
|
773
|
+
remedy_action="seed_wordlists",
|
|
774
|
+
remedy_payload=wl_name,
|
|
775
|
+
)
|
|
776
|
+
)
|
|
777
|
+
else:
|
|
778
|
+
expanded = os.path.abspath(os.path.expanduser(clean_path))
|
|
779
|
+
if not os.path.isfile(expanded):
|
|
780
|
+
report.issues.append(
|
|
781
|
+
PreflightIssue(
|
|
782
|
+
category="wordlist",
|
|
783
|
+
severity="error",
|
|
784
|
+
title=f"Specified wordlist file not found: '{clean_path}'",
|
|
785
|
+
description=f"Path '{expanded}' does not exist on disk.",
|
|
786
|
+
remediation_hint="Verify the wordlist path or seed bundled starter dictionaries.",
|
|
787
|
+
can_auto_remedy=True,
|
|
788
|
+
remedy_label="Seed Bundled Wordlists",
|
|
789
|
+
remedy_action="seed_wordlists",
|
|
790
|
+
remedy_payload=DEFAULT_WORDLIST_NAME,
|
|
791
|
+
)
|
|
792
|
+
)
|
|
793
|
+
|
|
794
|
+
@staticmethod
|
|
795
|
+
def _extract_clean_hostname(url_or_target: str) -> str:
|
|
796
|
+
"""Extract a clean domain or IP address from a URL or socket target."""
|
|
797
|
+
raw = url_or_target.strip()
|
|
798
|
+
if not raw.startswith("http://") and not raw.startswith("https://"):
|
|
799
|
+
raw = f"http://{raw}"
|
|
800
|
+
parsed = urllib.parse.urlparse(raw)
|
|
801
|
+
host = parsed.hostname or url_or_target
|
|
802
|
+
return host
|