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,61 @@
1
+ """Handlers for 'ether session' subcommands."""
2
+
3
+ from typing import Any
4
+
5
+ from ether.cli.context import EXIT_SUCCESS, CliContext
6
+ from ether.cli.formatters import print_json, print_table
7
+
8
+
9
+ async def handle_session_list(args: Any, context: CliContext) -> int:
10
+ """List investigation sessions in the database."""
11
+ workspace_id = getattr(args, "workspace_id", None)
12
+
13
+ async with context.open_store() as store:
14
+ if workspace_id:
15
+ sessions = await store.list_sessions(workspace_id)
16
+ else:
17
+ # Query all sessions across all workspaces
18
+ async with store.connection() as db:
19
+ import aiosqlite
20
+
21
+ db.row_factory = aiosqlite.Row
22
+ cursor = await db.execute("SELECT * FROM sessions ORDER BY created_at DESC")
23
+ rows = await cursor.fetchall()
24
+ sessions = [dict(r) for r in rows]
25
+
26
+ if context.is_json:
27
+ print_json(sessions)
28
+ return EXIT_SUCCESS
29
+
30
+ headers = ["SESSION ID", "WORKSPACE ID", "NAME", "CREATED AT"]
31
+ rows = [
32
+ [
33
+ s.get("id", ""),
34
+ s.get("workspace_id", ""),
35
+ s.get("name", ""),
36
+ str(s.get("created_at", ""))[:19],
37
+ ]
38
+ for s in sessions
39
+ ]
40
+ print_table(headers, rows)
41
+ return EXIT_SUCCESS
42
+
43
+
44
+ async def handle_session_create(args: Any, context: CliContext) -> int:
45
+ """Create a new investigation session."""
46
+ name = getattr(args, "name", "New Session")
47
+ workspace_id = getattr(args, "workspace_id", None)
48
+
49
+ async with context.open_store() as store:
50
+ if not workspace_id:
51
+ ws_id, sess_id = await store.get_or_create_default_session()
52
+ workspace_id = ws_id
53
+
54
+ sess_id = await store.create_session(workspace_id, name)
55
+
56
+ if context.is_json:
57
+ print_json({"session_id": sess_id, "workspace_id": workspace_id, "name": name})
58
+ else:
59
+ print(f"[+] Created session '{name}' (ID: {sess_id}) in workspace '{workspace_id}'")
60
+
61
+ return EXIT_SUCCESS
@@ -0,0 +1,51 @@
1
+ """Handlers for 'ether telemetry' subcommands."""
2
+
3
+ from typing import Any
4
+
5
+ from ether.cli.context import EXIT_RUNTIME_ERROR, EXIT_SUCCESS, CliContext
6
+ from ether.cli.formatters import print_error, print_json
7
+ from ether.graph.telemetry import GraphTelemetryCompiler
8
+
9
+
10
+ async def handle_telemetry_snapshot(args: Any, context: CliContext) -> int:
11
+ """Compile token-budgeted agent telemetry snapshot for a session."""
12
+ session_id = getattr(args, "session_id", None)
13
+ if not session_id:
14
+ print_error("session_id is required.")
15
+ return EXIT_RUNTIME_ERROR
16
+
17
+ max_tokens = int(getattr(args, "max_tokens", 4000))
18
+ selected_entity_id = getattr(args, "entity_id", None)
19
+
20
+ async with context.open_store() as store:
21
+ compiler = GraphTelemetryCompiler(store, session_id)
22
+ try:
23
+ snapshot = await compiler.compile_telemetry_snapshot(
24
+ selected_entity_id=selected_entity_id, max_tokens=max_tokens
25
+ )
26
+ except Exception as e:
27
+ print_error(f"Failed to compile telemetry snapshot: {e}")
28
+ return EXIT_RUNTIME_ERROR
29
+
30
+ print_json(snapshot)
31
+ return EXIT_SUCCESS
32
+
33
+
34
+ async def handle_telemetry_diff(args: Any, context: CliContext) -> int:
35
+ """Compute zero-token semantic graph delta by action_id or since a baseline timestamp."""
36
+ session_id = getattr(args, "session_id", None)
37
+ baseline = getattr(args, "baseline", None)
38
+ action_id = getattr(args, "action_id", None)
39
+ if not session_id:
40
+ print_error("session_id is required.")
41
+ return EXIT_RUNTIME_ERROR
42
+ if baseline is None and action_id is None:
43
+ print_error("Either --action-id or --baseline timestamp is required.")
44
+ return EXIT_RUNTIME_ERROR
45
+
46
+ async with context.open_store() as store:
47
+ compiler = GraphTelemetryCompiler(store, session_id)
48
+ diff = await compiler.compute_graph_diff(baseline_timestamp=baseline, action_id=action_id)
49
+
50
+ print_json(diff)
51
+ return EXIT_SUCCESS
@@ -0,0 +1,131 @@
1
+ """Handlers for 'ether tool' subcommands."""
2
+
3
+ import shutil
4
+ from typing import Any
5
+
6
+ from ether.cli.context import EXIT_RUNTIME_ERROR, EXIT_SUCCESS, CliContext
7
+ from ether.cli.formatters import print_error, print_json, print_table
8
+
9
+
10
+ def handle_tool_list(args: Any, context: CliContext) -> int:
11
+ """List all available tool adapters in ToolRegistry."""
12
+ registry = context.get_registry()
13
+ tools = registry.list_tools()
14
+
15
+ if context.is_json:
16
+ result = []
17
+ for name in sorted(tools):
18
+ data = registry.get_tool(name)
19
+ manifest = data.get("manifest") if data else None
20
+ adapter = data.get("adapter") if data else None
21
+ meta = getattr(manifest, "meta", None)
22
+ tier = getattr(meta, "execution_tier", "subprocess") if meta else "subprocess"
23
+ binary = getattr(meta, "binary", name) if meta else name
24
+
25
+ if tier == "coroutine":
26
+ is_installed = adapter.validate_install() if adapter else True
27
+ display_bin = binary or "native"
28
+ else:
29
+ is_installed = shutil.which(binary) is not None if binary else False
30
+ display_bin = binary or name
31
+
32
+ result.append(
33
+ {
34
+ "name": name,
35
+ "binary": display_bin,
36
+ "tier": tier,
37
+ "execution_tier": tier,
38
+ "installed": is_installed,
39
+ "category": getattr(meta, "category", "general") if meta else "general",
40
+ "description": getattr(meta, "description", "") if meta else "",
41
+ }
42
+ )
43
+ print_json(result)
44
+ return EXIT_SUCCESS
45
+
46
+ headers = ["TOOL", "TIER", "BINARY", "INSTALLED", "CATEGORY", "DESCRIPTION"]
47
+ rows = []
48
+ for name in sorted(tools):
49
+ data = registry.get_tool(name)
50
+ manifest = data.get("manifest") if data else None
51
+ adapter = data.get("adapter") if data else None
52
+ meta = getattr(manifest, "meta", None)
53
+ tier = getattr(meta, "execution_tier", "subprocess") if meta else "subprocess"
54
+ binary = getattr(meta, "binary", name) if meta else name
55
+
56
+ if tier == "coroutine":
57
+ is_installed = "yes" if (adapter and adapter.validate_install()) else "yes"
58
+ display_bin = binary or "native"
59
+ else:
60
+ is_installed = "yes" if (binary and shutil.which(binary)) else "no"
61
+ display_bin = binary or name
62
+
63
+ cat = getattr(meta, "category", "general") if meta else "general"
64
+ desc = getattr(meta, "description", "") if meta else ""
65
+ if len(desc) > 50:
66
+ desc = desc[:47] + "..."
67
+ rows.append([name, tier, display_bin, is_installed, cat, desc])
68
+
69
+ print_table(headers, rows)
70
+ return EXIT_SUCCESS
71
+
72
+
73
+ def handle_tool_info(args: Any, context: CliContext) -> int:
74
+ """Display detailed manifest and capabilities for a specific tool."""
75
+ tool_name = getattr(args, "name", None)
76
+ if not tool_name:
77
+ print_error("Tool name is required.")
78
+ return EXIT_RUNTIME_ERROR
79
+
80
+ registry = context.get_registry()
81
+ data = registry.get_tool(tool_name)
82
+ if not data or not data.get("manifest"):
83
+ print_error(f"Tool '{tool_name}' not found.")
84
+ return EXIT_RUNTIME_ERROR
85
+
86
+ manifest = data["manifest"]
87
+ meta = getattr(manifest, "meta", None)
88
+ tier = getattr(meta, "execution_tier", "subprocess") if meta else "subprocess"
89
+ binary = getattr(meta, "binary", tool_name) if meta else tool_name
90
+ bin_path = shutil.which(binary) if binary else None
91
+ adapter = data.get("adapter")
92
+ is_installed = (
93
+ adapter.validate_install() if (tier == "coroutine" and adapter) else (bin_path is not None)
94
+ )
95
+
96
+ info = {
97
+ "name": tool_name,
98
+ "tier": tier,
99
+ "execution_tier": tier,
100
+ "binary": binary or "native",
101
+ "binary_path": bin_path,
102
+ "installed": is_installed,
103
+ "category": getattr(meta, "category", "general") if meta else "general",
104
+ "description": getattr(meta, "description", "") if meta else "",
105
+ "input_accepts": getattr(manifest.input, "accepts", [])
106
+ if hasattr(manifest, "input")
107
+ else [],
108
+ "output_emits": getattr(manifest.output, "emits", [])
109
+ if hasattr(manifest, "output")
110
+ else [],
111
+ }
112
+
113
+ if context.is_json:
114
+ print_json(info)
115
+ else:
116
+ print(f"Tool: {info['name']}")
117
+ print(f"Tier: {info['tier']}")
118
+ if tier == "coroutine":
119
+ print(
120
+ f"Execution: Native Async Coroutine ({'Ready' if is_installed else 'Dependencies missing'})"
121
+ )
122
+ else:
123
+ print(
124
+ f"Binary: {info['binary']} ({'Installed: ' + str(bin_path) if bin_path else 'NOT FOUND'})"
125
+ )
126
+ print(f"Category: {info['category']}")
127
+ print(f"Description: {info['description']}")
128
+ print(f"Input: {', '.join(info['input_accepts']) or 'None'}")
129
+ print(f"Output: {', '.join(info['output_emits']) or 'None'}")
130
+
131
+ return EXIT_SUCCESS
ether/cli/context.py ADDED
@@ -0,0 +1,71 @@
1
+ """CLI runtime execution context and resource lifecycle management for Ether."""
2
+
3
+ from contextlib import asynccontextmanager
4
+ from dataclasses import dataclass
5
+ from typing import AsyncIterator, Optional
6
+
7
+ from ether import paths
8
+ from ether.gateway.gate import GatePolicy
9
+ from ether.graph.store import GraphStore
10
+ from ether.registry.registry import ToolRegistry
11
+
12
+ EXIT_SUCCESS = 0
13
+ EXIT_RUNTIME_ERROR = 1
14
+ EXIT_USAGE_ERROR = 2
15
+ EXIT_MISSING_DEP = 127
16
+
17
+
18
+ @dataclass(frozen=True)
19
+ class CliContext:
20
+ """Encapsulates runtime parameters, database paths, and execution policy."""
21
+
22
+ data_dir: str
23
+ db_path: str
24
+ tools_dir: Optional[str]
25
+ is_json: bool
26
+ verbose: bool
27
+ policy: GatePolicy
28
+
29
+ @classmethod
30
+ def from_args(cls, args) -> "CliContext":
31
+ """Resolve CLI arguments into an immutable runtime context."""
32
+ data_dir_arg = getattr(args, "data_dir", None)
33
+ db_arg = getattr(args, "db", None)
34
+ tools_arg = getattr(args, "tools", None)
35
+
36
+ data_dir = data_dir_arg or paths.get_default_data_dir()
37
+ db_path = db_arg or paths.get_default_db_path(data_dir)
38
+
39
+ is_json = bool(getattr(args, "json", False))
40
+ verbose = bool(getattr(args, "verbose", False))
41
+
42
+ policy_str = getattr(args, "policy", "safe")
43
+ if str(policy_str).lower() == "unrestricted":
44
+ policy = GatePolicy.UNRESTRICTED
45
+ else:
46
+ policy = GatePolicy.SAFE
47
+
48
+ return cls(
49
+ data_dir=data_dir,
50
+ db_path=db_path,
51
+ tools_dir=tools_arg,
52
+ is_json=is_json,
53
+ verbose=verbose,
54
+ policy=policy,
55
+ )
56
+
57
+ @asynccontextmanager
58
+ async def open_store(self) -> AsyncIterator[GraphStore]:
59
+ """Context manager guaranteeing initialized GraphStore and clean teardown."""
60
+ store = GraphStore(self.db_path)
61
+ await store.initialize()
62
+ try:
63
+ yield store
64
+ finally:
65
+ await store.close()
66
+
67
+ def get_registry(self) -> ToolRegistry:
68
+ """Instantiate and load ToolRegistry."""
69
+ registry = ToolRegistry(tools_dir=self.tools_dir)
70
+ registry.load_tools()
71
+ return registry
@@ -0,0 +1,39 @@
1
+ """Headless terminal text styling and JSON formatting for Ether CLI."""
2
+
3
+ import json
4
+ import sys
5
+ from typing import Any, List
6
+
7
+
8
+ def print_json(data: Any) -> None:
9
+ """Output machine-readable formatted JSON to stdout."""
10
+ print(json.dumps(data, indent=2, default=str), file=sys.stdout)
11
+
12
+
13
+ def print_error(msg: str) -> None:
14
+ """Output an error message to stderr."""
15
+ print(f"[!] Error: {msg}", file=sys.stderr)
16
+
17
+
18
+ def print_table(headers: List[str], rows: List[List[str]]) -> None:
19
+ """Format and print a simple ASCII table to stdout."""
20
+ if not headers:
21
+ return
22
+
23
+ # Calculate column widths
24
+ col_widths = [len(h) for h in headers]
25
+ for row in rows:
26
+ for idx, val in enumerate(row):
27
+ if idx < len(col_widths):
28
+ col_widths[idx] = max(col_widths[idx], len(str(val)))
29
+
30
+ # Format header
31
+ header_str = " ".join(f"{h:<{col_widths[i]}}" for i, h in enumerate(headers))
32
+ sep_str = " ".join("-" * col_widths[i] for i in range(len(headers)))
33
+ print(header_str)
34
+ print(sep_str)
35
+
36
+ # Format rows
37
+ for row in rows:
38
+ row_str = " ".join(f"{str(val):<{col_widths[i]}}" for i, val in enumerate(row))
39
+ print(row_str)