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/sqlmap/adapter.py
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"""SQLMap tool adapter."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
import shlex
|
|
5
|
+
from typing import Any, AsyncIterator, Dict, List, Optional
|
|
6
|
+
|
|
7
|
+
from ether.registry.adapter import ToolAdapter
|
|
8
|
+
from ether.registry.wordlists import substitute_wordlist_macros
|
|
9
|
+
from ether.schemas.base import BaseFinding
|
|
10
|
+
from ether.schemas.credential import CredentialFound
|
|
11
|
+
from ether.schemas.web import WebVulnerability
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SqlmapAdapter(ToolAdapter):
|
|
15
|
+
"""Adapter for the sqlmap automated SQL injection tool."""
|
|
16
|
+
|
|
17
|
+
PARAM_RE = re.compile(r"Parameter:\s*([^\s\(]+)(?:\s*\(([^)]+)\))?", re.IGNORECASE)
|
|
18
|
+
TYPE_RE = re.compile(r"Type:\s*(.+)", re.IGNORECASE)
|
|
19
|
+
TITLE_RE = re.compile(r"Title:\s*(.+)", re.IGNORECASE)
|
|
20
|
+
PAYLOAD_RE = re.compile(r"Payload:\s*(.+)", re.IGNORECASE)
|
|
21
|
+
DBMS_RE = re.compile(r"(?:back-end DBMS:\s*|the back-end DBMS is\s*)([^\r\n]+)", re.IGNORECASE)
|
|
22
|
+
TECH_RE = re.compile(r"web application technology:\s*(.+)", re.IGNORECASE)
|
|
23
|
+
CRED_RE = re.compile(
|
|
24
|
+
r"\[\*\]\s*([^\s:\[]+)\s*(?:\[\d+\])?:\s*[\r\n]+\s*(?:password hash:\s*|clear-text password:\s*)([^\r\n]+)",
|
|
25
|
+
re.IGNORECASE,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
def validate_install(self) -> bool:
|
|
29
|
+
"""Check if sqlmap executable is in system PATH."""
|
|
30
|
+
return self.is_binary_available("sqlmap")
|
|
31
|
+
|
|
32
|
+
def sanitize_output(self, raw_stdout: str) -> str:
|
|
33
|
+
"""Strip SQLMap ASCII art logo, disclaimer, and progress counters."""
|
|
34
|
+
lines = []
|
|
35
|
+
for line in raw_stdout.splitlines():
|
|
36
|
+
s = line.strip()
|
|
37
|
+
# Filter figlet banners, URLs, legal disclaimers, or noise lines
|
|
38
|
+
if (
|
|
39
|
+
s.startswith("___")
|
|
40
|
+
or s.startswith("|_")
|
|
41
|
+
or s.startswith("__H__")
|
|
42
|
+
or "sqlmap.org" in s
|
|
43
|
+
or "[*] starting @" in s
|
|
44
|
+
or "[*] ending @" in s
|
|
45
|
+
or s.startswith("[!] legal disclaimer")
|
|
46
|
+
):
|
|
47
|
+
continue
|
|
48
|
+
lines.append(line)
|
|
49
|
+
return "\n".join(lines)
|
|
50
|
+
|
|
51
|
+
def build_command(self, target: BaseFinding, params: Dict[str, Any]) -> List[str]:
|
|
52
|
+
"""Construct the sqlmap CLI execution command."""
|
|
53
|
+
url = self.extract_url(target)
|
|
54
|
+
|
|
55
|
+
raw_flags = params.get("raw_flags", "").strip()
|
|
56
|
+
raw_flags, _ = substitute_wordlist_macros(raw_flags)
|
|
57
|
+
flag_args = shlex.split(raw_flags) if raw_flags else []
|
|
58
|
+
|
|
59
|
+
args = ["sqlmap"]
|
|
60
|
+
|
|
61
|
+
# 1. Enforce non-interactive batch mode to avoid stdin blocking
|
|
62
|
+
if "--batch" not in flag_args and "-b" not in flag_args:
|
|
63
|
+
args.append("--batch")
|
|
64
|
+
|
|
65
|
+
# 2. Enforce target URL
|
|
66
|
+
has_u = any(flag_args[i] in ("-u", "--url") for i in range(len(flag_args)))
|
|
67
|
+
if not has_u:
|
|
68
|
+
if not url:
|
|
69
|
+
raise ValueError(
|
|
70
|
+
f"Target finding {target.schema_type} has no valid URL or host identifier, and no -u flag provided."
|
|
71
|
+
)
|
|
72
|
+
args.extend(["-u", url])
|
|
73
|
+
|
|
74
|
+
args.extend(flag_args)
|
|
75
|
+
return args
|
|
76
|
+
|
|
77
|
+
def _extract_url(self, target: BaseFinding) -> Optional[str]:
|
|
78
|
+
return self.extract_url(target)
|
|
79
|
+
|
|
80
|
+
async def parse_output(
|
|
81
|
+
self, raw_stdout: str, target: BaseFinding, context: Dict[str, Any] = None
|
|
82
|
+
) -> AsyncIterator[BaseFinding]:
|
|
83
|
+
"""Parse SQLMap stdout to extract identified SQLi vulnerabilities and dumped credentials."""
|
|
84
|
+
cleaned = raw_stdout.strip()
|
|
85
|
+
if not cleaned:
|
|
86
|
+
return
|
|
87
|
+
|
|
88
|
+
target_url = self.extract_url(target) or "http://target"
|
|
89
|
+
host_ip = (
|
|
90
|
+
target.pik.get("host_ip")
|
|
91
|
+
or target.pik.get("ip")
|
|
92
|
+
or target.data.get("host_ip")
|
|
93
|
+
or target.data.get("ip")
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# 1. Extract DBMS and technology fingerprints
|
|
97
|
+
dbms = None
|
|
98
|
+
dbms_match = self.DBMS_RE.search(cleaned)
|
|
99
|
+
if dbms_match:
|
|
100
|
+
dbms = dbms_match.group(1).strip()
|
|
101
|
+
|
|
102
|
+
tech = None
|
|
103
|
+
tech_match = self.TECH_RE.search(cleaned)
|
|
104
|
+
if tech_match:
|
|
105
|
+
tech = tech_match.group(1).strip()
|
|
106
|
+
|
|
107
|
+
# 2. Extract injection points
|
|
108
|
+
# Split by sections or parse iteratively
|
|
109
|
+
current_param = None
|
|
110
|
+
current_type = None
|
|
111
|
+
current_title = None
|
|
112
|
+
current_payload = None
|
|
113
|
+
|
|
114
|
+
seen_params = set()
|
|
115
|
+
|
|
116
|
+
for line in cleaned.splitlines():
|
|
117
|
+
line_str = line.strip()
|
|
118
|
+
|
|
119
|
+
param_match = self.PARAM_RE.search(line_str)
|
|
120
|
+
if param_match:
|
|
121
|
+
# If we had a previous finding assembled, yield it
|
|
122
|
+
if current_param and (current_type or current_payload):
|
|
123
|
+
key = (target_url, current_param, current_type)
|
|
124
|
+
if key not in seen_params:
|
|
125
|
+
seen_params.add(key)
|
|
126
|
+
yield WebVulnerability.create(
|
|
127
|
+
url=target_url,
|
|
128
|
+
vuln_type="SQL Injection",
|
|
129
|
+
parameter=current_param,
|
|
130
|
+
technique=current_type or "Unknown",
|
|
131
|
+
title=current_title or "SQL Injection",
|
|
132
|
+
payload=current_payload or "",
|
|
133
|
+
dbms=dbms,
|
|
134
|
+
technology=tech,
|
|
135
|
+
severity="high",
|
|
136
|
+
description=(
|
|
137
|
+
f"SQL injection detected on parameter '{current_param}' "
|
|
138
|
+
f"using technique '{current_type or 'Unknown'}'. DBMS: {dbms or 'Unknown'}."
|
|
139
|
+
),
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
current_param = param_match.group(1)
|
|
143
|
+
current_type = None
|
|
144
|
+
current_title = None
|
|
145
|
+
current_payload = None
|
|
146
|
+
continue
|
|
147
|
+
|
|
148
|
+
type_match = self.TYPE_RE.search(line_str)
|
|
149
|
+
if type_match:
|
|
150
|
+
current_type = type_match.group(1).strip()
|
|
151
|
+
continue
|
|
152
|
+
|
|
153
|
+
title_match = self.TITLE_RE.search(line_str)
|
|
154
|
+
if title_match:
|
|
155
|
+
current_title = title_match.group(1).strip()
|
|
156
|
+
continue
|
|
157
|
+
|
|
158
|
+
payload_match = self.PAYLOAD_RE.search(line_str)
|
|
159
|
+
if payload_match:
|
|
160
|
+
current_payload = payload_match.group(1).strip()
|
|
161
|
+
# Once we have param + type + payload, yield finding
|
|
162
|
+
if current_param:
|
|
163
|
+
key = (target_url, current_param, current_type)
|
|
164
|
+
if key not in seen_params:
|
|
165
|
+
seen_params.add(key)
|
|
166
|
+
yield WebVulnerability.create(
|
|
167
|
+
url=target_url,
|
|
168
|
+
vuln_type="SQL Injection",
|
|
169
|
+
parameter=current_param,
|
|
170
|
+
technique=current_type or "Unknown",
|
|
171
|
+
title=current_title or "SQL Injection",
|
|
172
|
+
payload=current_payload or "",
|
|
173
|
+
dbms=dbms,
|
|
174
|
+
technology=tech,
|
|
175
|
+
severity="high",
|
|
176
|
+
description=(
|
|
177
|
+
f"SQL injection detected on parameter '{current_param}' "
|
|
178
|
+
f"using technique '{current_type or 'Unknown'}'. DBMS: {dbms or 'Unknown'}."
|
|
179
|
+
),
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
# Catch any trailing parameter finding
|
|
183
|
+
if current_param and (current_type or current_payload):
|
|
184
|
+
key = (target_url, current_param, current_type)
|
|
185
|
+
if key not in seen_params:
|
|
186
|
+
seen_params.add(key)
|
|
187
|
+
yield WebVulnerability.create(
|
|
188
|
+
url=target_url,
|
|
189
|
+
vuln_type="SQL Injection",
|
|
190
|
+
parameter=current_param,
|
|
191
|
+
technique=current_type or "Unknown",
|
|
192
|
+
title=current_title or "SQL Injection",
|
|
193
|
+
payload=current_payload or "",
|
|
194
|
+
dbms=dbms,
|
|
195
|
+
technology=tech,
|
|
196
|
+
severity="high",
|
|
197
|
+
description=(
|
|
198
|
+
f"SQL injection detected on parameter '{current_param}' "
|
|
199
|
+
f"using technique '{current_type or 'Unknown'}'. DBMS: {dbms or 'Unknown'}."
|
|
200
|
+
),
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
# 3. Extract dumped database user credentials
|
|
204
|
+
for cred_match in self.CRED_RE.finditer(cleaned):
|
|
205
|
+
username = cred_match.group(1).strip()
|
|
206
|
+
password_hash = cred_match.group(2).strip()
|
|
207
|
+
if username and password_hash:
|
|
208
|
+
yield CredentialFound.create(
|
|
209
|
+
context=f"db://{dbms or 'database'}",
|
|
210
|
+
username=username,
|
|
211
|
+
password=password_hash,
|
|
212
|
+
host_ip=host_ip,
|
|
213
|
+
credential_type="hash",
|
|
214
|
+
)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
[meta]
|
|
2
|
+
name = "sqlmap"
|
|
3
|
+
description = "Automatic SQL injection and database takeover tool capable of detecting and exploiting flaws across MySQL, PostgreSQL, Oracle, Microsoft SQL Server, SQLite, and more."
|
|
4
|
+
one_line_summary = "automatic SQL injection and database takeover engine"
|
|
5
|
+
category = "Vulnerability Assessment"
|
|
6
|
+
categories = ["vulnerability", "web", "database", "exploit"]
|
|
7
|
+
binary = "sqlmap"
|
|
8
|
+
theory = """
|
|
9
|
+
### Theory & SQL Injection Mechanics
|
|
10
|
+
SQL Injection (SQLi) occurs when untrusted user-supplied input is directly concatenated into dynamic database query strings rather than bound via parameterized statements. This allows an attacker to alter the query's abstract syntax tree (AST) and execute arbitrary database commands.
|
|
11
|
+
|
|
12
|
+
### Detection & Exploitation Techniques
|
|
13
|
+
* **Boolean-Based Blind**: Injects true/false conditional subqueries and infers data character-by-character based on subtle response body variations.
|
|
14
|
+
* **Error-Based**: Forces unhandled database runtime exceptions (e.g., `FLOOR(RAND(0)*2)` or `CAST(...)`) that echo sensitive data directly into HTTP error pages.
|
|
15
|
+
* **UNION Query**: Combines the original query results with attacker-crafted `UNION SELECT` rows, echoing table contents directly into the page response.
|
|
16
|
+
* **Stacked Queries**: Executes semicolon-separated commands, allowing `INSERT`, `UPDATE`, `DROP`, or stored procedures (e.g., `xp_cmdshell` on MSSQL).
|
|
17
|
+
* **Time-Based Blind**: Injects database sleep routines (e.g., `pg_sleep()`, `WAITFOR DELAY`, `SLEEP()`) and measures response latency to extract data when no output or errors are returned.
|
|
18
|
+
|
|
19
|
+
### Defensive Remediation & Secure Architecture
|
|
20
|
+
* **Parameterized Queries & Prepared Statements**: Enforce complete separation between code and data across all database access layers.
|
|
21
|
+
* **Least Privilege Database Accounts**: Restrict web application database users from accessing administrative system catalogs or OS-level procedures.
|
|
22
|
+
* **Web Application Firewall (WAF)**: Deploy signature and heuristic inspection to filter obvious injection payloads.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
[modes]
|
|
26
|
+
learning = true
|
|
27
|
+
power = true
|
|
28
|
+
|
|
29
|
+
[input]
|
|
30
|
+
accepts = ["web.endpoint", "web.vulnerability"]
|
|
31
|
+
|
|
32
|
+
[output]
|
|
33
|
+
produces = ["web.vulnerability", "credential.found"]
|
|
34
|
+
|
|
35
|
+
[learning]
|
|
36
|
+
enabled = true
|
|
37
|
+
|
|
38
|
+
[[learning.recipes]]
|
|
39
|
+
name = "Safe Injection Detection & Fingerprinting"
|
|
40
|
+
difficulty = "Beginner"
|
|
41
|
+
description = "Safely test endpoint parameters for SQL injection vulnerabilities and fingerprint the underlying DBMS."
|
|
42
|
+
flags = ["-u", "{url}", "--batch", "--banner", "--level=1", "--risk=1"]
|
|
43
|
+
|
|
44
|
+
[learning.recipes.theory]
|
|
45
|
+
concept = "SQL Syntax Deviation & Database Engine Fingerprinting"
|
|
46
|
+
explanation = """
|
|
47
|
+
1. What the tool does: Injects benign syntax probes (single quotes, logic inversions like AND 1=1) into URL query parameters to evaluate response stability and detect unhandled database exceptions.
|
|
48
|
+
2. Flag selection: '--batch' forces non-interactive mode so scans run automatically without prompts; '--banner' retrieves the DBMS version banner; '--level=1 --risk=1' limits testing to standard HTTP parameters without destructive payloads.
|
|
49
|
+
3. Response interpretation: Identifying specific SQL error strings or status code changes reveals the exact database vendor and version (e.g. MySQL, PostgreSQL).
|
|
50
|
+
"""
|
|
51
|
+
packet_wire_summary = "Client GET /items?id=1' -> Server HTTP/1.1 500 Internal Server Error (You have an error in your SQL syntax)"
|
|
52
|
+
remediation = "Replace string-concatenated SQL queries with parameterized statements and prepared statements in your application code."
|
|
53
|
+
|
|
54
|
+
[[learning.recipes]]
|
|
55
|
+
name = "Multi-Technique Injection Assessment"
|
|
56
|
+
difficulty = "Intermediate"
|
|
57
|
+
description = "Execute comprehensive testing across Boolean, Error, UNION, Stacked, and Time-based injection vectors."
|
|
58
|
+
flags = ["-u", "{url}", "--batch", "--technique=BEUST", "--current-user"]
|
|
59
|
+
|
|
60
|
+
[learning.recipes.theory]
|
|
61
|
+
concept = "Five Core SQL Injection Methodologies (BEUST)"
|
|
62
|
+
explanation = """
|
|
63
|
+
1. What the tool does: Systematically tests all five core injection techniques:
|
|
64
|
+
- B: Boolean-based blind (conditional true/false responses)
|
|
65
|
+
- E: Error-based (forcing data into error messages)
|
|
66
|
+
- U: UNION query (joining attacker queries to legitimate output)
|
|
67
|
+
- S: Stacked queries (multiple commands separated by semicolons)
|
|
68
|
+
- T: Time-based blind (measuring delay via SLEEP functions)
|
|
69
|
+
2. Flag selection: '--technique=BEUST' restricts or enforces all 5 methods; '--current-user' extracts the active database user account.
|
|
70
|
+
3. Response interpretation: Verifying the injection technique determines the fastest extraction speed (UNION is fastest, Time-based is slowest).
|
|
71
|
+
"""
|
|
72
|
+
packet_wire_summary = "Client GET /items?id=1 UNION SELECT 1,CURRENT_USER(),3-- - -> Server HTTP/1.1 200 OK (db_user@localhost)"
|
|
73
|
+
remediation = "Ensure Object-Relational Mappers (ORMs) or database abstraction libraries are configured with strict parameter binding."
|
|
74
|
+
|
|
75
|
+
[[learning.recipes]]
|
|
76
|
+
name = "Database Catalog & Schema Enumeration"
|
|
77
|
+
difficulty = "Advanced"
|
|
78
|
+
description = "Enumerate accessible databases and system schemas on verified vulnerable endpoints."
|
|
79
|
+
flags = ["-u", "{url}", "--batch", "--dbs"]
|
|
80
|
+
|
|
81
|
+
[learning.recipes.theory]
|
|
82
|
+
concept = "Database Catalog Discovery & Information Disclosure"
|
|
83
|
+
explanation = """
|
|
84
|
+
1. What the tool does: Queries metadata catalogs (such as INFORMATION_SCHEMA.SCHEMATA on MySQL/PostgreSQL or sys.databases on MSSQL) to discover all database instances hosted on the target engine.
|
|
85
|
+
2. Flag selection: '--dbs' requests the list of all available databases; '--batch' ensures automated non-blocking execution.
|
|
86
|
+
3. Risk analysis: Demonstrates critical risk: read access to internal database schemas typically leads to discovery of user credentials, payment tables, and sensitive company records.
|
|
87
|
+
"""
|
|
88
|
+
packet_wire_summary = "Client GET /items?id=1 UNION SELECT schema_name FROM information_schema.schemata-- - -> Database lists schemas"
|
|
89
|
+
remediation = "Isolate application databases into independent user accounts without permissions to read INFORMATION_SCHEMA or master catalogs."
|
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Subfinder tool adapter."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
import shlex
|
|
5
|
+
from typing import Any, AsyncIterator, Dict, List
|
|
6
|
+
|
|
7
|
+
from ether.registry.adapter import ToolAdapter
|
|
8
|
+
from ether.schemas.base import BaseFinding
|
|
9
|
+
from ether.schemas.dns import DnsRecord
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class SubfinderAdapter(ToolAdapter):
|
|
13
|
+
"""Adapter for the subfinder tool."""
|
|
14
|
+
|
|
15
|
+
DOMAIN_RE = re.compile(r"^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$")
|
|
16
|
+
|
|
17
|
+
def validate_install(self) -> bool:
|
|
18
|
+
return self.is_binary_available("subfinder")
|
|
19
|
+
|
|
20
|
+
def sanitize_output(self, raw_stdout: str) -> str:
|
|
21
|
+
"""Strip subfinder ASCII art banners, progress lines, and diagnostic logging."""
|
|
22
|
+
lines = []
|
|
23
|
+
for line in raw_stdout.splitlines():
|
|
24
|
+
s = line.strip()
|
|
25
|
+
if (
|
|
26
|
+
s.startswith("[")
|
|
27
|
+
or s.startswith("_")
|
|
28
|
+
or s.startswith("::")
|
|
29
|
+
or "subfinder" in s.lower()
|
|
30
|
+
and ("projectdiscovery" in s.lower() or "version" in s.lower())
|
|
31
|
+
):
|
|
32
|
+
continue
|
|
33
|
+
lines.append(line)
|
|
34
|
+
return "\n".join(lines)
|
|
35
|
+
|
|
36
|
+
def build_command(self, target: BaseFinding, params: Dict[str, Any]) -> List[str]:
|
|
37
|
+
args = ["subfinder"]
|
|
38
|
+
|
|
39
|
+
raw_flags = params.get("raw_flags", "")
|
|
40
|
+
if raw_flags:
|
|
41
|
+
domain = self.extract_domain(target) or ""
|
|
42
|
+
tokens = shlex.split(raw_flags)
|
|
43
|
+
resolved_tokens = [t.replace("{domain}", domain) for t in tokens if t]
|
|
44
|
+
args.extend(resolved_tokens)
|
|
45
|
+
|
|
46
|
+
return args
|
|
47
|
+
|
|
48
|
+
async def parse_output(
|
|
49
|
+
self, raw_stdout: str, target: BaseFinding, context: Dict[str, Any] = None
|
|
50
|
+
) -> AsyncIterator[BaseFinding]:
|
|
51
|
+
"""Parser for subfinder output.
|
|
52
|
+
|
|
53
|
+
Expects lines containing just the subdomains (if -silent is used)
|
|
54
|
+
or lines with subdomains among logging (which we filter out).
|
|
55
|
+
Example line: api.example.com
|
|
56
|
+
"""
|
|
57
|
+
for line in raw_stdout.splitlines():
|
|
58
|
+
clean_line = self.strip_ansi(line).strip()
|
|
59
|
+
|
|
60
|
+
# Skip subfinder banner/logging if not using -silent
|
|
61
|
+
if not clean_line or clean_line.startswith("[") or clean_line.startswith("_"):
|
|
62
|
+
continue
|
|
63
|
+
|
|
64
|
+
if self.DOMAIN_RE.match(clean_line):
|
|
65
|
+
# We default to A record type as we just found a name, not necessarily knowing the type
|
|
66
|
+
# Real DNS resolution would follow to confirm
|
|
67
|
+
yield DnsRecord.create(
|
|
68
|
+
domain=clean_line,
|
|
69
|
+
record_type="A", # Assumption until resolved
|
|
70
|
+
value="unknown", # Needs resolving
|
|
71
|
+
)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
[meta]
|
|
2
|
+
name = "subfinder"
|
|
3
|
+
description = "Fast passive subdomain discovery tool designed to map enterprise attack surfaces using passive online reconnaissance sources."
|
|
4
|
+
one_line_summary = "discover subdomains passively using OSINT sources and CT logs"
|
|
5
|
+
category = "Network Reconnaissance"
|
|
6
|
+
categories = ["recon", "dns", "enumeration", "osint"]
|
|
7
|
+
binary = "subfinder"
|
|
8
|
+
theory = """
|
|
9
|
+
### Protocol Theory & Passive Attack Surface Mapping
|
|
10
|
+
Subfinder executes non-intrusive enumeration without transmitting packets to target infrastructure, leaving zero footprint in target IDS/IPS logs.
|
|
11
|
+
|
|
12
|
+
### Primary Intelligence Channels
|
|
13
|
+
* **Certificate Transparency Logs (RFC 6962)**: Public, append-only Merkle tree logs mandated for public CAs recording every issued TLS certificate.
|
|
14
|
+
* **Passive DNS (pDNS) Aggregation**: Streams historical resolution data from global DNS telemetry sensors.
|
|
15
|
+
* **Search Indices & Threat Feeds**: Collects indexed hostnames from public threat intelligence APIs.
|
|
16
|
+
|
|
17
|
+
### Defensive Hardening & Hygiene
|
|
18
|
+
* **CT Log Monitoring**: Deploy real-time alerts (e.g. Certstream) to detect unexpected certificate issuance.
|
|
19
|
+
* **DNS Garbage Collection**: De-provision stale CNAME pointers to prevent Subdomain Takeovers.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
[modes]
|
|
23
|
+
learning = true
|
|
24
|
+
power = true
|
|
25
|
+
|
|
26
|
+
[input]
|
|
27
|
+
accepts = ["domain.info", "dns.record"]
|
|
28
|
+
|
|
29
|
+
[output]
|
|
30
|
+
produces = ["dns.record"]
|
|
31
|
+
|
|
32
|
+
[learning]
|
|
33
|
+
enabled = true
|
|
34
|
+
|
|
35
|
+
[[learning.recipes]]
|
|
36
|
+
name = "Passive OSINT Subdomain Enumeration"
|
|
37
|
+
difficulty = "Beginner"
|
|
38
|
+
description = "Query passive threat intelligence feeds and Certificate Transparency logs without transmitting packets to target infrastructure."
|
|
39
|
+
flags = ["-d", "{domain}"]
|
|
40
|
+
|
|
41
|
+
[learning.recipes.theory]
|
|
42
|
+
concept = "Passive Reconnaissance & Certificate Transparency Logs (RFC 6962)"
|
|
43
|
+
explanation = """
|
|
44
|
+
Passive discovery uncovers subdomains without sending a single probe to the target company's network.
|
|
45
|
+
Certificate Transparency (CT) mandates that Certificate Authorities publicly log every issued SSL/TLS certificate.
|
|
46
|
+
Search engines (Google, Bing), DNS aggregators (PassiveTotal, DNSDumpster), and CT databases (crt.sh) continually index these logs.
|
|
47
|
+
Subfinder queries these public databases to harvest subdomains completely undetected by the target's SOC or intrusion detection systems.
|
|
48
|
+
"""
|
|
49
|
+
packet_wire_summary = "Client HTTPS -> Third-party intelligence APIs (crt.sh, AlienVault) -> Zero traffic sent to target network"
|
|
50
|
+
remediation = "Maintain an automated external attack surface management (EASM) pipeline to identify and decommission forgotten legacy subdomains."
|
|
51
|
+
|
|
52
|
+
[[learning.recipes]]
|
|
53
|
+
name = "All-Source Deep Enumeration"
|
|
54
|
+
difficulty = "Intermediate"
|
|
55
|
+
description = "Query all available passive provider sources to maximize subdomain discovery coverage."
|
|
56
|
+
flags = ["-d", "{domain}", "-all"]
|
|
57
|
+
|
|
58
|
+
[learning.recipes.theory]
|
|
59
|
+
concept = "Intelligence Aggregation & Attack Surface Coverage Maximization"
|
|
60
|
+
explanation = """
|
|
61
|
+
Individual passive sources only maintain partial snapshots of an organization's domain footprint.
|
|
62
|
+
For example, historical archives may contain subdomains active 5 years ago, while Certificate Transparency logs reflect recent cloud deployments.
|
|
63
|
+
Enabling '-all' aggregates data across dozens of passive feeds, cross-validates records, and deduplicates the resulting domain list.
|
|
64
|
+
"""
|
|
65
|
+
packet_wire_summary = "Client queries 40+ independent threat feeds simultaneously -> Deduplicates and normalizes FQDN results"
|
|
66
|
+
remediation = "Enforce strict DNS lifecycle management to remove DNS pointers when cloud instances or SaaS integrations are terminated."
|
|
67
|
+
|
|
68
|
+
[[learning.recipes]]
|
|
69
|
+
name = "Rate-Limited & Throttled Discovery"
|
|
70
|
+
difficulty = "Intermediate"
|
|
71
|
+
description = "Control request concurrency and rate-limits to avoid IP bans on public OSINT API endpoints."
|
|
72
|
+
flags = ["-d", "{domain}", "-rate-limit", "10", "-t", "5"]
|
|
73
|
+
|
|
74
|
+
[learning.recipes.theory]
|
|
75
|
+
concept = "API Rate Limits, Token Buckets & Provider Throttling"
|
|
76
|
+
explanation = """
|
|
77
|
+
Public intelligence providers (e.g. VirusTotal, Censys, Shodan) protect their compute infrastructure by implementing aggressive IP-based rate limiting.
|
|
78
|
+
Exceeding rate thresholds results in HTTP 429 Too Many Requests errors and temporary blacklisting.
|
|
79
|
+
Configuring '-rate-limit' regulates requests-per-second, ensuring reliable enumeration across entire enterprise address spaces.
|
|
80
|
+
"""
|
|
81
|
+
packet_wire_summary = "Client paces queries to 10 requests per second across 5 concurrent worker threads"
|
|
82
|
+
remediation = "Use dedicated API tokens with elevated tier quotas for authorized penetration testing workflows."
|
|
83
|
+
|
|
84
|
+
[[learning.recipes]]
|
|
85
|
+
name = "JSON Output Streaming Pipeline"
|
|
86
|
+
difficulty = "Advanced"
|
|
87
|
+
description = "Emit structured JSON lines output for direct automated piping into vulnerability and port scanners."
|
|
88
|
+
flags = ["-d", "{domain}", "-oJ", "-silent"]
|
|
89
|
+
|
|
90
|
+
[learning.recipes.theory]
|
|
91
|
+
concept = "Unix Pipeline Philosophy & Structured Telemetry Ingestion"
|
|
92
|
+
explanation = """
|
|
93
|
+
Modern reconnaissance relies on composable, streaming architectures.
|
|
94
|
+
Emitting output as JSON Lines (-oJ) accompanied by '-silent' suppresses ASCII art banners, allowing downstream automation (like Ether's Action Gateway) to parse domain names, discovered IPs, and provider sources in real time without regex fragility.
|
|
95
|
+
"""
|
|
96
|
+
packet_wire_summary = "Tool streams newline-delimited JSON objects -> Ether ActionGateway -> SQLite entity graph"
|
|
97
|
+
remediation = "Automate continuous discovery pipelines to alert SOC teams when new unauthorized subdomains emerge."
|
|
98
|
+
|
|
99
|
+
[power]
|
|
100
|
+
enabled = true
|
|
101
|
+
suggests = [
|
|
102
|
+
{ target = "dns.record", condition = "type == 'A'", tool = "nmap", flags = "-sV {target.data.value}" },
|
|
103
|
+
{ target = "dns.record", condition = "domain != ''", tool = "ffuf", flags = "-u http://{target.pik.domain}/FUZZ -w {wordlist:common_dirs}" }
|
|
104
|
+
]
|
tools/whois/__init__.py
ADDED
|
File without changes
|
tools/whois/adapter.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Whois tool adapter."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
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.dns import DomainInfo
|
|
10
|
+
from ether.schemas.network import NetworkHost, NetworkNetblock
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class WhoisAdapter(ToolAdapter):
|
|
14
|
+
"""Adapter for the whois client."""
|
|
15
|
+
|
|
16
|
+
REGISTRAR_PATTERN = re.compile(r"Registrar:\s*(.*)", re.IGNORECASE)
|
|
17
|
+
ORG_PATTERN = re.compile(r"(?:Organization|Registrant Organization):\s*(.*)", re.IGNORECASE)
|
|
18
|
+
CIDR_PATTERN = re.compile(r"(?:CIDR|NetRange):\s*(.*)", re.IGNORECASE)
|
|
19
|
+
|
|
20
|
+
def validate_install(self) -> bool:
|
|
21
|
+
return self.is_binary_available("whois")
|
|
22
|
+
|
|
23
|
+
def sanitize_output(self, raw_stdout: str) -> str:
|
|
24
|
+
"""Strip whois legal disclaimers, boilerplate, and comment blocks."""
|
|
25
|
+
lines = []
|
|
26
|
+
for line in raw_stdout.splitlines():
|
|
27
|
+
s = line.strip()
|
|
28
|
+
if s.startswith("%") or s.startswith("#") or "TERMS OF USE" in s.upper():
|
|
29
|
+
continue
|
|
30
|
+
lines.append(line)
|
|
31
|
+
return "\n".join(lines)
|
|
32
|
+
|
|
33
|
+
def build_command(self, target: BaseFinding, params: Dict[str, Any]) -> List[str]:
|
|
34
|
+
# target can be dns.record (use domain) or network.host (use ip)
|
|
35
|
+
query = self.extract_domain(target) or self.extract_host(target)
|
|
36
|
+
|
|
37
|
+
args = ["whois"]
|
|
38
|
+
|
|
39
|
+
raw_flags = params.get("raw_flags", "")
|
|
40
|
+
if raw_flags:
|
|
41
|
+
args.extend(shlex.split(raw_flags))
|
|
42
|
+
|
|
43
|
+
if query:
|
|
44
|
+
args.append(query)
|
|
45
|
+
elif not raw_flags:
|
|
46
|
+
raise ValueError(
|
|
47
|
+
f"Target finding {target.schema_type} missing query field (domain/ip), and no flags provided."
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
return args
|
|
51
|
+
|
|
52
|
+
async def parse_output(
|
|
53
|
+
self, raw_stdout: str, target: BaseFinding, context: Dict[str, Any] = None
|
|
54
|
+
) -> AsyncIterator[BaseFinding]:
|
|
55
|
+
"""Parse whois output for registrar, organization, and IP info."""
|
|
56
|
+
|
|
57
|
+
registrar = self._extract(raw_stdout, self.REGISTRAR_PATTERN)
|
|
58
|
+
org = self._extract(raw_stdout, self.ORG_PATTERN)
|
|
59
|
+
cidr = self._extract(raw_stdout, self.CIDR_PATTERN)
|
|
60
|
+
|
|
61
|
+
# 1. If we queried a domain, emit DomainInfo
|
|
62
|
+
if target.schema_type == "dns.record":
|
|
63
|
+
domain = target.pik.get("domain")
|
|
64
|
+
yield DomainInfo.create(domain=domain, registrar=registrar, organization=org)
|
|
65
|
+
|
|
66
|
+
# 2. Emit Netblock info if found
|
|
67
|
+
if cidr or org:
|
|
68
|
+
yield NetworkNetblock.create(cidr=cidr or "Unknown", organization=org)
|
|
69
|
+
|
|
70
|
+
# 3. Emit host enrichment finding
|
|
71
|
+
if target.schema_type == "network.host":
|
|
72
|
+
ip = target.pik.get("ip")
|
|
73
|
+
yield NetworkHost.create(ip=ip)
|
|
74
|
+
|
|
75
|
+
def _extract(self, text: str, pattern: Any) -> Optional[str]:
|
|
76
|
+
if isinstance(pattern, str):
|
|
77
|
+
match = re.search(pattern, text, re.IGNORECASE)
|
|
78
|
+
else:
|
|
79
|
+
match = pattern.search(text)
|
|
80
|
+
return match.group(1).strip() if match else None
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
[meta]
|
|
2
|
+
name = "whois"
|
|
3
|
+
description = "Retrieve domain registration, ownership records, netblock assignments, and Autonomous System (ASN) routing intelligence."
|
|
4
|
+
one_line_summary = "ownership, registrar, and IP netblock intelligence"
|
|
5
|
+
category = "Network Reconnaissance"
|
|
6
|
+
categories = ["recon", "osint"]
|
|
7
|
+
binary = "whois"
|
|
8
|
+
theory = """
|
|
9
|
+
### Protocol Theory & RFC 3912 Architecture
|
|
10
|
+
The WHOIS protocol (RFC 3912) queries hierarchical registries over TCP port 43 to retrieve domain ownership and routing data.
|
|
11
|
+
|
|
12
|
+
### Core Architecture & RIRs
|
|
13
|
+
* **Regional Registries (RIRs)**: Five global entities (ARIN, RIPE, APNIC, LACNIC, AFRINIC) govern CIDR netblock ownership.
|
|
14
|
+
* **Autonomous System Numbers (ASNs)**: Resolves BGP routing origin networks attributed to carriers and cloud providers.
|
|
15
|
+
* **Domain Attribution**: Identifies registrar authority, registration dates, and upstream DNS delegation points.
|
|
16
|
+
|
|
17
|
+
### Defensive Hardening & Privacy
|
|
18
|
+
* **Privacy Proxy Services**: Obfuscate administrative PII behind accredited registrar proxies.
|
|
19
|
+
* **RDAP Migration (RFC 7480-7484)**: Move to RESTful JSON directory protocol with role-based authenticated access.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
[modes]
|
|
23
|
+
learning = true
|
|
24
|
+
power = true
|
|
25
|
+
|
|
26
|
+
[input]
|
|
27
|
+
accepts = ["dns.record", "network.host"]
|
|
28
|
+
|
|
29
|
+
[output]
|
|
30
|
+
produces = ["domain.info", "network.netblock", "network.host"]
|
|
31
|
+
|
|
32
|
+
[learning]
|
|
33
|
+
enabled = true
|
|
34
|
+
|
|
35
|
+
[[learning.recipes]]
|
|
36
|
+
name = "Domain Registrar & Ownership Lookup"
|
|
37
|
+
difficulty = "Beginner"
|
|
38
|
+
description = "Query the authoritative WHOIS registry for domain registrar, creation/expiration dates, and registrant organization."
|
|
39
|
+
flags = []
|
|
40
|
+
|
|
41
|
+
[learning.recipes.theory]
|
|
42
|
+
concept = "Domain Name Registration Model & Extensible Provisioning Protocol (RFC 5730)"
|
|
43
|
+
explanation = """
|
|
44
|
+
When an organization purchases a top-level domain (TLD), the registrar submits ownership and technical delegation metadata to the authoritative TLD registry (e.g. Verisign for .com).
|
|
45
|
+
The WHOIS protocol operates over TCP port 43 as a simple text request/response standard (RFC 3912).
|
|
46
|
+
Querying WHOIS discloses:
|
|
47
|
+
1. Sponsoring Registrar and IANA ID.
|
|
48
|
+
2. Creation, expiration, and update timestamps (crucial for detecting domain expiry hijacking).
|
|
49
|
+
3. Authoritative nameserver delegations.
|
|
50
|
+
"""
|
|
51
|
+
packet_wire_summary = "Client TCP:43 -> Connect to whois.iana.org / registrar server -> Transmit domain string -> Receive plaintext registry response"
|
|
52
|
+
remediation = "Enable Registrar Lock (TransferProhibited) and WHOIS Privacy Protection / GDPR masking to prevent social engineering."
|
|
53
|
+
|
|
54
|
+
[[learning.recipes]]
|
|
55
|
+
name = "Regional Internet Registry (RIR) Netblock Query"
|
|
56
|
+
difficulty = "Beginner"
|
|
57
|
+
description = "Lookup the Classless Inter-Domain Routing (CIDR) netblock assignment and network owner for an IP address."
|
|
58
|
+
flags = []
|
|
59
|
+
|
|
60
|
+
[learning.recipes.theory]
|
|
61
|
+
concept = "Regional Internet Registry (RIR) Allocation Hierarchy (RFC 4632)"
|
|
62
|
+
explanation = """
|
|
63
|
+
Global IPv4 and IPv6 address space is managed by IANA and delegated to five Regional Internet Registries:
|
|
64
|
+
- ARIN (North America)
|
|
65
|
+
- RIPE NCC (Europe, Middle East, Central Asia)
|
|
66
|
+
- APNIC (Asia-Pacific)
|
|
67
|
+
- LACNIC (Latin America & Caribbean)
|
|
68
|
+
- AFRINIC (Africa)
|
|
69
|
+
Querying an IP address against WHOIS queries the respective RIR database, returning the NetRange, CIDR notation (e.g. 192.0.2.0/24), and parent ISP/hosting provider.
|
|
70
|
+
"""
|
|
71
|
+
packet_wire_summary = "Client queries RIR database (e.g. whois.arin.net) -> Resolves OrgName, NetRange, and CIDR block"
|
|
72
|
+
remediation = "Maintain accurate Network Coordination Center (POC) contact information for immediate security incident notification."
|
|
73
|
+
|
|
74
|
+
[[learning.recipes]]
|
|
75
|
+
name = "Direct ARIN / RIPE Host Query"
|
|
76
|
+
difficulty = "Intermediate"
|
|
77
|
+
description = "Force the query to a specific regional registry host to bypass local referral timeouts."
|
|
78
|
+
flags = ["-h", "whois.arin.net"]
|
|
79
|
+
|
|
80
|
+
[learning.recipes.theory]
|
|
81
|
+
concept = "WHOIS Referral Chains & Regional Database Redirection"
|
|
82
|
+
explanation = """
|
|
83
|
+
Because IP allocations are divided geographically, standard WHOIS clients initiate a query against a default server and follow referral pointers (e.g. 'ReferralServer: whois://whois.ripe.net').
|
|
84
|
+
Explicitly targeting the authoritative RIR server with '-h' reduces latency, avoids rate-limiting on gateway referral servers, and returns the full uncut technical allocation records.
|
|
85
|
+
"""
|
|
86
|
+
packet_wire_summary = "Client connects directly to target RIR port 43 -> Bypasses multi-hop referral queries"
|
|
87
|
+
remediation = "Ensure organization records are synchronized across all regional registries where infrastructure is deployed."
|
|
88
|
+
|
|
89
|
+
[power]
|
|
90
|
+
enabled = true
|
|
91
|
+
suggests = [
|
|
92
|
+
{ target = "domain.info", condition = "domain != ''", tool = "subfinder", flags = "-d {target.pik.domain}" },
|
|
93
|
+
{ target = "domain.info", condition = "domain != ''", tool = "dnspython", flags = "{target.pik.domain} -t NS" },
|
|
94
|
+
{ target = "network.netblock", condition = "cidr != ''", tool = "nmap", flags = "-sn {target.pik.cidr}" }
|
|
95
|
+
]
|