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.
Files changed (104) hide show
  1. ether/__init__.py +32 -0
  2. ether/assets/wordlists/common_dirs.txt.gz +0 -0
  3. ether/assets/wordlists/common_params.txt.gz +0 -0
  4. ether/assets/wordlists/common_passwords.txt.gz +0 -0
  5. ether/assets/wordlists/common_usernames.txt.gz +0 -0
  6. ether/assets/wordlists/subdomains_500.txt.gz +0 -0
  7. ether/cli/__init__.py +5 -0
  8. ether/cli/__main__.py +8 -0
  9. ether/cli/commands/__init__.py +1 -0
  10. ether/cli/commands/doctor.py +21 -0
  11. ether/cli/commands/graph.py +311 -0
  12. ether/cli/commands/logs.py +45 -0
  13. ether/cli/commands/mcp.py +49 -0
  14. ether/cli/commands/run.py +146 -0
  15. ether/cli/commands/session.py +61 -0
  16. ether/cli/commands/telemetry.py +51 -0
  17. ether/cli/commands/tool.py +131 -0
  18. ether/cli/context.py +71 -0
  19. ether/cli/formatters.py +39 -0
  20. ether/cli/router.py +368 -0
  21. ether/common/__init__.py +201 -0
  22. ether/common/algorithms.py +407 -0
  23. ether/common/canonicalize.py +93 -0
  24. ether/common/context.py +25 -0
  25. ether/common/crypto.py +183 -0
  26. ether/common/embeddings.py +93 -0
  27. ether/common/exceptions.py +13 -0
  28. ether/common/logging.py +386 -0
  29. ether/common/secure_memory.py +159 -0
  30. ether/common/ssrf.py +93 -0
  31. ether/core/__init__.py +25 -0
  32. ether/core/diagnostics.py +368 -0
  33. ether/core/executor.py +296 -0
  34. ether/core/sandbox.py +118 -0
  35. ether/core/session.py +956 -0
  36. ether/gateway/__init__.py +21 -0
  37. ether/gateway/gate.py +392 -0
  38. ether/gateway/network.py +98 -0
  39. ether/gateway/preflight.py +802 -0
  40. ether/graph/__init__.py +13 -0
  41. ether/graph/analytics.py +334 -0
  42. ether/graph/store.py +1615 -0
  43. ether/graph/telemetry.py +334 -0
  44. ether/graph/timeline.py +185 -0
  45. ether/mcp/__init__.py +5 -0
  46. ether/mcp/server.py +382 -0
  47. ether/paths.py +176 -0
  48. ether/py.typed +0 -0
  49. ether/registry/__init__.py +7 -0
  50. ether/registry/adapter.py +194 -0
  51. ether/registry/manifest.py +53 -0
  52. ether/registry/registry.py +150 -0
  53. ether/registry/wordlists.py +156 -0
  54. ether/schemas/__init__.py +50 -0
  55. ether/schemas/base.py +122 -0
  56. ether/schemas/credential.py +50 -0
  57. ether/schemas/dns.py +116 -0
  58. ether/schemas/host_internal.py +58 -0
  59. ether/schemas/network.py +142 -0
  60. ether/schemas/power.py +68 -0
  61. ether/schemas/vulnerability.py +221 -0
  62. ether/schemas/web.py +172 -0
  63. ether_core-0.1.0.dist-info/METADATA +440 -0
  64. ether_core-0.1.0.dist-info/RECORD +104 -0
  65. ether_core-0.1.0.dist-info/WHEEL +4 -0
  66. ether_core-0.1.0.dist-info/entry_points.txt +2 -0
  67. ether_core-0.1.0.dist-info/licenses/LICENSE +21 -0
  68. tools/__init__.py +0 -0
  69. tools/dnspython/__init__.py +1 -0
  70. tools/dnspython/adapter.py +302 -0
  71. tools/dnspython/cli.py +202 -0
  72. tools/dnspython/manifest.toml +138 -0
  73. tools/ffuf/__init__.py +1 -0
  74. tools/ffuf/adapter.py +183 -0
  75. tools/ffuf/manifest.toml +121 -0
  76. tools/gobuster/__init__.py +0 -0
  77. tools/gobuster/adapter.py +90 -0
  78. tools/gobuster/manifest.toml +104 -0
  79. tools/http_probe/adapter.py +256 -0
  80. tools/http_probe/manifest.toml +40 -0
  81. tools/netexec/__init__.py +1 -0
  82. tools/netexec/adapter.py +163 -0
  83. tools/netexec/manifest.toml +83 -0
  84. tools/nikto/__init__.py +0 -0
  85. tools/nikto/adapter.py +145 -0
  86. tools/nikto/manifest.toml +108 -0
  87. tools/nmap/__init__.py +0 -0
  88. tools/nmap/adapter.py +97 -0
  89. tools/nmap/manifest.toml +159 -0
  90. tools/nuclei/__init__.py +1 -0
  91. tools/nuclei/adapter.py +171 -0
  92. tools/nuclei/manifest.toml +117 -0
  93. tools/searchsploit/__init__.py +1 -0
  94. tools/searchsploit/adapter.py +139 -0
  95. tools/searchsploit/manifest.toml +103 -0
  96. tools/sqlmap/__init__.py +1 -0
  97. tools/sqlmap/adapter.py +214 -0
  98. tools/sqlmap/manifest.toml +89 -0
  99. tools/subfinder/__init__.py +0 -0
  100. tools/subfinder/adapter.py +71 -0
  101. tools/subfinder/manifest.toml +104 -0
  102. tools/whois/__init__.py +0 -0
  103. tools/whois/adapter.py +80 -0
  104. tools/whois/manifest.toml +95 -0
@@ -0,0 +1,302 @@
1
+ """Pure-Python DNS Probe tool adapter."""
2
+
3
+ import json
4
+ import shlex
5
+ import sys
6
+ from typing import Any, AsyncIterator, Dict, List, Optional
7
+
8
+ from ether.common.context import ExecutionContext
9
+ from ether.registry.adapter import ToolAdapter
10
+ from ether.schemas.base import BaseFinding
11
+ from ether.schemas.dns import DnsRecord
12
+ from ether.schemas.network import NetworkHost
13
+
14
+
15
+ class DnsPythonAdapter(ToolAdapter):
16
+ """Adapter for the dnspython query and zone transfer engine."""
17
+
18
+ execution_tier = "coroutine"
19
+
20
+ def validate_install(self) -> bool:
21
+ """Dnspython is a bundled Python dependency, always valid if importable."""
22
+ if "dns.resolver" in sys.modules:
23
+ return True
24
+ try:
25
+ import dns.resolver # noqa: F401
26
+
27
+ return True
28
+ except ImportError:
29
+ return False
30
+
31
+ async def execute_action(
32
+ self,
33
+ target: BaseFinding,
34
+ params: Dict[str, Any],
35
+ context: ExecutionContext,
36
+ ) -> AsyncIterator[BaseFinding]:
37
+ """Execute DNS resolution natively in-process using dns.asyncresolver."""
38
+ import dns.asyncquery
39
+ import dns.asyncresolver
40
+ import dns.rdatatype
41
+ import dns.resolver
42
+ import dns.reversename
43
+ import dns.zone
44
+
45
+ query: Optional[str] = None
46
+ if target.schema_type == "dns.record":
47
+ query = target.pik.get("domain") or target.data.get("domain")
48
+ elif target.schema_type == "network.host":
49
+ query = target.pik.get("ip") or target.data.get("ip")
50
+
51
+ if not query:
52
+ query = params.get("target") or params.get("domain") or params.get("ip")
53
+
54
+ if not query:
55
+ await context.spool_line(
56
+ f"[-] Target {target.schema_type} missing query field (domain/ip)",
57
+ is_error=True,
58
+ )
59
+ return
60
+
61
+ raw_flags = params.get("raw_flags", "").strip()
62
+ flag_args = shlex.split(raw_flags) if raw_flags else []
63
+
64
+ record_types: List[str] = []
65
+ nameserver: Optional[str] = params.get("nameserver")
66
+ timeout: float = float(params.get("timeout", 5.0))
67
+
68
+ # Parse flags
69
+ i = 0
70
+ while i < len(flag_args):
71
+ arg = flag_args[i]
72
+ if arg in ("-t", "--type") and i + 1 < len(flag_args):
73
+ record_types.extend([t.strip().upper() for t in flag_args[i + 1].split(",")])
74
+ i += 2
75
+ elif arg in ("-s", "--server") and i + 1 < len(flag_args):
76
+ nameserver = flag_args[i + 1]
77
+ i += 2
78
+ elif arg.startswith("@"):
79
+ nameserver = arg[1:]
80
+ i += 1
81
+ elif arg in ("--timeout",) and i + 1 < len(flag_args):
82
+ try:
83
+ timeout = float(flag_args[i + 1])
84
+ except ValueError:
85
+ pass
86
+ i += 2
87
+ else:
88
+ i += 1
89
+
90
+ if not record_types:
91
+ if params.get("record_type"):
92
+ record_types = [params["record_type"].upper()]
93
+ elif target.schema_type == "network.host":
94
+ record_types = ["PTR"]
95
+ else:
96
+ record_types = ["A", "AAAA", "MX", "NS", "TXT", "SOA"]
97
+
98
+ resolver = dns.asyncresolver.Resolver()
99
+ resolver.lifetime = timeout
100
+ resolver.timeout = timeout
101
+ if nameserver:
102
+ resolver.nameservers = [nameserver]
103
+
104
+ await context.spool_line(
105
+ f"[*] Native DNS resolution initiated for '{query}' (types: {', '.join(record_types)})"
106
+ )
107
+
108
+ for rtype in record_types:
109
+ if rtype == "PTR":
110
+ try:
111
+ rev_name = dns.reversename.from_address(query)
112
+ await context.spool_line(f"[*] Querying PTR for {rev_name}...")
113
+ answers = await resolver.resolve(rev_name, "PTR")
114
+ for rdata in answers:
115
+ val = str(rdata.target).rstrip(".")
116
+ ttl_sec = int(answers.ttl) if hasattr(answers, "ttl") else 3600
117
+ await context.spool_line(f"[+] {query} PTR {val} (TTL={ttl_sec})")
118
+ yield DnsRecord.create(
119
+ domain=val,
120
+ record_type="PTR",
121
+ value=val,
122
+ resolved_ip=query,
123
+ ttl_seconds=ttl_sec,
124
+ )
125
+ except Exception as e:
126
+ await context.spool_line(
127
+ f"[-] PTR query failed for {query}: {type(e).__name__} ({e})"
128
+ )
129
+ elif rtype == "AXFR":
130
+ ns_servers = [nameserver] if nameserver else []
131
+ if not ns_servers:
132
+ try:
133
+ ns_answers = await resolver.resolve(query, "NS")
134
+ ns_servers = [str(r.target).rstrip(".") for r in ns_answers]
135
+ except Exception as e:
136
+ await context.spool_line(
137
+ f"[-] Failed to discover NS for AXFR: {e}", is_error=True
138
+ )
139
+ for ns in ns_servers:
140
+ await context.spool_line(
141
+ f"[*] Attempting AXFR for {query} against nameserver {ns}..."
142
+ )
143
+ try:
144
+ zone = dns.zone.Zone(query)
145
+ await dns.asyncquery.inbound_xfr(
146
+ where=ns, txn_manager=zone, timeout=timeout
147
+ )
148
+ await context.spool_line(
149
+ f"[+] AXFR SUCCESS: Zone transfer allowed on {ns} for {query}!"
150
+ )
151
+ for name, node in zone.nodes.items():
152
+ rname = str(name)
153
+ full_name = f"{rname}.{query}" if rname != "@" else query
154
+ for rdataset in node.rdatasets:
155
+ r_type_str = dns.rdatatype.to_text(rdataset.rdtype)
156
+ for rdata in rdataset:
157
+ val = str(rdata).rstrip(".")
158
+ ttl_sec = (
159
+ int(rdataset.ttl) if hasattr(rdataset, "ttl") else 3600
160
+ )
161
+ await context.spool_line(
162
+ f" {full_name} {ttl_sec} IN {r_type_str} {val}"
163
+ )
164
+ resolved_ip = val if r_type_str in ("A", "AAAA") else None
165
+ soa_serial = None
166
+ if r_type_str == "SOA":
167
+ parts = val.split()
168
+ if len(parts) >= 3:
169
+ soa_serial = parts[2]
170
+ yield DnsRecord.create(
171
+ domain=full_name,
172
+ record_type=r_type_str,
173
+ value=val,
174
+ resolved_ip=resolved_ip,
175
+ soa_serial=soa_serial,
176
+ ttl_seconds=ttl_sec,
177
+ )
178
+ if resolved_ip:
179
+ yield NetworkHost.create(ip=resolved_ip)
180
+ break
181
+ except Exception as e:
182
+ await context.spool_line(
183
+ f"[-] AXFR failed on {ns}: {type(e).__name__} ({e})"
184
+ )
185
+ else:
186
+ await context.spool_line(f"[*] Querying {rtype} for {query}...")
187
+ try:
188
+ answers = await resolver.resolve(query, rtype)
189
+ ttl_sec = int(answers.ttl) if hasattr(answers, "ttl") else 3600
190
+ for rdata in answers:
191
+ val = str(rdata).rstrip(".")
192
+ soa_serial = None
193
+ if rtype == "SOA":
194
+ try:
195
+ soa_serial = str(rdata.serial)
196
+ except AttributeError:
197
+ parts = val.split()
198
+ if len(parts) >= 3:
199
+ soa_serial = parts[2]
200
+ await context.spool_line(f"[+] {query} {ttl_sec} IN {rtype} {val}")
201
+ resolved_ip = val if rtype in ("A", "AAAA") else None
202
+ yield DnsRecord.create(
203
+ domain=query,
204
+ record_type=rtype,
205
+ value=val,
206
+ resolved_ip=resolved_ip,
207
+ soa_serial=soa_serial,
208
+ ttl_seconds=ttl_sec,
209
+ )
210
+ if resolved_ip:
211
+ yield NetworkHost.create(ip=resolved_ip)
212
+ except dns.resolver.NXDOMAIN:
213
+ await context.spool_line(f"[-] {query} does not exist (NXDOMAIN)")
214
+ break
215
+ except (dns.resolver.NoAnswer, dns.resolver.NoNameservers):
216
+ await context.spool_line(f"[*] No {rtype} record found for {query}")
217
+ except Exception as e:
218
+ await context.spool_line(
219
+ f"[-] Query {rtype} failed for {query}: {type(e).__name__} ({e})"
220
+ )
221
+
222
+ await context.spool_line(f"[*] Native DNS resolution completed for '{query}'")
223
+
224
+ def build_command(self, target: BaseFinding, params: Dict[str, Any]) -> List[str]:
225
+ """Construct the CLI command using Python's module invocation."""
226
+ query: Optional[str] = None
227
+ if target.schema_type == "dns.record":
228
+ query = target.pik.get("domain")
229
+ elif target.schema_type == "network.host":
230
+ query = target.pik.get("ip")
231
+
232
+ raw_flags = params.get("raw_flags", "").strip()
233
+ flag_args = shlex.split(raw_flags) if raw_flags else []
234
+
235
+ # If user did not provide target query inside flags, attach resolved query
236
+ args = [sys.executable, "-m", "tools.dnspython.cli"]
237
+
238
+ if query:
239
+ args.append(query)
240
+ elif not flag_args:
241
+ raise ValueError(
242
+ f"Target finding {target.schema_type} missing query field (domain/ip), and no flags provided."
243
+ )
244
+
245
+ # Enforce json output for reliable programmatic parsing
246
+ if "--json" not in flag_args:
247
+ args.append("--json")
248
+
249
+ args.extend(flag_args)
250
+ return args
251
+
252
+ async def parse_output(
253
+ self, raw_stdout: str, target: BaseFinding, context: Dict[str, Any] = None
254
+ ) -> AsyncIterator[BaseFinding]:
255
+ """Parse structured JSON records into DnsRecord findings."""
256
+ cleaned = raw_stdout.strip()
257
+ if not cleaned:
258
+ return
259
+
260
+ try:
261
+ records = json.loads(cleaned)
262
+ except json.JSONDecodeError:
263
+ # Fallback in case non-JSON diagnostic messages were printed before the JSON block
264
+ start_bracket = cleaned.find("[")
265
+ end_bracket = cleaned.rfind("]")
266
+ if start_bracket != -1 and end_bracket != -1 and end_bracket > start_bracket:
267
+ try:
268
+ records = json.loads(cleaned[start_bracket : end_bracket + 1])
269
+ except json.JSONDecodeError:
270
+ return
271
+ else:
272
+ return
273
+
274
+ if not isinstance(records, list):
275
+ records = [records]
276
+
277
+ for item in records:
278
+ if not isinstance(item, dict):
279
+ continue
280
+ # Skip error notices that did not produce a record value
281
+ if "value" not in item or not item.get("value"):
282
+ continue
283
+
284
+ domain_name = item.get("name", "").rstrip(".")
285
+ rtype = item.get("type", "A").upper()
286
+ val = str(item["value"]).rstrip(".")
287
+ ttl = int(item.get("ttl", 300))
288
+ soa_serial = item.get("serial")
289
+ if not soa_serial and rtype == "SOA":
290
+ parts = val.split()
291
+ if len(parts) >= 3:
292
+ soa_serial = parts[2]
293
+
294
+ resolved_ip = val if rtype == "A" else None
295
+ yield DnsRecord.create(
296
+ domain=domain_name,
297
+ record_type=rtype,
298
+ value=val,
299
+ resolved_ip=resolved_ip,
300
+ soa_serial=soa_serial,
301
+ ttl_seconds=ttl,
302
+ )
tools/dnspython/cli.py ADDED
@@ -0,0 +1,202 @@
1
+ """CLI entrypoint for Ether pure-Python DNS probe."""
2
+
3
+ import argparse
4
+ import json
5
+ import sys
6
+ import time
7
+ from typing import Any, Dict, List, Optional
8
+
9
+ try:
10
+ import dns.exception
11
+ import dns.query
12
+ import dns.resolver
13
+ import dns.reversename
14
+ import dns.zone
15
+ except ImportError:
16
+ dns = None
17
+
18
+
19
+ def resolve_records(
20
+ target: str,
21
+ record_type: str = "A",
22
+ nameserver: Optional[str] = None,
23
+ timeout: float = 5.0,
24
+ ) -> List[Dict[str, Any]]:
25
+ """Resolve DNS records for target using dnspython."""
26
+ if dns is None:
27
+ raise RuntimeError("dnspython library is not installed.")
28
+
29
+ record_type = record_type.upper().strip()
30
+ resolver = dns.resolver.Resolver()
31
+ resolver.lifetime = timeout
32
+ resolver.timeout = timeout
33
+
34
+ if nameserver:
35
+ resolver.nameservers = [nameserver]
36
+
37
+ results: List[Dict[str, Any]] = []
38
+
39
+ # 1. Zone Transfer (AXFR)
40
+ if record_type == "AXFR":
41
+ ns_servers = [nameserver] if nameserver else []
42
+ if not ns_servers:
43
+ # Discover authoritative nameservers first
44
+ try:
45
+ ns_answers = resolver.resolve(target, "NS")
46
+ ns_servers = [str(r.target).rstrip(".") for r in ns_answers]
47
+ except Exception as e:
48
+ return [
49
+ {
50
+ "name": target,
51
+ "type": "AXFR",
52
+ "error": f"Failed to discover NS for AXFR: {e}",
53
+ }
54
+ ]
55
+
56
+ for ns in ns_servers:
57
+ try:
58
+ zone = dns.zone.from_xfr(dns.query.xfr(ns, target, timeout=timeout))
59
+ for name, node in zone.nodes.items():
60
+ rname = str(name)
61
+ full_name = f"{rname}.{target}" if rname != "@" else target
62
+ for rdataset in node.rdatasets:
63
+ rtype = dns.rdatatype.to_text(rdataset.rdtype)
64
+ for rdata in rdataset:
65
+ results.append(
66
+ {
67
+ "name": full_name,
68
+ "type": rtype,
69
+ "ttl": rdataset.ttl,
70
+ "value": str(rdata),
71
+ "server": ns,
72
+ }
73
+ )
74
+ return results
75
+ except Exception as e:
76
+ results.append(
77
+ {
78
+ "name": target,
79
+ "type": "AXFR",
80
+ "error": f"AXFR failed on {ns}: {type(e).__name__} ({e})",
81
+ "server": ns,
82
+ }
83
+ )
84
+ return results
85
+
86
+ # 2. Reverse DNS Lookup (PTR)
87
+ if record_type == "PTR":
88
+ try:
89
+ rev_name = dns.reversename.from_address(target)
90
+ answers = resolver.resolve(rev_name, "PTR")
91
+ for rdata in answers:
92
+ results.append(
93
+ {
94
+ "name": target,
95
+ "type": "PTR",
96
+ "ttl": answers.ttl,
97
+ "value": str(rdata.target).rstrip("."),
98
+ "server": resolver.nameservers[0] if resolver.nameservers else "system",
99
+ }
100
+ )
101
+ except Exception as e:
102
+ results.append(
103
+ {
104
+ "name": target,
105
+ "type": "PTR",
106
+ "error": f"PTR lookup failed: {type(e).__name__} ({e})",
107
+ }
108
+ )
109
+ return results
110
+
111
+ # 3. Standard Record Types (A, AAAA, MX, NS, TXT, SOA, CNAME, etc.)
112
+ try:
113
+ answers = resolver.resolve(target, record_type)
114
+ for rdata in answers:
115
+ val = str(rdata)
116
+ if record_type == "TXT":
117
+ val = "".join(
118
+ s.decode("utf-8", errors="replace") if isinstance(s, bytes) else str(s)
119
+ for s in rdata.strings
120
+ )
121
+ elif record_type == "MX":
122
+ val = f"{rdata.preference} {str(rdata.exchange).rstrip('.')}"
123
+ elif record_type in ("NS", "CNAME"):
124
+ val = val.rstrip(".")
125
+
126
+ results.append(
127
+ {
128
+ "name": target,
129
+ "type": record_type,
130
+ "ttl": answers.ttl,
131
+ "value": val,
132
+ "server": resolver.nameservers[0] if resolver.nameservers else "system",
133
+ }
134
+ )
135
+ except dns.resolver.NXDOMAIN:
136
+ results.append(
137
+ {"name": target, "type": record_type, "error": "NXDOMAIN (Non-Existent Domain)"}
138
+ )
139
+ except dns.resolver.NoAnswer:
140
+ results.append(
141
+ {"name": target, "type": record_type, "error": f"No {record_type} records found."}
142
+ )
143
+ except Exception as e:
144
+ results.append({"name": target, "type": record_type, "error": f"{type(e).__name__}: {e}"})
145
+
146
+ return results
147
+
148
+
149
+ def main(args: Optional[List[str]] = None) -> int:
150
+ parser = argparse.ArgumentParser(description="Ether Pure-Python DNS Probe")
151
+ parser.add_argument("target", help="Domain name or IP address to probe")
152
+ parser.add_argument(
153
+ "-t", "--type", default="A", help="DNS Record Type (A, AAAA, MX, NS, TXT, SOA, PTR, AXFR)"
154
+ )
155
+ parser.add_argument(
156
+ "-s", "--server", default=None, help="Nameserver IP to query (e.g., 8.8.8.8, 1.1.1.1)"
157
+ )
158
+ parser.add_argument("--timeout", type=float, default=5.0, help="Query timeout in seconds")
159
+ parser.add_argument("--json", action="store_true", help="Output records in JSON format")
160
+
161
+ parsed = parser.parse_args(args)
162
+
163
+ start_time = time.time()
164
+ try:
165
+ records = resolve_records(
166
+ target=parsed.target,
167
+ record_type=parsed.type,
168
+ nameserver=parsed.server,
169
+ timeout=parsed.timeout,
170
+ )
171
+ except Exception as e:
172
+ if parsed.json:
173
+ print(json.dumps([{"target": parsed.target, "error": str(e)}], indent=2))
174
+ else:
175
+ print(f";; ERROR: {e}", file=sys.stderr)
176
+ return 1
177
+
178
+ elapsed_ms = int((time.time() - start_time) * 1000)
179
+
180
+ if parsed.json:
181
+ print(json.dumps(records, indent=2))
182
+ return 0
183
+
184
+ # Human-readable dig-style output
185
+ server_str = parsed.server or "system-default"
186
+ print(f"; <<>> Ether DNS Probe (dnspython) <<>> {parsed.target} {parsed.type.upper()}")
187
+ print(f";; SERVER: {server_str}#53")
188
+ print(f";; QUERY TIME: {elapsed_ms} msec")
189
+ print(f";; WHEN: {time.strftime('%Y-%m-%d %H:%M:%S UTC', time.gmtime())}")
190
+ print()
191
+ print(";; ANSWER SECTION:")
192
+ for r in records:
193
+ if "error" in r:
194
+ print(f";; WARNING: {r['name']} {r['type']} -> {r['error']}")
195
+ else:
196
+ print(f"{r['name']}.\t{r.get('ttl', 300)}\tIN\t{r['type']}\t{r['value']}")
197
+
198
+ return 0
199
+
200
+
201
+ if __name__ == "__main__":
202
+ sys.exit(main())
@@ -0,0 +1,138 @@
1
+ [meta]
2
+ name = "dnspython"
3
+ description = "Pure-Python asynchronous DNS resolver, reverse pointer mapping, and zone transfer auditing suite."
4
+ one_line_summary = "zero-binary DNS query and zone auditing engine"
5
+ category = "Network Reconnaissance"
6
+ categories = ["recon", "dns", "osint"]
7
+ binary = ""
8
+ execution_tier = "coroutine"
9
+ theory = """
10
+ ### Protocol Theory & RFC 1034/1035 Architecture
11
+ The Domain Name System (DNS) is a distributed hierarchical database operating over UDP/TCP port 53. dnspython constructs raw socket queries for deep protocol verification.
12
+
13
+ ### Core Record Auditing Mechanics
14
+ * **Resource Records (A, AAAA, PTR)**: Resolves hostnames and validates reverse pointer trees under `in-addr.arpa`.
15
+ * **Mail & Anti-Spoofing (MX, TXT)**:
16
+ - `MX`: Prioritized SMTP mail exchanger routing.
17
+ - `SPF (RFC 7208)`: Defines authorized sender CIDR blocks in TXT records.
18
+ - `DMARC (RFC 7489)`: Enforces policy rules (`p=reject`) against SPF/DKIM validation failures.
19
+ * **Zone Transfers (AXFR - RFC 5936)**: TCP zone replication query that dumps the entire DNS database if nameservers lack transfer ACLs.
20
+
21
+ ### Defensive Hardening & DNSSEC
22
+ * **Strict AXFR ACLs**: Enforce `allow-transfer { none; };` on public nameservers.
23
+ * **DNSSEC (RFC 4033-4035)**: Deploy cryptographic `RRSIG` validation against cache poisoning.
24
+ """
25
+
26
+ [modes]
27
+ learning = true
28
+ power = true
29
+
30
+ [input]
31
+ accepts = ["dns.record", "network.host"]
32
+
33
+ [output]
34
+ produces = ["dns.record"]
35
+
36
+ [learning]
37
+ enabled = true
38
+
39
+ [[learning.recipes]]
40
+ name = "IPv4 Forward Resolution (A Record)"
41
+ difficulty = "Beginner"
42
+ description = "Resolve the primary IPv4 host address mapping for a fully-qualified domain name (FQDN)."
43
+ flags = ["-t", "A"]
44
+
45
+ [learning.recipes.theory]
46
+ concept = "Domain Name System (DNS) Address Resolution (RFC 1035)"
47
+ explanation = """
48
+ DNS translates human-readable hostnames (e.g. example.com) into 32-bit IPv4 addresses required by the IP protocol stack for routing packets across the Internet.
49
+ The client resolver sends a UDP query on port 53 containing an IN (Internet) class and A (Host Address) type question. The recursive resolver walks the root (.), TLD (.com), and authoritative nameservers to fetch the canonical IP.
50
+ """
51
+ packet_wire_summary = "Client UDP:53 -> Query IN A example.com -> Server UDP:53 -> Answer example.com 300 IN A 93.184.216.34"
52
+ remediation = "Ensure DNS records are hosted behind geographically redundant Anycast nameservers with appropriate Time-To-Live (TTL) values."
53
+
54
+ [[learning.recipes]]
55
+ name = "Mail Exchange & Priority Audit (MX)"
56
+ difficulty = "Beginner"
57
+ description = "Enumerate mail server endpoints and their preference weights responsible for accepting inbound SMTP email."
58
+ flags = ["-t", "MX"]
59
+
60
+ [learning.recipes.theory]
61
+ concept = "Simple Mail Transfer Protocol (SMTP) Mail Routing (RFC 5321)"
62
+ explanation = """
63
+ MX records designate the mail transfer agents (MTAs) authorized to receive incoming email for a domain.
64
+ Each MX record includes a numerical preference value (priority). Sending MTAs MUST attempt delivery to the lowest numerical value first, falling back to higher values only when primary hosts are unreachable.
65
+ Attackers inspect backup MX servers because secondary mail relays frequently employ less stringent spam, phishing, and anti-malware filtering.
66
+ """
67
+ packet_wire_summary = "Client Query IN MX example.com -> Response Answer: 10 mail.example.com, 20 backup-mail.example.com"
68
+ remediation = "Harden all secondary and tertiary MX relays with identical perimeter security controls and spam filtering policies as primary servers."
69
+
70
+ [[learning.recipes]]
71
+ name = "Authoritative Nameserver Chain (NS)"
72
+ difficulty = "Intermediate"
73
+ description = "Identify the authoritative nameservers delegated to manage the target DNS zone."
74
+ flags = ["-t", "NS"]
75
+
76
+ [learning.recipes.theory]
77
+ concept = "DNS Delegation & Authority Hierarchy (RFC 1034 / RFC 2182)"
78
+ explanation = """
79
+ NS records indicate which servers maintain the master zone database and authoritatively answer queries for the domain.
80
+ During reconnaissance, mapping nameservers reveals cloud providers, DNS hosting infrastructure (e.g., AWS Route53, Cloudflare), and potential subdomain takeover vulnerabilities caused by dangling delegations.
81
+ """
82
+ packet_wire_summary = "Client Query IN NS example.com -> Response: a.iana-servers.net, b.iana-servers.net"
83
+ remediation = "Audit NS delegations continuously to prevent dangling NS pointers that enable subdomain takeovers."
84
+
85
+ [[learning.recipes]]
86
+ name = "Anti-Spoofing & SPF Verification (TXT)"
87
+ difficulty = "Intermediate"
88
+ description = "Audit domain TXT records to evaluate Sender Policy Framework (SPF), DKIM, and DMARC email spoofing protections."
89
+ flags = ["-t", "TXT"]
90
+
91
+ [learning.recipes.theory]
92
+ concept = "Email Sender Authentication & Policy Enforcement (RFC 7208 / RFC 7489)"
93
+ explanation = """
94
+ TXT records store arbitrary human- and machine-readable text associated with a domain. Modern email authentication relies heavily on TXT records:
95
+ 1. SPF (v=spf1): Explicitly lists IP ranges and MX hosts permitted to send email originating from the domain.
96
+ 2. DMARC (v=DMARC1): Defines alignment policies (none, quarantine, reject) instructing receiving servers how to handle messages failing SPF/DKIM.
97
+ A missing or permissive SPF policy (+all or ~all without DMARC) allows threat actors to forge emails impersonating company executives and services.
98
+ """
99
+ packet_wire_summary = "Client Query IN TXT example.com -> Response: \"v=spf1 -all\""
100
+ remediation = "Implement a strict SPF record ending in '-all' coupled with an enforced DMARC policy ('p=reject')."
101
+
102
+ [[learning.recipes]]
103
+ name = "Reverse DNS Pointer Mapping (PTR)"
104
+ difficulty = "Intermediate"
105
+ description = "Perform reverse DNS resolution to map an IP address back to its registered hostname via in-addr.arpa."
106
+ flags = ["-t", "PTR"]
107
+
108
+ [learning.recipes.theory]
109
+ concept = "Reverse DNS Resolution & in-addr.arpa / ip6.arpa (RFC 1035)"
110
+ explanation = """
111
+ Reverse DNS queries translate an IP address into a domain name by reversing the IP octets and appending the special '.in-addr.arpa' domain (e.g., 93.184.216.34 -> 34.216.184.93.in-addr.arpa).
112
+ Comparing forward A records and reverse PTR records (Forward-Confirmed reverse DNS / FCrDNS) is a primary verification check used by mail servers and network logging systems to detect IP spoofing.
113
+ """
114
+ packet_wire_summary = "Client Query IN PTR 34.216.184.93.in-addr.arpa -> Response: example.com."
115
+ remediation = "Maintain synchronized forward (A) and reverse (PTR) DNS records for all public server interfaces."
116
+
117
+ [[learning.recipes]]
118
+ name = "Full Zone Transfer Audit (AXFR)"
119
+ difficulty = "Advanced"
120
+ description = "Attempt an Authoritative Zone Transfer (AXFR) to test for DNS zone exposure and full internal network disclosure."
121
+ flags = ["-t", "AXFR"]
122
+
123
+ [learning.recipes.theory]
124
+ concept = "DNS Zone Transfer Protocol & Replication Vulnerability (RFC 5936)"
125
+ explanation = """
126
+ AXFR operates over TCP port 53 and was engineered for master nameservers to replicate complete zone data to secondary nameservers.
127
+ If a nameserver is misconfigured to allow AXFR requests from any IP address (rather than restricted slave IPs), any attacker can download the entire internal topology, including unannounced hostnames, staging environments, VPN gateways, and private addresses with a single query.
128
+ """
129
+ packet_wire_summary = "Client TCP:53 -> Connect -> Query IN AXFR target.com -> Server TCP:53 -> Replicates ALL Zone Records (or Refused)"
130
+ remediation = "Restrict AXFR zone transfers strictly to trusted secondary nameserver IP addresses via ACLs or TSIG keys."
131
+
132
+ [power]
133
+ enabled = true
134
+ suggests = [
135
+ { target = "dns.record", condition = "type == 'A'", tool = "nmap", flags = "-sV -Pn" },
136
+ { target = "dns.record", condition = "type == 'A'", tool = "gobuster", flags = "dir -u http://{target.pik.domain}" },
137
+ { target = "dns.record", condition = "type == 'NS'", tool = "whois", flags = "{target.data.value}" }
138
+ ]
tools/ffuf/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """FFUF tool package."""