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
ether/schemas/base.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# PROTECTED FILE — See CONTRIBUTING.md before modifying.
|
|
2
|
+
# Changes to this file require team agreement.
|
|
3
|
+
"""Foundational Pydantic models for Ether findings."""
|
|
4
|
+
|
|
5
|
+
from datetime import UTC, datetime
|
|
6
|
+
from typing import Any, ClassVar, Dict, List, Literal, Optional
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, Field, field_validator, model_validator
|
|
9
|
+
|
|
10
|
+
from ether.common.canonicalize import canonicalize_mapping
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Relation(BaseModel):
|
|
14
|
+
"""Represents an edge in the entity graph."""
|
|
15
|
+
|
|
16
|
+
target_type: str # e.g. "network.host"
|
|
17
|
+
target_pik: Dict[str, Any] # The PIK fields of the target entity
|
|
18
|
+
via: str # Relationship name, e.g. "has_service"
|
|
19
|
+
|
|
20
|
+
@field_validator("target_pik", mode="before")
|
|
21
|
+
@classmethod
|
|
22
|
+
def apply_canonicalization(cls, v: Any) -> Any:
|
|
23
|
+
if isinstance(v, dict):
|
|
24
|
+
return canonicalize_mapping(v)
|
|
25
|
+
return v
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class BaseFinding(BaseModel):
|
|
29
|
+
"""The base finding structure all schemas must follow."""
|
|
30
|
+
|
|
31
|
+
schema_type: str # e.g. "network.service"
|
|
32
|
+
schema_version: str = "1.0"
|
|
33
|
+
pik_fields: ClassVar[List[str]] = [] # Declarative PIK fields for registry/linter
|
|
34
|
+
pik: Dict[str, Any] # Primary Identity Key fields
|
|
35
|
+
parent: Optional[Relation] = None
|
|
36
|
+
associations: List[Relation] = Field(default_factory=list)
|
|
37
|
+
data: Dict[str, Any] # Additional finding data
|
|
38
|
+
timestamp: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
39
|
+
status: Literal["proposed", "confirmed", "flapping", "stale"] = "confirmed"
|
|
40
|
+
ttl_seconds: int = 3600
|
|
41
|
+
anchor_hash: Optional[str] = None
|
|
42
|
+
last_seen_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def from_data(
|
|
46
|
+
cls,
|
|
47
|
+
data: Dict[str, Any],
|
|
48
|
+
parent: Optional[Relation] = None,
|
|
49
|
+
associations: Optional[List[Relation]] = None,
|
|
50
|
+
status: Literal["proposed", "confirmed", "flapping", "stale"] = "confirmed",
|
|
51
|
+
ttl_seconds: int = 3600,
|
|
52
|
+
anchor_hash: Optional[str] = None,
|
|
53
|
+
) -> "BaseFinding":
|
|
54
|
+
"""Construct a finding instance deriving its PIK automatically from class pik_fields."""
|
|
55
|
+
pik = {k: data[k] for k in cls.pik_fields if k in data}
|
|
56
|
+
return cls(
|
|
57
|
+
pik=pik,
|
|
58
|
+
parent=parent,
|
|
59
|
+
associations=associations or [],
|
|
60
|
+
data=data,
|
|
61
|
+
status=status,
|
|
62
|
+
ttl_seconds=ttl_seconds,
|
|
63
|
+
anchor_hash=anchor_hash,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
@field_validator("pik", "data", mode="before")
|
|
67
|
+
@classmethod
|
|
68
|
+
def apply_canonicalization(cls, v: Any) -> Any:
|
|
69
|
+
"""Apply declarative normalization filters to PIK and data dictionary fields."""
|
|
70
|
+
if isinstance(v, dict):
|
|
71
|
+
return canonicalize_mapping(v)
|
|
72
|
+
return v
|
|
73
|
+
|
|
74
|
+
@model_validator(mode="before")
|
|
75
|
+
@classmethod
|
|
76
|
+
def resolve_anchor_hash(cls, values: Any) -> Any:
|
|
77
|
+
"""Derive cryptographic anchor_hash from data dictionary if not explicitly provided."""
|
|
78
|
+
if isinstance(values, dict):
|
|
79
|
+
if not values.get("anchor_hash"):
|
|
80
|
+
inner_data = values.get("data")
|
|
81
|
+
if isinstance(inner_data, dict):
|
|
82
|
+
for key in (
|
|
83
|
+
"anchor_hash",
|
|
84
|
+
"tls_cert_sha256",
|
|
85
|
+
"ssh_hostkey_fingerprint",
|
|
86
|
+
"favicon_hash",
|
|
87
|
+
"soa_serial",
|
|
88
|
+
):
|
|
89
|
+
val = inner_data.get(key)
|
|
90
|
+
if val:
|
|
91
|
+
prefix = (
|
|
92
|
+
"tls"
|
|
93
|
+
if "tls" in key
|
|
94
|
+
else (
|
|
95
|
+
"ssh"
|
|
96
|
+
if "ssh" in key
|
|
97
|
+
else (
|
|
98
|
+
"favicon"
|
|
99
|
+
if "favicon" in key
|
|
100
|
+
else ("soa" if "soa" in key else "")
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
values["anchor_hash"] = (
|
|
105
|
+
f"{prefix}:{val}"
|
|
106
|
+
if prefix and not str(val).startswith(f"{prefix}:")
|
|
107
|
+
else str(val)
|
|
108
|
+
)
|
|
109
|
+
break
|
|
110
|
+
return values
|
|
111
|
+
|
|
112
|
+
def to_semantic_text(self) -> str:
|
|
113
|
+
"""Produce a concise, human-readable semantic text description for vector embedding."""
|
|
114
|
+
pik_desc = ", ".join(f"{k}={v}" for k, v in self.pik.items())
|
|
115
|
+
data_desc = ", ".join(
|
|
116
|
+
f"{k}={v}"
|
|
117
|
+
for k, v in self.data.items()
|
|
118
|
+
if k not in self.pik and v is not None and str(v).strip()
|
|
119
|
+
)
|
|
120
|
+
if data_desc:
|
|
121
|
+
return f"{self.schema_type}: {pik_desc}. Data: {data_desc}."
|
|
122
|
+
return f"{self.schema_type}: {pik_desc}."
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Credential finding schemas."""
|
|
2
|
+
|
|
3
|
+
from typing import ClassVar, Optional
|
|
4
|
+
|
|
5
|
+
from ether.schemas.base import BaseFinding, Relation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CredentialFound(BaseFinding):
|
|
9
|
+
"""A username/password or token discovery. Linked to a host or domain. Produced by hydra, medusa, leak-lookups."""
|
|
10
|
+
|
|
11
|
+
schema_type: str = "credential.found"
|
|
12
|
+
pik_fields: ClassVar[list[str]] = ["context", "username"]
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def create(
|
|
16
|
+
cls,
|
|
17
|
+
context: str,
|
|
18
|
+
username: str,
|
|
19
|
+
password: Optional[str] = None,
|
|
20
|
+
host_ip: Optional[str] = None,
|
|
21
|
+
**kwargs,
|
|
22
|
+
):
|
|
23
|
+
parent = None
|
|
24
|
+
if host_ip:
|
|
25
|
+
parent = Relation(
|
|
26
|
+
target_type="network.host",
|
|
27
|
+
target_pik={"ip": host_ip},
|
|
28
|
+
via="credential_for_host",
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
return cls(
|
|
32
|
+
pik={"context": context, "username": username},
|
|
33
|
+
parent=parent,
|
|
34
|
+
data={
|
|
35
|
+
"context": context,
|
|
36
|
+
"username": username,
|
|
37
|
+
"password": password,
|
|
38
|
+
"host_ip": host_ip,
|
|
39
|
+
**kwargs,
|
|
40
|
+
},
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def to_semantic_text(self) -> str:
|
|
44
|
+
username = self.pik.get("username") or self.data.get("username", "")
|
|
45
|
+
context = self.pik.get("context") or self.data.get("context", "")
|
|
46
|
+
host_ip = self.data.get("host_ip")
|
|
47
|
+
parts = [f"Credential discovered for user '{username}' in context '{context}'"]
|
|
48
|
+
if host_ip:
|
|
49
|
+
parts.append(f"Host: {host_ip}")
|
|
50
|
+
return ". ".join(parts) + "."
|
ether/schemas/dns.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""DNS and Domain related schemas."""
|
|
2
|
+
|
|
3
|
+
from typing import ClassVar, List, Optional
|
|
4
|
+
|
|
5
|
+
from ether.schemas.base import BaseFinding, Relation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class DnsRecord(BaseFinding):
|
|
9
|
+
"""A single DNS entry mapping a name to a value. Produced by dig, whois, or passive DNS tools."""
|
|
10
|
+
|
|
11
|
+
schema_type: str = "dns.record"
|
|
12
|
+
pik_fields: ClassVar[List[str]] = ["domain", "type", "value"]
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def create(
|
|
16
|
+
cls,
|
|
17
|
+
domain: str,
|
|
18
|
+
record_type: str,
|
|
19
|
+
value: str,
|
|
20
|
+
resolved_ip: Optional[str] = None,
|
|
21
|
+
soa_serial: Optional[str] = None,
|
|
22
|
+
ttl_seconds: Optional[int] = None,
|
|
23
|
+
anchor_hash: Optional[str] = None,
|
|
24
|
+
**kwargs,
|
|
25
|
+
):
|
|
26
|
+
pik = {
|
|
27
|
+
"domain": domain.lower().strip(),
|
|
28
|
+
"type": record_type.upper(),
|
|
29
|
+
"value": value.strip(),
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
associations = []
|
|
33
|
+
if resolved_ip:
|
|
34
|
+
associations.append(
|
|
35
|
+
Relation(
|
|
36
|
+
target_type="network.host", target_pik={"ip": resolved_ip}, via="resolves_to"
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
data = {**pik, "resolved_ip": resolved_ip, **kwargs}
|
|
41
|
+
if soa_serial:
|
|
42
|
+
data["soa_serial"] = soa_serial
|
|
43
|
+
if not anchor_hash:
|
|
44
|
+
anchor_hash = (
|
|
45
|
+
f"soa:{soa_serial}"
|
|
46
|
+
if not str(soa_serial).startswith("soa:")
|
|
47
|
+
else str(soa_serial)
|
|
48
|
+
)
|
|
49
|
+
elif record_type.upper() == "SOA" and not anchor_hash:
|
|
50
|
+
data["soa_serial"] = value.strip()
|
|
51
|
+
anchor_hash = f"soa:{value.strip()}"
|
|
52
|
+
|
|
53
|
+
return cls(
|
|
54
|
+
pik=pik,
|
|
55
|
+
associations=associations,
|
|
56
|
+
data=data,
|
|
57
|
+
ttl_seconds=ttl_seconds if ttl_seconds is not None else 3600,
|
|
58
|
+
anchor_hash=anchor_hash,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
def to_semantic_text(self) -> str:
|
|
62
|
+
domain = self.pik.get("domain") or self.data.get("domain", "")
|
|
63
|
+
rec_type = self.pik.get("type") or self.data.get("type", "")
|
|
64
|
+
val = self.pik.get("value") or self.data.get("value", "")
|
|
65
|
+
resolved_ip = self.data.get("resolved_ip")
|
|
66
|
+
parts = [f"DNS Record: {domain} {rec_type} {val}"]
|
|
67
|
+
if resolved_ip:
|
|
68
|
+
parts.append(f"Resolved IP: {resolved_ip}")
|
|
69
|
+
return ". ".join(parts) + "."
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class DomainInfo(BaseFinding):
|
|
73
|
+
"""Whois registration data for a domain — owner, registrar, dates. Produced by whois."""
|
|
74
|
+
|
|
75
|
+
schema_type: str = "domain.info"
|
|
76
|
+
pik_fields: ClassVar[List[str]] = ["domain"]
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def create(
|
|
80
|
+
cls, domain: str, registrar: Optional[str] = None, organization: Optional[str] = None
|
|
81
|
+
):
|
|
82
|
+
pik = {"domain": domain.lower().strip()}
|
|
83
|
+
|
|
84
|
+
# Link to the broad dns.record namespace for this domain
|
|
85
|
+
associations = [
|
|
86
|
+
Relation(
|
|
87
|
+
target_type="dns.record",
|
|
88
|
+
target_pik={"domain": pik["domain"], "type": "ANY", "value": "ANY"},
|
|
89
|
+
via="whois_data_for",
|
|
90
|
+
)
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
return cls(
|
|
94
|
+
pik=pik,
|
|
95
|
+
associations=associations,
|
|
96
|
+
data={**pik, "registrar": registrar, "organization": organization},
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class EntityAlias(BaseFinding):
|
|
101
|
+
"""Links two identifiers that represent the same entity (e.g. hostname to IP). Produced by resolvers."""
|
|
102
|
+
|
|
103
|
+
schema_type: str = "entity.alias"
|
|
104
|
+
pik_fields: ClassVar[List[str]] = ["source_id", "target_id"]
|
|
105
|
+
|
|
106
|
+
@classmethod
|
|
107
|
+
def create(cls, source_id: str, target_id: str, relation_type: str = "alias_of", **kwargs):
|
|
108
|
+
# Links two existing entities (e.g. hostname to IP)
|
|
109
|
+
return cls.from_data(
|
|
110
|
+
{
|
|
111
|
+
"source_id": source_id,
|
|
112
|
+
"target_id": target_id,
|
|
113
|
+
"relation_type": relation_type,
|
|
114
|
+
**kwargs,
|
|
115
|
+
}
|
|
116
|
+
)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""Host-internal finding schemas (processes, files, packages)."""
|
|
2
|
+
|
|
3
|
+
from typing import ClassVar, Optional
|
|
4
|
+
|
|
5
|
+
from ether.schemas.base import BaseFinding, Relation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ProcessRunning(BaseFinding):
|
|
9
|
+
"""A running process on a host. Child of network.host. Produced by ps, netstat."""
|
|
10
|
+
|
|
11
|
+
schema_type: str = "process.running"
|
|
12
|
+
pik_fields: ClassVar[list[str]] = ["host_ip", "pid"]
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def create(cls, host_ip: str, pid: int, name: str, **kwargs):
|
|
16
|
+
return cls.from_data(
|
|
17
|
+
{"host_ip": host_ip, "pid": pid, "name": name, **kwargs},
|
|
18
|
+
parent=Relation(
|
|
19
|
+
target_type="network.host", target_pik={"ip": host_ip}, via="hosts_process"
|
|
20
|
+
),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class FileSystemObject(BaseFinding):
|
|
25
|
+
"""A file or directory found on a host. Child of network.host. Produced by find, ls."""
|
|
26
|
+
|
|
27
|
+
schema_type: str = "file.system_object"
|
|
28
|
+
pik_fields: ClassVar[list[str]] = ["host_ip", "path"]
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def create(cls, host_ip: str, path: str, **kwargs):
|
|
32
|
+
return cls.from_data(
|
|
33
|
+
{"host_ip": host_ip, "path": path, **kwargs},
|
|
34
|
+
parent=Relation(
|
|
35
|
+
target_type="network.host", target_pik={"ip": host_ip}, via="hosts_file"
|
|
36
|
+
),
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class SoftwarePackage(BaseFinding):
|
|
41
|
+
"""An installed software package. Child of network.host. Produced by dpkg, rpm, brew."""
|
|
42
|
+
|
|
43
|
+
schema_type: str = "software.package"
|
|
44
|
+
pik_fields: ClassVar[list[str]] = ["host_ip", "package_name"]
|
|
45
|
+
|
|
46
|
+
@classmethod
|
|
47
|
+
def create(cls, host_ip: str, package_name: str, version: Optional[str] = None, **kwargs):
|
|
48
|
+
return cls.from_data(
|
|
49
|
+
{
|
|
50
|
+
"host_ip": host_ip,
|
|
51
|
+
"package_name": package_name,
|
|
52
|
+
"version": version,
|
|
53
|
+
**kwargs,
|
|
54
|
+
},
|
|
55
|
+
parent=Relation(
|
|
56
|
+
target_type="network.host", target_pik={"ip": host_ip}, via="hosts_software"
|
|
57
|
+
),
|
|
58
|
+
)
|
ether/schemas/network.py
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"""Network-related finding schemas."""
|
|
2
|
+
|
|
3
|
+
from typing import ClassVar, Optional
|
|
4
|
+
|
|
5
|
+
from ether.schemas.base import BaseFinding, Relation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class NetworkHost(BaseFinding):
|
|
9
|
+
"""A discovered machine on the network, identified by IP. Root entity for most scans. Produced by nmap."""
|
|
10
|
+
|
|
11
|
+
schema_type: str = "network.host"
|
|
12
|
+
pik_fields: ClassVar[list[str]] = ["ip"]
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def create(cls, ip: str, hostname: Optional[str] = None, os: Optional[str] = None, **kwargs):
|
|
16
|
+
return cls.from_data({"ip": ip, "hostname": hostname, "os": os, **kwargs})
|
|
17
|
+
|
|
18
|
+
def to_semantic_text(self) -> str:
|
|
19
|
+
ip = self.pik.get("ip") or self.data.get("ip", "")
|
|
20
|
+
hostname = self.data.get("hostname")
|
|
21
|
+
os_val = self.data.get("os")
|
|
22
|
+
parts = [f"Discovered Host IP: {ip}"]
|
|
23
|
+
if hostname:
|
|
24
|
+
parts.append(f"Hostname: {hostname}")
|
|
25
|
+
if os_val:
|
|
26
|
+
parts.append(f"Operating System: {os_val}")
|
|
27
|
+
return ". ".join(parts) + "."
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class NetworkService(BaseFinding):
|
|
31
|
+
"""A listening port on a host. Child of network.host. Produced by nmap -sV."""
|
|
32
|
+
|
|
33
|
+
schema_type: str = "network.service"
|
|
34
|
+
pik_fields: ClassVar[list[str]] = ["host_ip", "port", "protocol"]
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def create(
|
|
38
|
+
cls,
|
|
39
|
+
host_ip: str,
|
|
40
|
+
port: int,
|
|
41
|
+
protocol: str = "tcp",
|
|
42
|
+
service_name: Optional[str] = None,
|
|
43
|
+
tls_cert_sha256: Optional[str] = None,
|
|
44
|
+
ssh_hostkey_fingerprint: Optional[str] = None,
|
|
45
|
+
anchor_hash: Optional[str] = None,
|
|
46
|
+
**kwargs,
|
|
47
|
+
):
|
|
48
|
+
pik = {"host_ip": host_ip, "port": port, "protocol": protocol}
|
|
49
|
+
data = {**pik, "service_name": service_name, **kwargs}
|
|
50
|
+
if tls_cert_sha256:
|
|
51
|
+
data["tls_cert_sha256"] = tls_cert_sha256
|
|
52
|
+
if not anchor_hash:
|
|
53
|
+
anchor_hash = (
|
|
54
|
+
f"tls:{tls_cert_sha256}"
|
|
55
|
+
if not tls_cert_sha256.startswith("tls:")
|
|
56
|
+
else tls_cert_sha256
|
|
57
|
+
)
|
|
58
|
+
if ssh_hostkey_fingerprint:
|
|
59
|
+
data["ssh_hostkey_fingerprint"] = ssh_hostkey_fingerprint
|
|
60
|
+
if not anchor_hash:
|
|
61
|
+
anchor_hash = (
|
|
62
|
+
f"ssh:{ssh_hostkey_fingerprint}"
|
|
63
|
+
if not ssh_hostkey_fingerprint.startswith("ssh:")
|
|
64
|
+
else ssh_hostkey_fingerprint
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
return cls(
|
|
68
|
+
pik=pik,
|
|
69
|
+
parent=Relation(
|
|
70
|
+
target_type="network.host", target_pik={"ip": host_ip}, via="has_service"
|
|
71
|
+
),
|
|
72
|
+
data=data,
|
|
73
|
+
anchor_hash=anchor_hash,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
def to_semantic_text(self) -> str:
|
|
77
|
+
host_ip = self.pik.get("host_ip") or self.data.get("host_ip", "")
|
|
78
|
+
port = self.pik.get("port") or self.data.get("port", "")
|
|
79
|
+
protocol = self.pik.get("protocol") or self.data.get("protocol", "tcp")
|
|
80
|
+
svc = self.data.get("service_name") or "unknown"
|
|
81
|
+
banner = self.data.get("banner")
|
|
82
|
+
tls = self.data.get("tls_cert_sha256")
|
|
83
|
+
parts = [f"{svc} service on {host_ip}:{port}/{protocol}"]
|
|
84
|
+
if banner:
|
|
85
|
+
parts.append(f"Product banner: {banner}")
|
|
86
|
+
if tls:
|
|
87
|
+
parts.append(f"TLS SHA-256: {tls}")
|
|
88
|
+
return ". ".join(parts) + "."
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class NetworkNetblock(BaseFinding):
|
|
92
|
+
"""An IP range with ownership data — org, ASN, CIDR. Produced by whois against an IP."""
|
|
93
|
+
|
|
94
|
+
schema_type: str = "network.netblock"
|
|
95
|
+
pik_fields: ClassVar[list[str]] = ["cidr"]
|
|
96
|
+
|
|
97
|
+
@classmethod
|
|
98
|
+
def create(cls, cidr: str, organization: Optional[str] = None, asn: Optional[str] = None):
|
|
99
|
+
pik = {"cidr": cidr.strip()}
|
|
100
|
+
return cls(pik=pik, data={**pik, "organization": organization, "asn": asn})
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class TLSCertificate(BaseFinding):
|
|
104
|
+
"""A TLS certificate associated with a service. Child of network.service. Produced by sslscan, nmap-scripts."""
|
|
105
|
+
|
|
106
|
+
schema_type: str = "tls.certificate"
|
|
107
|
+
pik_fields: ClassVar[list[str]] = ["fingerprint"]
|
|
108
|
+
|
|
109
|
+
@classmethod
|
|
110
|
+
def create(
|
|
111
|
+
cls,
|
|
112
|
+
fingerprint: str,
|
|
113
|
+
host_ip: str,
|
|
114
|
+
port: int,
|
|
115
|
+
anchor_hash: Optional[str] = None,
|
|
116
|
+
**kwargs,
|
|
117
|
+
):
|
|
118
|
+
if not anchor_hash and fingerprint:
|
|
119
|
+
anchor_hash = (
|
|
120
|
+
f"tls:{fingerprint}" if not fingerprint.startswith("tls:") else fingerprint
|
|
121
|
+
)
|
|
122
|
+
return cls(
|
|
123
|
+
pik={"fingerprint": fingerprint},
|
|
124
|
+
parent=Relation(
|
|
125
|
+
target_type="network.service",
|
|
126
|
+
target_pik={"host_ip": host_ip, "port": port, "protocol": "tcp"},
|
|
127
|
+
via="uses_certificate",
|
|
128
|
+
),
|
|
129
|
+
data={
|
|
130
|
+
"fingerprint": fingerprint,
|
|
131
|
+
"host_ip": host_ip,
|
|
132
|
+
"port": port,
|
|
133
|
+
**kwargs,
|
|
134
|
+
},
|
|
135
|
+
anchor_hash=anchor_hash,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
def to_semantic_text(self) -> str:
|
|
139
|
+
fp = self.pik.get("fingerprint") or self.data.get("fingerprint", "")
|
|
140
|
+
host = self.data.get("host_ip", "")
|
|
141
|
+
port = self.data.get("port", "")
|
|
142
|
+
return f"TLS Certificate (SHA-256: {fp}) on {host}:{port}."
|
ether/schemas/power.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""Schemas for Power Mode sessions, actions, and context."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from datetime import UTC, datetime
|
|
5
|
+
from enum import Enum
|
|
6
|
+
from typing import Any, Dict, List, Optional
|
|
7
|
+
from uuid import UUID, uuid4
|
|
8
|
+
|
|
9
|
+
from pydantic import BaseModel, Field
|
|
10
|
+
|
|
11
|
+
from ether.schemas.base import BaseFinding
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ActionSource(str, Enum):
|
|
15
|
+
"""Origin of a tool action."""
|
|
16
|
+
|
|
17
|
+
USER = "USER"
|
|
18
|
+
SUGGESTION = "SUGGESTION"
|
|
19
|
+
AGENT = "AGENT"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class JobStatusEnum(str, Enum):
|
|
23
|
+
"""Current state of a tool execution job."""
|
|
24
|
+
|
|
25
|
+
QUEUED = "QUEUED"
|
|
26
|
+
RUNNING = "RUNNING"
|
|
27
|
+
DONE = "DONE"
|
|
28
|
+
FAILED = "FAILED"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ActionRequest(BaseModel):
|
|
32
|
+
"""A typed request to execute a tool action."""
|
|
33
|
+
|
|
34
|
+
action_id: UUID = Field(default_factory=uuid4)
|
|
35
|
+
session_id: UUID
|
|
36
|
+
tool_name: str
|
|
37
|
+
target_entity_id: Optional[str] = None # Optional for general shell commands
|
|
38
|
+
params: Dict[str, Any] = Field(default_factory=dict)
|
|
39
|
+
triggered_by: ActionSource = ActionSource.USER
|
|
40
|
+
is_explicit_shell: bool = False # True if prefix '!' was used
|
|
41
|
+
timeout_seconds: Optional[int] = None
|
|
42
|
+
timestamp: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class JobStatus(BaseModel):
|
|
46
|
+
"""Real-time status of a job in the queue."""
|
|
47
|
+
|
|
48
|
+
job_id: UUID
|
|
49
|
+
session_id: UUID
|
|
50
|
+
tool_name: str
|
|
51
|
+
status: JobStatusEnum
|
|
52
|
+
started_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
53
|
+
completed_at: Optional[datetime] = None
|
|
54
|
+
log_file: Optional[str] = None
|
|
55
|
+
command_snippet: Optional[str] = None
|
|
56
|
+
tab_id: Optional[str] = None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class WorkspaceContext(BaseModel):
|
|
60
|
+
"""Point-in-time snapshot of the Power Mode workspace."""
|
|
61
|
+
|
|
62
|
+
session_id: UUID
|
|
63
|
+
session_name: Optional[str]
|
|
64
|
+
selected_entity: Optional[BaseFinding] = None
|
|
65
|
+
resolved_vars: Dict[str, Any] = Field(default_factory=dict) # e.g. {"TARGET": "10.10.10.5"}
|
|
66
|
+
active_jobs: List[JobStatus] = Field(default_factory=list)
|
|
67
|
+
entity_counts: Dict[str, int] = Field(default_factory=dict)
|
|
68
|
+
cwd: str = Field(default_factory=lambda: os.path.expanduser("~"))
|