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
tools/nuclei/adapter.py
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"""Nuclei vulnerability scanner adapter."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import shlex
|
|
5
|
+
from typing import Any, AsyncIterator, Dict, List, Optional
|
|
6
|
+
|
|
7
|
+
from ether.registry.adapter import ToolAdapter
|
|
8
|
+
from ether.schemas.base import BaseFinding
|
|
9
|
+
from ether.schemas.vulnerability import AuditMisconfig, VulnerabilityFound
|
|
10
|
+
from ether.schemas.web import WebTechnology
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NucleiAdapter(ToolAdapter):
|
|
14
|
+
"""Adapter for ProjectDiscovery Nuclei vulnerability scanner."""
|
|
15
|
+
|
|
16
|
+
def validate_install(self) -> bool:
|
|
17
|
+
"""Verify nuclei binary is available on system PATH."""
|
|
18
|
+
return self.is_binary_available("nuclei")
|
|
19
|
+
|
|
20
|
+
def sanitize_output(self, raw_stdout: str) -> str:
|
|
21
|
+
"""Filter verbose nuclei loading stats, update notices, and template clusters."""
|
|
22
|
+
lines = []
|
|
23
|
+
for line in raw_stdout.splitlines():
|
|
24
|
+
s = line.strip()
|
|
25
|
+
if any(
|
|
26
|
+
s.startswith(p)
|
|
27
|
+
for p in (
|
|
28
|
+
"[INF] Current nuclei version",
|
|
29
|
+
"[INF] New templates",
|
|
30
|
+
"[INF] Loading templates",
|
|
31
|
+
"[INF] Templates cluster",
|
|
32
|
+
"[INF] Using",
|
|
33
|
+
)
|
|
34
|
+
):
|
|
35
|
+
continue
|
|
36
|
+
lines.append(line)
|
|
37
|
+
return "\n".join(lines)
|
|
38
|
+
|
|
39
|
+
def build_command(self, target: BaseFinding, params: Dict[str, Any]) -> List[str]:
|
|
40
|
+
"""Construct nuclei execution command with streaming JSONL output."""
|
|
41
|
+
url = self.extract_url(target)
|
|
42
|
+
|
|
43
|
+
raw_flags = params.get("raw_flags", "").strip()
|
|
44
|
+
flag_args = shlex.split(raw_flags) if raw_flags else []
|
|
45
|
+
|
|
46
|
+
args = ["nuclei"]
|
|
47
|
+
|
|
48
|
+
has_target = any(
|
|
49
|
+
flag_args[i] in ("-u", "-target", "-list", "-l") for i in range(len(flag_args))
|
|
50
|
+
)
|
|
51
|
+
if not has_target:
|
|
52
|
+
if not url:
|
|
53
|
+
raise ValueError(
|
|
54
|
+
f"Target finding {target.schema_type} does not specify a valid URL or host."
|
|
55
|
+
)
|
|
56
|
+
args.extend(["-u", url])
|
|
57
|
+
|
|
58
|
+
if "-jsonl" not in flag_args and "-j" not in flag_args:
|
|
59
|
+
args.append("-jsonl")
|
|
60
|
+
|
|
61
|
+
# Disable interactive animations and update checks during programmatic execution
|
|
62
|
+
if "-silent" not in flag_args and "-s" not in flag_args:
|
|
63
|
+
args.append("-silent")
|
|
64
|
+
|
|
65
|
+
args.extend(flag_args)
|
|
66
|
+
return args
|
|
67
|
+
|
|
68
|
+
def _extract_url(self, target: BaseFinding) -> Optional[str]:
|
|
69
|
+
return self.extract_url(target)
|
|
70
|
+
|
|
71
|
+
async def parse_output(
|
|
72
|
+
self, raw_stdout: str, target: BaseFinding, context: Dict[str, Any] = None
|
|
73
|
+
) -> AsyncIterator[BaseFinding]:
|
|
74
|
+
"""Parse Nuclei JSONL stream into typed findings."""
|
|
75
|
+
cleaned = raw_stdout.strip()
|
|
76
|
+
if not cleaned:
|
|
77
|
+
return
|
|
78
|
+
|
|
79
|
+
fallback_ip = (
|
|
80
|
+
target.pik.get("host_ip") or target.pik.get("ip") or target.data.get("host_ip")
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
for line in cleaned.splitlines():
|
|
84
|
+
line = line.strip()
|
|
85
|
+
if not line or not line.startswith("{"):
|
|
86
|
+
continue
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
item = json.loads(line)
|
|
90
|
+
except json.JSONDecodeError:
|
|
91
|
+
continue
|
|
92
|
+
|
|
93
|
+
if not isinstance(item, dict):
|
|
94
|
+
continue
|
|
95
|
+
|
|
96
|
+
template_id = str(item.get("template-id", "")).strip()
|
|
97
|
+
info = item.get("info", {})
|
|
98
|
+
if not isinstance(info, dict):
|
|
99
|
+
info = {}
|
|
100
|
+
|
|
101
|
+
name = str(info.get("name") or template_id or "Nuclei Finding").strip()
|
|
102
|
+
severity = str(info.get("severity", "info")).lower().strip()
|
|
103
|
+
tags = [str(t).lower() for t in info.get("tags", [])]
|
|
104
|
+
matched_at = str(item.get("matched-at") or item.get("host") or "").strip()
|
|
105
|
+
host_ip = str(item.get("ip") or fallback_ip or "").strip()
|
|
106
|
+
extracted = item.get("extracted-results", [])
|
|
107
|
+
description = str(info.get("description", "")).strip()
|
|
108
|
+
remediation = str(info.get("remediation", "")).strip()
|
|
109
|
+
|
|
110
|
+
# 1. Technology / Fingerprinting Finding
|
|
111
|
+
if "tech" in tags or "fingerprint" in tags or template_id.startswith("tech-"):
|
|
112
|
+
version = ""
|
|
113
|
+
if extracted and isinstance(extracted, list):
|
|
114
|
+
version = str(extracted[0]).strip()
|
|
115
|
+
yield WebTechnology.create(
|
|
116
|
+
url=matched_at or "http://unknown",
|
|
117
|
+
technology_name=name,
|
|
118
|
+
version=version,
|
|
119
|
+
categories=["server"] if "server" in tags else ["framework"],
|
|
120
|
+
confidence=1.0,
|
|
121
|
+
host_ip=host_ip or None,
|
|
122
|
+
)
|
|
123
|
+
continue
|
|
124
|
+
|
|
125
|
+
# 2. Security Misconfiguration / Sensitive Exposure
|
|
126
|
+
if any(
|
|
127
|
+
t in tags for t in ("misconfig", "exposure", "leak", "config")
|
|
128
|
+
) or template_id.endswith("-exposure"):
|
|
129
|
+
yield AuditMisconfig.create(
|
|
130
|
+
target=matched_at or host_ip or "unknown",
|
|
131
|
+
check_id=template_id,
|
|
132
|
+
title=name,
|
|
133
|
+
severity=severity
|
|
134
|
+
if severity in ("critical", "high", "medium", "low", "info")
|
|
135
|
+
else "medium",
|
|
136
|
+
host_ip=host_ip or None,
|
|
137
|
+
remediation=remediation or None,
|
|
138
|
+
description=description or None,
|
|
139
|
+
)
|
|
140
|
+
continue
|
|
141
|
+
|
|
142
|
+
# 3. Known Vulnerability / CVE
|
|
143
|
+
if severity in ("critical", "high", "medium", "low") or "cve" in tags:
|
|
144
|
+
vuln_id = (
|
|
145
|
+
template_id.upper() if template_id.lower().startswith("cve-") else template_id
|
|
146
|
+
)
|
|
147
|
+
yield VulnerabilityFound.create(
|
|
148
|
+
host_ip=host_ip or "0.0.0.0",
|
|
149
|
+
vuln_id=vuln_id,
|
|
150
|
+
title=name,
|
|
151
|
+
severity=severity
|
|
152
|
+
if severity in ("critical", "high", "medium", "low", "info")
|
|
153
|
+
else "info",
|
|
154
|
+
description=description or None,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
def sanitize_output(self, raw_stdout: str) -> str:
|
|
158
|
+
"""Strip verbose banner and template loading stats from nuclei output."""
|
|
159
|
+
lines = []
|
|
160
|
+
for line in raw_stdout.splitlines():
|
|
161
|
+
s = line.strip()
|
|
162
|
+
if not s:
|
|
163
|
+
continue
|
|
164
|
+
if s.startswith("[INF]") and any(
|
|
165
|
+
k in s for k in ("Templates", "projectdiscovery.io", "Configured", "Using")
|
|
166
|
+
):
|
|
167
|
+
continue
|
|
168
|
+
if any(banner in s for banner in ("__ __", " __ _")):
|
|
169
|
+
continue
|
|
170
|
+
lines.append(line)
|
|
171
|
+
return "\n".join(lines)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
[meta]
|
|
2
|
+
name = "nuclei"
|
|
3
|
+
description = "Fast, customizable vulnerability scanner powered by community-authored YAML templates covering CVEs, misconfigurations, and technology fingerprints."
|
|
4
|
+
one_line_summary = "template-based vulnerability scanner and misconfiguration auditor"
|
|
5
|
+
category = "Vulnerability Assessment"
|
|
6
|
+
categories = ["vulnerability", "scanner", "cve", "dast"]
|
|
7
|
+
binary = "nuclei"
|
|
8
|
+
theory = """
|
|
9
|
+
### Theory & Declarative Vulnerability Verification
|
|
10
|
+
Nuclei verifies vulnerabilities using declarative YAML templates. Rather than brute-force fuzzing, templates model the exact network interaction required to confirm a vulnerability.
|
|
11
|
+
|
|
12
|
+
### Multi-Protocol Architecture & Mechanics
|
|
13
|
+
* **Declarative DSL**: Combines raw request frames, payload substitutions, and extraction variables.
|
|
14
|
+
* **Multi-Protocol Coverage**: Audits HTTP/S, DNS, SSL/TLS, TCP raw sockets, Websockets, and headless browsers.
|
|
15
|
+
* **Cryptographic Matchers**: Requires exact reflection strings, status codes, or hash matches to guarantee zero false positives.
|
|
16
|
+
|
|
17
|
+
### Defensive Remediation & CI/CD
|
|
18
|
+
* **Deterministic Root Cause Patching**: Remediates the root vulnerability pinpointed by template IDs.
|
|
19
|
+
* **DevSecOps Integration**: Embeds Nuclei in CI/CD pipelines to block builds containing known CVEs.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
[modes]
|
|
23
|
+
learning = true
|
|
24
|
+
power = true
|
|
25
|
+
|
|
26
|
+
[input]
|
|
27
|
+
accepts = ["network.host", "web.endpoint", "dns.record"]
|
|
28
|
+
|
|
29
|
+
[output]
|
|
30
|
+
produces = ["vulnerability.found", "audit.misconfig", "web.technology"]
|
|
31
|
+
|
|
32
|
+
[learning]
|
|
33
|
+
enabled = true
|
|
34
|
+
|
|
35
|
+
[[learning.recipes]]
|
|
36
|
+
name = "Critical & High Severity CVE Scan"
|
|
37
|
+
difficulty = "Beginner"
|
|
38
|
+
description = "Scan the target endpoint for known critical and high-severity CVE vulnerabilities using verified templates."
|
|
39
|
+
flags = ["-u", "{url}", "-severity", "critical,high", "-tags", "cve", "-jsonl"]
|
|
40
|
+
|
|
41
|
+
[learning.recipes.theory]
|
|
42
|
+
concept = "Declarative Vulnerability Scanning & Exploit Signature Matching"
|
|
43
|
+
explanation = """
|
|
44
|
+
Nuclei executes declarative YAML templates containing exact HTTP, DNS, SSL, and TCP payloads alongside matchers (status codes, regexes, DSL expressions).
|
|
45
|
+
Filtering for 'critical,high' severity prioritizes remote code execution (RCE), SQL injection, and authentication bypass flaws with CVSS scores above 7.0.
|
|
46
|
+
JSON Lines output allows realtime streaming and continuous correlation into the attack graph.
|
|
47
|
+
"""
|
|
48
|
+
packet_wire_summary = "Client sends specific PoC payloads defined in YAML template -> Analyzes HTTP headers/body for vulnerability signature"
|
|
49
|
+
remediation = "Isolate affected instances, apply vendor patches, and configure web application firewall (WAF) virtual patching rules."
|
|
50
|
+
|
|
51
|
+
[[learning.recipes]]
|
|
52
|
+
name = "Technology Fingerprinting & Asset Profiling"
|
|
53
|
+
difficulty = "Beginner"
|
|
54
|
+
description = "Identify underlying web servers, application frameworks, CMS platforms, and Javascript libraries."
|
|
55
|
+
flags = ["-u", "{url}", "-tags", "tech", "-severity", "info", "-jsonl"]
|
|
56
|
+
|
|
57
|
+
[learning.recipes.theory]
|
|
58
|
+
concept = "HTTP Response Header Fingerprinting & Passive Artifact Recognition"
|
|
59
|
+
explanation = """
|
|
60
|
+
Applications leak identifying indicators across HTTP headers (Server, X-Powered-By, X-AspNet-Version), cookies, favicon hashes, and specific JavaScript script tags.
|
|
61
|
+
Fingerprinting technology versions provides attack surface context and informs targeted vulnerability assessments.
|
|
62
|
+
"""
|
|
63
|
+
packet_wire_summary = "Client GET / -> Server Response Headers + DOM inspected for known framework signatures (React, Nginx, Django, WordPress)"
|
|
64
|
+
remediation = "Suppress identifying server banner headers (e.g. Nginx 'server_tokens off;') and remove default boilerplate pages."
|
|
65
|
+
|
|
66
|
+
[[learning.recipes]]
|
|
67
|
+
name = "Security Misconfigurations & Sensitive Exposure"
|
|
68
|
+
difficulty = "Intermediate"
|
|
69
|
+
description = "Detect exposed internal dashboards, leaked source repositories, unauthenticated APIs, and cloud credential files."
|
|
70
|
+
flags = ["-u", "{url}", "-tags", "misconfig,exposure", "-severity", "medium,high", "-jsonl"]
|
|
71
|
+
|
|
72
|
+
[learning.recipes.theory]
|
|
73
|
+
concept = "OWASP Top 10 A05:2021 Security Misconfiguration & Exposed Sensitive Assets"
|
|
74
|
+
explanation = """
|
|
75
|
+
Security misconfigurations occur when default credentials, open administrative interfaces, debug portals (Spring Boot Actuator, Django Debug), or backup directories are exposed to the public Internet without authentication.
|
|
76
|
+
Nuclei templates verify existence and unauthenticated accessibility of known sensitive paths.
|
|
77
|
+
"""
|
|
78
|
+
packet_wire_summary = "Client GET /actuator/env -> Server returns environment variables containing database passwords and AWS keys"
|
|
79
|
+
remediation = "Enforce least privilege, disable unused endpoints, and restrict administrative portals to internal VPN networks."
|
|
80
|
+
|
|
81
|
+
[[learning.recipes]]
|
|
82
|
+
name = "SSL/TLS Cipher Suite & Certificate Audit"
|
|
83
|
+
difficulty = "Intermediate"
|
|
84
|
+
description = "Evaluate SSL/TLS certificate validity, expiration, deprecated protocols (TLS 1.0/1.1), and weak cipher suites."
|
|
85
|
+
flags = ["-u", "{url}", "-tags", "ssl,tls", "-jsonl"]
|
|
86
|
+
|
|
87
|
+
[learning.recipes.theory]
|
|
88
|
+
concept = "Transport Layer Security (TLS) Cryptographic Negotiation"
|
|
89
|
+
explanation = """
|
|
90
|
+
During the TLS ClientHello and ServerHello handshake, the client and server negotiate cryptographic ciphers, key exchange algorithms, and protocol versions.
|
|
91
|
+
Insecure configurations support broken ciphers (RC4, DES, CBC mode ciphers vulnerable to BEAST/POODLE) or expired X.509 certificates.
|
|
92
|
+
Nuclei probes the TLS termination point to verify compliance with modern cryptographic standards.
|
|
93
|
+
"""
|
|
94
|
+
packet_wire_summary = "Client TLS ClientHello (proposing modern TLS 1.3 ciphers) -> Server ServerHello (Certificate chain & cipher suite verification)"
|
|
95
|
+
remediation = "Enforce TLS 1.2+ with forward secrecy (ECDHE) ciphers and automate certificate renewal using ACME / Let's Encrypt."
|
|
96
|
+
|
|
97
|
+
[[learning.recipes]]
|
|
98
|
+
name = "Rate-Limited Custom Template Sweep"
|
|
99
|
+
difficulty = "Advanced"
|
|
100
|
+
description = "Run a high-coverage vulnerability audit while limiting concurrency to prevent target service degradation."
|
|
101
|
+
flags = ["-u", "{url}", "-c", "25", "-rate-limit", "50", "-jsonl"]
|
|
102
|
+
|
|
103
|
+
[learning.recipes.theory]
|
|
104
|
+
concept = "Concurrency Control, TCP Socket Management & Safe Auditing"
|
|
105
|
+
explanation = """
|
|
106
|
+
Automated scanners can inadvertently cause denial-of-service (DoS) conditions on un-optimized production web servers by opening thousands of concurrent TCP sockets.
|
|
107
|
+
Nuclei's '-c' flag constrains worker threads, while '-rate-limit' regulates requests-per-second, ensuring reliable auditing without exhausting server memory or database connection pools.
|
|
108
|
+
"""
|
|
109
|
+
packet_wire_summary = "Client throttles to 50 req/sec with max 25 worker routines -> Prevents server socket exhaustion"
|
|
110
|
+
remediation = "Schedule extensive vulnerability scans during approved maintenance windows and continuously monitor server metrics."
|
|
111
|
+
|
|
112
|
+
[power]
|
|
113
|
+
enabled = true
|
|
114
|
+
suggests = [
|
|
115
|
+
{ target = "vulnerability.found", condition = "vuln_id != ''", tool = "searchsploit", flags = "--cve {target.pik.vuln_id}" },
|
|
116
|
+
{ target = "web.technology", condition = "name != ''", tool = "searchsploit", flags = "{target.pik.name} {target.data.version}" }
|
|
117
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""SearchSploit tool package."""
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""SearchSploit Exploit-DB tool adapter."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import re
|
|
5
|
+
import shlex
|
|
6
|
+
from typing import Any, AsyncIterator, Dict, List
|
|
7
|
+
|
|
8
|
+
from ether.registry.adapter import ToolAdapter
|
|
9
|
+
from ether.schemas.base import BaseFinding
|
|
10
|
+
from ether.schemas.vulnerability import ExploitReference
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SearchSploitAdapter(ToolAdapter):
|
|
14
|
+
"""Adapter for the searchsploit local exploit query utility."""
|
|
15
|
+
|
|
16
|
+
CVE_PATTERN = re.compile(r"CVE-\d{4}-\d+", re.IGNORECASE)
|
|
17
|
+
|
|
18
|
+
def validate_install(self) -> bool:
|
|
19
|
+
"""Verify searchsploit binary is present in system PATH."""
|
|
20
|
+
return self.is_binary_available("searchsploit")
|
|
21
|
+
|
|
22
|
+
def sanitize_output(self, raw_stdout: str) -> str:
|
|
23
|
+
"""Strip non-JSON diagnostic lines or headers from searchsploit output."""
|
|
24
|
+
cleaned = raw_stdout.strip()
|
|
25
|
+
start = cleaned.find("{")
|
|
26
|
+
end = cleaned.rfind("}")
|
|
27
|
+
if start != -1 and end != -1 and end > start:
|
|
28
|
+
return cleaned[start : end + 1]
|
|
29
|
+
return cleaned
|
|
30
|
+
|
|
31
|
+
def build_command(self, target: BaseFinding, params: Dict[str, Any]) -> List[str]:
|
|
32
|
+
"""Construct the searchsploit command line arguments."""
|
|
33
|
+
args = ["searchsploit", "--json"]
|
|
34
|
+
|
|
35
|
+
raw_flags = params.get("raw_flags", "").strip()
|
|
36
|
+
flag_args = shlex.split(raw_flags) if raw_flags else []
|
|
37
|
+
|
|
38
|
+
# If user explicitly provided flags, incorporate them
|
|
39
|
+
for f in flag_args:
|
|
40
|
+
if f != "--json" and f not in args:
|
|
41
|
+
args.append(f)
|
|
42
|
+
|
|
43
|
+
# Derive target query if not explicitly passed in raw flags
|
|
44
|
+
if not raw_flags or not any(not flag.startswith("-") for flag in flag_args):
|
|
45
|
+
query_parts = self._extract_query_parts(target)
|
|
46
|
+
if not query_parts:
|
|
47
|
+
raise ValueError(
|
|
48
|
+
f"Target finding {target.schema_type} does not contain recognizable service or CVE metadata."
|
|
49
|
+
)
|
|
50
|
+
args.extend(query_parts)
|
|
51
|
+
|
|
52
|
+
return args
|
|
53
|
+
|
|
54
|
+
def _extract_query_parts(self, target: BaseFinding) -> List[str]:
|
|
55
|
+
if target.schema_type == "network.service":
|
|
56
|
+
sname = target.data.get("service_name") or target.pik.get("service_name") or ""
|
|
57
|
+
version = target.data.get("version") or ""
|
|
58
|
+
query = f"{sname} {version}".strip()
|
|
59
|
+
return [query] if query else []
|
|
60
|
+
|
|
61
|
+
if target.schema_type == "vulnerability.found":
|
|
62
|
+
vuln_id = target.pik.get("vuln_id") or target.data.get("vuln_id") or ""
|
|
63
|
+
if vuln_id.upper().startswith("CVE-"):
|
|
64
|
+
return ["--cve", vuln_id]
|
|
65
|
+
return [vuln_id] if vuln_id else []
|
|
66
|
+
|
|
67
|
+
if target.schema_type == "network.host":
|
|
68
|
+
hostname = target.data.get("hostname")
|
|
69
|
+
return [hostname] if hostname else []
|
|
70
|
+
|
|
71
|
+
return []
|
|
72
|
+
|
|
73
|
+
async def parse_output(
|
|
74
|
+
self, raw_stdout: str, target: BaseFinding, context: Dict[str, Any] = None
|
|
75
|
+
) -> AsyncIterator[BaseFinding]:
|
|
76
|
+
"""Parse searchsploit JSON results into ExploitReference finding models."""
|
|
77
|
+
cleaned = raw_stdout.strip()
|
|
78
|
+
if not cleaned:
|
|
79
|
+
return
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
data = json.loads(cleaned)
|
|
83
|
+
except json.JSONDecodeError:
|
|
84
|
+
# Handle possible non-JSON headers before the main JSON payload
|
|
85
|
+
start_bracket = cleaned.find("{")
|
|
86
|
+
end_bracket = cleaned.rfind("}")
|
|
87
|
+
if start_bracket != -1 and end_bracket != -1 and end_bracket > start_bracket:
|
|
88
|
+
try:
|
|
89
|
+
data = json.loads(cleaned[start_bracket : end_bracket + 1])
|
|
90
|
+
except json.JSONDecodeError:
|
|
91
|
+
return
|
|
92
|
+
else:
|
|
93
|
+
return
|
|
94
|
+
|
|
95
|
+
if not isinstance(data, dict):
|
|
96
|
+
return
|
|
97
|
+
|
|
98
|
+
results = data.get("RESULTS_EXPLOIT", [])
|
|
99
|
+
if not isinstance(results, list):
|
|
100
|
+
return
|
|
101
|
+
|
|
102
|
+
# Contextual connection metadata from target
|
|
103
|
+
host_ip = target.pik.get("host_ip") or target.pik.get("ip") or target.data.get("host_ip")
|
|
104
|
+
port = target.pik.get("port") or target.data.get("port")
|
|
105
|
+
vuln_id = target.pik.get("vuln_id") or target.data.get("vuln_id")
|
|
106
|
+
|
|
107
|
+
for item in results:
|
|
108
|
+
if not isinstance(item, dict):
|
|
109
|
+
continue
|
|
110
|
+
|
|
111
|
+
edb_id = str(item.get("EDB-ID", "")).strip()
|
|
112
|
+
title = str(item.get("Title", "")).strip()
|
|
113
|
+
if not edb_id or not title:
|
|
114
|
+
continue
|
|
115
|
+
|
|
116
|
+
exploit_id = f"EDB-{edb_id}"
|
|
117
|
+
platform = item.get("Platform")
|
|
118
|
+
exploit_type = item.get("Type")
|
|
119
|
+
file_path = item.get("Path")
|
|
120
|
+
verified_val = str(item.get("Verified", "0")).strip().lower()
|
|
121
|
+
verified = verified_val in ("1", "true", "yes")
|
|
122
|
+
|
|
123
|
+
# Extract primary CVE code if present in "Codes" field
|
|
124
|
+
codes = str(item.get("Codes", ""))
|
|
125
|
+
cve_match = self.CVE_PATTERN.search(codes)
|
|
126
|
+
cve_id = cve_match.group(0).upper() if cve_match else None
|
|
127
|
+
|
|
128
|
+
yield ExploitReference.create(
|
|
129
|
+
exploit_id=exploit_id,
|
|
130
|
+
title=title,
|
|
131
|
+
cve_id=cve_id,
|
|
132
|
+
platform=platform,
|
|
133
|
+
exploit_type=exploit_type,
|
|
134
|
+
verified=verified,
|
|
135
|
+
file_path=file_path,
|
|
136
|
+
host_ip=host_ip,
|
|
137
|
+
port=port,
|
|
138
|
+
vuln_id=vuln_id,
|
|
139
|
+
)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
[meta]
|
|
2
|
+
name = "searchsploit"
|
|
3
|
+
description = "Command-line search utility for Exploit-DB, enabling offline discovery of verified exploits, PoCs, and CVE references."
|
|
4
|
+
one_line_summary = "offline Exploit-DB and public PoC intelligence lookup"
|
|
5
|
+
category = "Vulnerability Assessment"
|
|
6
|
+
categories = ["exploit", "cve", "recon"]
|
|
7
|
+
binary = "searchsploit"
|
|
8
|
+
theory = """
|
|
9
|
+
### Theory & Vulnerability Lifecycle
|
|
10
|
+
Vulnerability research correlates software version strings identified during reconnaissance against public CVE databases and verified exploit archives.
|
|
11
|
+
|
|
12
|
+
### Exploit Architecture & Classification
|
|
13
|
+
* **Remote (`remote`)**: Weaponized exploits executable over a network socket without valid credentials.
|
|
14
|
+
* **Privilege Escalation (`local`)**: Requires an unprivileged shell to escalate to root or SYSTEM rights.
|
|
15
|
+
* **Web Applications (`webapps`)**: Exploits targeting SQLi, RCE, LFI, and SSRF in web frameworks.
|
|
16
|
+
* **Offline Verification**: Operates fully disconnected from the internet, ideal for air-gapped environments.
|
|
17
|
+
|
|
18
|
+
### Defensive Hardening & Governance
|
|
19
|
+
* **Patch Cadence**: Maintain an aggressive patch schedule for internet-facing daemons.
|
|
20
|
+
* **Principle of Least Privilege**: Isolate daemons in unprivileged accounts with SELinux/AppArmor confinement.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
[modes]
|
|
24
|
+
learning = true
|
|
25
|
+
power = true
|
|
26
|
+
|
|
27
|
+
[input]
|
|
28
|
+
accepts = ["network.service", "vulnerability.found", "network.host"]
|
|
29
|
+
|
|
30
|
+
[output]
|
|
31
|
+
produces = ["exploit.reference"]
|
|
32
|
+
|
|
33
|
+
[learning]
|
|
34
|
+
enabled = true
|
|
35
|
+
|
|
36
|
+
[[learning.recipes]]
|
|
37
|
+
name = "Service Version Exploit Lookup"
|
|
38
|
+
difficulty = "Beginner"
|
|
39
|
+
description = "Search local Exploit-DB archives for publicly documented exploits matching discovered software version strings."
|
|
40
|
+
flags = ["--json"]
|
|
41
|
+
|
|
42
|
+
[learning.recipes.theory]
|
|
43
|
+
concept = "Offline Exploit Indexing & Version Fingerprint Matching"
|
|
44
|
+
explanation = """
|
|
45
|
+
SearchSploit evaluates local copies of the Offensive Security Exploit Database (Exploit-DB).
|
|
46
|
+
Instead of sending network packets to the target, it performs substring and regex searches across thousands of archived vulnerability PoCs.
|
|
47
|
+
Matching service names and version numbers against Exploit-DB allows security engineers to quickly discover if a running service has known remote compromise vectors.
|
|
48
|
+
"""
|
|
49
|
+
packet_wire_summary = "Local Query -> Match CSV/JSON index against service version -> Output exploit file paths"
|
|
50
|
+
remediation = "Upgrade exposed services to the latest supported patch release and backport vendor security fixes."
|
|
51
|
+
|
|
52
|
+
[[learning.recipes]]
|
|
53
|
+
name = "Remote Code Execution (RCE) Filter"
|
|
54
|
+
difficulty = "Intermediate"
|
|
55
|
+
description = "Isolate remote execution exploits that allow an unauthenticated attacker to execute commands over the network."
|
|
56
|
+
flags = ["-t", "Remote", "--json"]
|
|
57
|
+
|
|
58
|
+
[learning.recipes.theory]
|
|
59
|
+
concept = "Remote Attack Surfaces & CVSS Impact Classification"
|
|
60
|
+
explanation = """
|
|
61
|
+
Exploits in Exploit-DB are tagged by Type (remote, local, webapps, dos).
|
|
62
|
+
Remote exploits target listening daemons without requiring prior local shell access, representing the highest operational risk (CVSS 9.0–10.0).
|
|
63
|
+
Filtering for 'Remote' helps prioritize remediation on public internet-facing perimeters before evaluating local privilege escalations.
|
|
64
|
+
"""
|
|
65
|
+
packet_wire_summary = "Filter criteria: Type=='remote' -> Prioritizes pre-authentication vulnerabilities"
|
|
66
|
+
remediation = "Place listening services behind firewall ACLs, zero-trust network access (ZTNA), or VPN gateways."
|
|
67
|
+
|
|
68
|
+
[[learning.recipes]]
|
|
69
|
+
name = "Direct CVE Correlation"
|
|
70
|
+
difficulty = "Intermediate"
|
|
71
|
+
description = "Lookup proof-of-concept scripts and weaponized code corresponding to a specific Common Vulnerabilities and Exposures (CVE) identifier (e.g. Apache 2.4.49 path traversal CVE-2021-41773)."
|
|
72
|
+
flags = ["--cve", "2021-41773", "--json"]
|
|
73
|
+
|
|
74
|
+
[learning.recipes.theory]
|
|
75
|
+
concept = "Common Vulnerabilities and Exposures (CVE) Standardization"
|
|
76
|
+
explanation = """
|
|
77
|
+
CVE provides a standardized alphanumeric identifier for publicly known cybersecurity vulnerabilities.
|
|
78
|
+
Querying by CVE eliminates version-string ambiguity and directly maps scanner findings (such as from Nuclei or Nikto) to working proof-of-concept scripts in the local archive.
|
|
79
|
+
"""
|
|
80
|
+
packet_wire_summary = "Query CVE-YYYY-NNNN -> Cross-reference EDB-ID -> Display exploit code path"
|
|
81
|
+
remediation = "Reference the vendor security bulletin corresponding to the CVE and deploy mitigation workarounds if patches are pending."
|
|
82
|
+
|
|
83
|
+
[[learning.recipes]]
|
|
84
|
+
name = "Verified Exploit Filter"
|
|
85
|
+
difficulty = "Advanced"
|
|
86
|
+
description = "Query only exploits verified by Offensive Security lab engineers to avoid non-functional or unreliable proof-of-concepts."
|
|
87
|
+
flags = ["-w", "-t", "--json"]
|
|
88
|
+
|
|
89
|
+
[learning.recipes.theory]
|
|
90
|
+
concept = "Proof-of-Concept Reliability & Weaponization Verification"
|
|
91
|
+
explanation = """
|
|
92
|
+
Exploit-DB flags submissions with a 'Verified' bit indicating that Offensive Security analysts have independently reproduced the vulnerability and verified code execution in a test environment.
|
|
93
|
+
Focusing on verified exploits allows penetration testers and red teams to select reliable tools that won't crash production services due to unhandled exceptions or memory corruptions.
|
|
94
|
+
"""
|
|
95
|
+
packet_wire_summary = "Filter criteria: Verified=='1' -> Guarantees reproducible exploit payload"
|
|
96
|
+
remediation = "Prioritize emergency patching for vulnerabilities that possess verified, weaponized exploit code in the wild."
|
|
97
|
+
|
|
98
|
+
[power]
|
|
99
|
+
enabled = true
|
|
100
|
+
suggests = [
|
|
101
|
+
{ target = "network.service", condition = "service_name != ''", tool = "searchsploit", flags = "{target.data.service_name} {target.data.version}" },
|
|
102
|
+
{ target = "vulnerability.found", condition = "vuln_id != ''", tool = "searchsploit", flags = "--cve {target.pik.vuln_id}" }
|
|
103
|
+
]
|
tools/sqlmap/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""SQLMap tool package."""
|