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/nikto/adapter.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""Nikto 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.vulnerability import VulnerabilityFound
|
|
10
|
+
from ether.schemas.web import WebVulnerability
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NiktoAdapter(ToolAdapter):
|
|
14
|
+
"""Adapter for the nikto web scanner."""
|
|
15
|
+
|
|
16
|
+
FINDING_PATTERN = re.compile(r"^\+ (.*)", re.MULTILINE)
|
|
17
|
+
PATH_PATTERN = re.compile(r"^(/[\w\-\.\/]+):\s+(.*)")
|
|
18
|
+
OSVDB_PATTERN = re.compile(r"^(OSVDB-\d+):\s+(.*)")
|
|
19
|
+
|
|
20
|
+
def validate_install(self) -> bool:
|
|
21
|
+
return self.is_binary_available("nikto")
|
|
22
|
+
|
|
23
|
+
def sanitize_output(self, raw_stdout: str) -> str:
|
|
24
|
+
"""Strip Nikto banners, informational headers, and run trailers."""
|
|
25
|
+
lines = []
|
|
26
|
+
for line in raw_stdout.splitlines():
|
|
27
|
+
s = line.strip()
|
|
28
|
+
if (
|
|
29
|
+
s.startswith("- Nikto v")
|
|
30
|
+
or s.startswith("+ Target IP:")
|
|
31
|
+
or s.startswith("+ Target Hostname:")
|
|
32
|
+
or s.startswith("+ Target Port:")
|
|
33
|
+
or s.startswith("+ Start Time:")
|
|
34
|
+
or s.startswith("+ End Time:")
|
|
35
|
+
or "host(s) tested" in s
|
|
36
|
+
):
|
|
37
|
+
continue
|
|
38
|
+
lines.append(line)
|
|
39
|
+
return "\n".join(lines)
|
|
40
|
+
|
|
41
|
+
def build_command(self, target: BaseFinding, params: Dict[str, Any]) -> List[str]:
|
|
42
|
+
args = ["nikto"]
|
|
43
|
+
|
|
44
|
+
raw_flags = params.get("raw_flags", "")
|
|
45
|
+
if raw_flags:
|
|
46
|
+
if target.schema_type == "web.endpoint":
|
|
47
|
+
target_str = target.pik.get("url", "")
|
|
48
|
+
else:
|
|
49
|
+
target_str = self.extract_host(target) or ""
|
|
50
|
+
port_val = self.extract_port(target)
|
|
51
|
+
port_str = str(port_val) if port_val else ""
|
|
52
|
+
|
|
53
|
+
# Tokenize first to prevent argument injection from target_str or port_str
|
|
54
|
+
tokens = shlex.split(raw_flags)
|
|
55
|
+
resolved_tokens = []
|
|
56
|
+
skip_next = False
|
|
57
|
+
for i, token in enumerate(tokens):
|
|
58
|
+
if skip_next:
|
|
59
|
+
skip_next = False
|
|
60
|
+
continue
|
|
61
|
+
if token == "-p" and i + 1 < len(tokens) and tokens[i + 1] == "{port}":
|
|
62
|
+
if port_str:
|
|
63
|
+
resolved_tokens.extend(["-p", port_str])
|
|
64
|
+
skip_next = True
|
|
65
|
+
continue
|
|
66
|
+
token = token.replace("{target}", target_str)
|
|
67
|
+
token = token.replace("{port}", port_str)
|
|
68
|
+
if token:
|
|
69
|
+
resolved_tokens.append(token)
|
|
70
|
+
|
|
71
|
+
args.extend(resolved_tokens)
|
|
72
|
+
|
|
73
|
+
return args
|
|
74
|
+
|
|
75
|
+
async def parse_output(
|
|
76
|
+
self, raw_stdout: str, target: BaseFinding, context: Dict[str, Any] = None
|
|
77
|
+
) -> AsyncIterator[BaseFinding]:
|
|
78
|
+
"""Regex parser for nikto output.
|
|
79
|
+
|
|
80
|
+
Example line: + /admin/: Directory indexing found.
|
|
81
|
+
Example line: + Server: Apache/2.4.41 (Ubuntu)
|
|
82
|
+
Example line: + OSVDB-112004: /cgi-bin/test.cgi: Site appears vulnerable to the 'Shellshock' vulnerability.
|
|
83
|
+
"""
|
|
84
|
+
# Try to extract base host/url from target or command
|
|
85
|
+
base_host = self.extract_host(target) or ""
|
|
86
|
+
base_url = (self.extract_url(target) or "").rstrip("/")
|
|
87
|
+
|
|
88
|
+
for match in self.FINDING_PATTERN.finditer(raw_stdout):
|
|
89
|
+
line = match.group(1).strip()
|
|
90
|
+
|
|
91
|
+
# Skip informational headers
|
|
92
|
+
if (
|
|
93
|
+
line.startswith("Target IP:")
|
|
94
|
+
or line.startswith("Target Hostname:")
|
|
95
|
+
or line.startswith("Target Port:")
|
|
96
|
+
or line.startswith("Start Time:")
|
|
97
|
+
or line.startswith("End Time:")
|
|
98
|
+
or "Nikto v" in line
|
|
99
|
+
or "host(s) tested" in line
|
|
100
|
+
):
|
|
101
|
+
continue
|
|
102
|
+
|
|
103
|
+
osvdb_match = self.OSVDB_PATTERN.search(line)
|
|
104
|
+
if osvdb_match:
|
|
105
|
+
vuln_id = osvdb_match.group(1)
|
|
106
|
+
desc = osvdb_match.group(2)
|
|
107
|
+
|
|
108
|
+
# Check if it has a path
|
|
109
|
+
path_match = self.PATH_PATTERN.search(desc)
|
|
110
|
+
if path_match and base_url:
|
|
111
|
+
path = path_match.group(1)
|
|
112
|
+
finding = path_match.group(2)
|
|
113
|
+
yield WebVulnerability.create(
|
|
114
|
+
url=f"{base_url}{path}", vuln_type=vuln_id, description=finding
|
|
115
|
+
)
|
|
116
|
+
elif base_host:
|
|
117
|
+
yield VulnerabilityFound.create(
|
|
118
|
+
host_ip=base_host, vuln_id=vuln_id, severity="unknown", description=desc
|
|
119
|
+
)
|
|
120
|
+
else:
|
|
121
|
+
path_match = self.PATH_PATTERN.search(line)
|
|
122
|
+
if path_match and base_url:
|
|
123
|
+
path = path_match.group(1)
|
|
124
|
+
desc = path_match.group(2)
|
|
125
|
+
yield WebVulnerability.create(
|
|
126
|
+
url=f"{base_url}{path}", vuln_type="misconfiguration", description=desc
|
|
127
|
+
)
|
|
128
|
+
elif path_match and base_host:
|
|
129
|
+
path = path_match.group(1)
|
|
130
|
+
desc = path_match.group(2)
|
|
131
|
+
yield VulnerabilityFound.create(
|
|
132
|
+
host_ip=base_host,
|
|
133
|
+
vuln_id="misconfiguration",
|
|
134
|
+
severity="info",
|
|
135
|
+
description=f"{path}: {desc}",
|
|
136
|
+
)
|
|
137
|
+
elif base_host:
|
|
138
|
+
# Generic host/service finding
|
|
139
|
+
if "Server:" in line or "Retrieved x-powered-by" in line:
|
|
140
|
+
yield VulnerabilityFound.create(
|
|
141
|
+
host_ip=base_host,
|
|
142
|
+
vuln_id="info_disclosure",
|
|
143
|
+
severity="info",
|
|
144
|
+
description=line,
|
|
145
|
+
)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
[meta]
|
|
2
|
+
name = "nikto"
|
|
3
|
+
description = "Comprehensive web server scanner for finding dangerous files, outdated server software, insecure HTTP headers, and server misconfigurations."
|
|
4
|
+
one_line_summary = "scan web servers for security misconfigurations and obsolete software"
|
|
5
|
+
category = "Vulnerability Assessment"
|
|
6
|
+
categories = ["vuln", "web", "scanner"]
|
|
7
|
+
binary = "nikto"
|
|
8
|
+
theory = """
|
|
9
|
+
### Protocol Theory & Heuristic Vulnerability Auditing
|
|
10
|
+
Nikto queries over 6,700 known vulnerabilities, dangerous scripts, and software configuration weaknesses across web servers (RFC 2616).
|
|
11
|
+
|
|
12
|
+
### Primary Audit Vectors
|
|
13
|
+
* **Dangerous HTTP Methods**: Probes for insecure WebDAV and legacy methods (`PUT`, `DELETE`, `TRACE`). Detects Cross-Site Tracing (XST).
|
|
14
|
+
* **Defensive Header Auditing**: Audits missing security headers: `Strict-Transport-Security` (HSTS), `Content-Security-Policy` (CSP), and `X-Frame-Options`.
|
|
15
|
+
* **Outdated Server Fingerprints**: Matches `Server` and `X-Powered-By` version strings against CVE registries.
|
|
16
|
+
|
|
17
|
+
### Defensive Hardening & Remediation
|
|
18
|
+
* **Banner Suppression**: Obfuscate daemon banners (`ServerTokens Prod`, `server_tokens off`).
|
|
19
|
+
* **Enforce Security Headers**: Implement modern headers to block client-side injection and clickjacking.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
[modes]
|
|
23
|
+
learning = true
|
|
24
|
+
power = true
|
|
25
|
+
|
|
26
|
+
[input]
|
|
27
|
+
accepts = ["network.service", "web.endpoint", "network.host"]
|
|
28
|
+
|
|
29
|
+
[output]
|
|
30
|
+
produces = ["vulnerability.found", "web.vulnerability", "web.endpoint"]
|
|
31
|
+
|
|
32
|
+
[learning]
|
|
33
|
+
enabled = true
|
|
34
|
+
|
|
35
|
+
[[learning.recipes]]
|
|
36
|
+
name = "Standard Web Misconfiguration Audit"
|
|
37
|
+
difficulty = "Beginner"
|
|
38
|
+
description = "Scan web server for missing security headers, open directory indexing, and default files."
|
|
39
|
+
flags = ["-h", "{target}"]
|
|
40
|
+
|
|
41
|
+
[learning.recipes.theory]
|
|
42
|
+
concept = "HTTP Defensive Headers & Server Misconfiguration Checks"
|
|
43
|
+
explanation = """
|
|
44
|
+
Nikto inspects incoming HTTP responses for critical defensive headers:
|
|
45
|
+
- Strict-Transport-Security (HSTS, RFC 6797): Enforces HTTPS connections and eliminates SSL stripping.
|
|
46
|
+
- Content-Security-Policy (CSP): Restricts origins of executable scripts to prevent XSS.
|
|
47
|
+
- X-Frame-Options: Protects users against clickjacking attacks.
|
|
48
|
+
- X-Content-Type-Options: Prevents MIME-confusion attacks ('nosniff').
|
|
49
|
+
Missing headers leave end-users exposed to cross-site scripting, framing, and downgrade attacks.
|
|
50
|
+
"""
|
|
51
|
+
packet_wire_summary = "Client GET / -> Analyzes Server response headers for missing HSTS, CSP, and X-Frame-Options"
|
|
52
|
+
remediation = "Implement strict modern security headers in web server reverse proxy configuration."
|
|
53
|
+
|
|
54
|
+
[[learning.recipes]]
|
|
55
|
+
name = "Specific Port Web Scan"
|
|
56
|
+
difficulty = "Beginner"
|
|
57
|
+
description = "Target administrative or development web portals listening on non-standard ports (8080, 8443)."
|
|
58
|
+
flags = ["-h", "{target}", "-p", "{port}"]
|
|
59
|
+
|
|
60
|
+
[learning.recipes.theory]
|
|
61
|
+
concept = "High-Port Web Consoles & Alternative HTTP Sockets"
|
|
62
|
+
explanation = """
|
|
63
|
+
Development servers (Tomcat, Spring Boot, Jenkins, Node.js) frequently run on non-standard ports such as 8080 or 8443.
|
|
64
|
+
These services are often deployed with default administrative credentials, exposed debug consoles, and unhardened stack trace configurations.
|
|
65
|
+
"""
|
|
66
|
+
packet_wire_summary = "Client connects to target:PORT -> Sends standard HTTP/1.1 negotiation requests"
|
|
67
|
+
remediation = "Bind administrative web consoles strictly to localhost (127.0.0.1) or restrict access via VPN and bastion hosts."
|
|
68
|
+
|
|
69
|
+
[[learning.recipes]]
|
|
70
|
+
name = "SSL/TLS Security & Cipher Audit"
|
|
71
|
+
difficulty = "Intermediate"
|
|
72
|
+
description = "Audit the HTTPS handshake, certificate issuer, expired certs, and supported cipher suites."
|
|
73
|
+
flags = ["-h", "{target}", "-ssl"]
|
|
74
|
+
|
|
75
|
+
[learning.recipes.theory]
|
|
76
|
+
concept = "TLS Handshake Negotiation & Legacy Cipher Deprecation"
|
|
77
|
+
explanation = """
|
|
78
|
+
The '-ssl' flag forces Nikto to perform encrypted TLS handshakes.
|
|
79
|
+
It tests for support of legacy, insecure protocols (SSLv2, SSLv3, TLS 1.0, TLS 1.1) and broken ciphers (RC4, 3DES).
|
|
80
|
+
It also evaluates X.509 certificate validity, checking for hostname mismatch, self-signed certificates, and approaching expiration dates.
|
|
81
|
+
"""
|
|
82
|
+
packet_wire_summary = "Client TLS ClientHello -> Evaluates server cipher preferences and X.509 certificate chain"
|
|
83
|
+
remediation = "Disable TLS 1.0/1.1; enforce TLS 1.2 and TLS 1.3 with modern ephemeral Diffie-Hellman ciphers."
|
|
84
|
+
|
|
85
|
+
[[learning.recipes]]
|
|
86
|
+
name = "Tuned Information Disclosure Sweep"
|
|
87
|
+
difficulty = "Advanced"
|
|
88
|
+
description = "Run a targeted scan focusing specifically on information disclosure and server configuration leaks."
|
|
89
|
+
flags = ["-h", "{target}", "-Tuning", "2,4,b"]
|
|
90
|
+
|
|
91
|
+
[learning.recipes.theory]
|
|
92
|
+
concept = "Scanner Tuning & Targeted Payload Classification"
|
|
93
|
+
explanation = """
|
|
94
|
+
Nikto categorizes tests into numeric 'Tuning' classes:
|
|
95
|
+
- 2: Misconfigurations & default files
|
|
96
|
+
- 4: Injection & remote code execution flaws
|
|
97
|
+
- b: Software identification & version extraction
|
|
98
|
+
Using '-Tuning' drastically reduces total scan duration by focusing exclusively on relevant test vectors while skipping irrelevant tests.
|
|
99
|
+
"""
|
|
100
|
+
packet_wire_summary = "Client executes filtered test subset: Only transmits requests matching Tuning classes 2, 4, and b"
|
|
101
|
+
remediation = "Regularly audit server file trees to remove unused staging artifacts and sample test files."
|
|
102
|
+
|
|
103
|
+
[power]
|
|
104
|
+
enabled = true
|
|
105
|
+
suggests = [
|
|
106
|
+
{ target = "vulnerability.found", condition = "vuln_id != ''", tool = "searchsploit", flags = "--cve {target.pik.vuln_id}" },
|
|
107
|
+
{ target = "web.vulnerability", condition = "url != ''", tool = "nuclei", flags = "-u {target.pik.url}" }
|
|
108
|
+
]
|
tools/nmap/__init__.py
ADDED
|
File without changes
|
tools/nmap/adapter.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""Nmap 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.network import NetworkHost, NetworkService
|
|
10
|
+
|
|
11
|
+
_REPORT_PATTERN = re.compile(r"Nmap scan report for (?:[^\s(]+\s+)?\(?([^\s)]+)\)?")
|
|
12
|
+
_PORT_PATTERN = re.compile(r"(\d+)/(tcp|udp)\s+open\s+(\S+)")
|
|
13
|
+
_IP_PATTERN = re.compile(r"(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class NmapAdapter(ToolAdapter):
|
|
17
|
+
"""Adapter for the nmap port scanner."""
|
|
18
|
+
|
|
19
|
+
def validate_install(self) -> bool:
|
|
20
|
+
return self.is_binary_available("nmap")
|
|
21
|
+
|
|
22
|
+
def sanitize_output(self, raw_stdout: str) -> str:
|
|
23
|
+
"""Strip nmap banner and timing statistics to conserve LLM context tokens."""
|
|
24
|
+
lines = []
|
|
25
|
+
for line in raw_stdout.splitlines():
|
|
26
|
+
s = line.strip()
|
|
27
|
+
if (
|
|
28
|
+
s.startswith("Starting Nmap")
|
|
29
|
+
or s.startswith("Nmap done:")
|
|
30
|
+
or "host up (" 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
|
+
# target is expected to be a network.host, but might be dummy in manual mode
|
|
38
|
+
ip = self.extract_host(target)
|
|
39
|
+
|
|
40
|
+
args = ["nmap", "--noninteractive"]
|
|
41
|
+
|
|
42
|
+
# Handle manual raw flags from UI
|
|
43
|
+
raw_flags = params.get("raw_flags", "")
|
|
44
|
+
if raw_flags:
|
|
45
|
+
args.extend(shlex.split(raw_flags))
|
|
46
|
+
|
|
47
|
+
if ip and ip not in args:
|
|
48
|
+
args.append(ip)
|
|
49
|
+
elif not raw_flags:
|
|
50
|
+
raise ValueError(
|
|
51
|
+
"Target finding must have an IP address, or provide one in the command flags."
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
return args
|
|
55
|
+
|
|
56
|
+
async def parse_output(
|
|
57
|
+
self, raw_stdout: str, target: BaseFinding, context: Dict[str, Any] = None
|
|
58
|
+
) -> AsyncIterator[BaseFinding]:
|
|
59
|
+
"""Simple regex parser for nmap output.
|
|
60
|
+
|
|
61
|
+
Example line: 80/tcp open http
|
|
62
|
+
"""
|
|
63
|
+
context = context or {}
|
|
64
|
+
|
|
65
|
+
for line in raw_stdout.splitlines():
|
|
66
|
+
clean_line = self.strip_ansi(line)
|
|
67
|
+
|
|
68
|
+
# Host discovery
|
|
69
|
+
host_match = _REPORT_PATTERN.search(clean_line)
|
|
70
|
+
if host_match:
|
|
71
|
+
host_ip = host_match.group(1)
|
|
72
|
+
context["current_host_ip"] = host_ip
|
|
73
|
+
yield NetworkHost.create(ip=host_ip)
|
|
74
|
+
continue
|
|
75
|
+
|
|
76
|
+
# Port discovery
|
|
77
|
+
port_match = _PORT_PATTERN.search(clean_line)
|
|
78
|
+
if port_match:
|
|
79
|
+
# Priority: 1. Host from output context, 2. Host from target PIK, 3. Host from raw flags
|
|
80
|
+
host_ip = context.get("current_host_ip") or target.pik.get("ip")
|
|
81
|
+
|
|
82
|
+
if not host_ip:
|
|
83
|
+
# Fallback: Try to find IP in raw flags if it is a manual scan
|
|
84
|
+
raw_flags = context.get("params", {}).get("raw_flags", "")
|
|
85
|
+
ip_match = _IP_PATTERN.search(raw_flags)
|
|
86
|
+
if ip_match:
|
|
87
|
+
host_ip = ip_match.group(1)
|
|
88
|
+
context["current_host_ip"] = host_ip
|
|
89
|
+
|
|
90
|
+
if host_ip:
|
|
91
|
+
port = int(port_match.group(1))
|
|
92
|
+
protocol = port_match.group(2)
|
|
93
|
+
service = port_match.group(3)
|
|
94
|
+
|
|
95
|
+
yield NetworkService.create(
|
|
96
|
+
host_ip=host_ip, port=port, protocol=protocol, service_name=service
|
|
97
|
+
)
|
tools/nmap/manifest.toml
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
[meta]
|
|
2
|
+
name = "nmap"
|
|
3
|
+
description = "Network host and port scanner and network security auditing suite."
|
|
4
|
+
one_line_summary = "discover hosts, open ports, and running services across a network"
|
|
5
|
+
category = "Network Reconnaissance"
|
|
6
|
+
categories = ["recon", "enumeration", "network"]
|
|
7
|
+
binary = "nmap"
|
|
8
|
+
theory = """
|
|
9
|
+
### Protocol Theory & RFC 793 Standards
|
|
10
|
+
Network enumeration interrogates the remote operating system's transport-layer stack (RFC 793) to deduce listening socket states.
|
|
11
|
+
|
|
12
|
+
### Core Mechanics & Wire-Level Probing
|
|
13
|
+
* **TCP SYN Half-Open (`-sS`)**: Injects raw `SYN` frames. If listening, server replies `SYN/ACK`. Nmap terminates immediately with `RST` to evade application connection logging.
|
|
14
|
+
* **Service Versioning (`-sV`)**: Matches welcome banners against `nmap-service-probes` database (SSH, HTTP Server, FTP).
|
|
15
|
+
* **OS Fingerprinting (`-O`)**: Probes window scale, initial sequence number (ISN) drift, and IP ID predictability.
|
|
16
|
+
|
|
17
|
+
### Defensive Hardening & Detection
|
|
18
|
+
* **Stateful Firewalls**: Drop unsolicited packets (`DROP` vs `REJECT/RST`) to induce timeouts.
|
|
19
|
+
* **IDS/IPS Rules**: Monitor high-frequency SYN flag sequences across non-contiguous destination ports.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
[modes]
|
|
23
|
+
learning = true
|
|
24
|
+
power = true
|
|
25
|
+
|
|
26
|
+
[input]
|
|
27
|
+
accepts = ["network.host"]
|
|
28
|
+
|
|
29
|
+
[output]
|
|
30
|
+
produces = ["network.service"]
|
|
31
|
+
|
|
32
|
+
[learning]
|
|
33
|
+
enabled = true
|
|
34
|
+
|
|
35
|
+
[[learning.recipes]]
|
|
36
|
+
name = "Standard Service Version Scan"
|
|
37
|
+
difficulty = "Beginner"
|
|
38
|
+
description = "Fast standard service and version detection on top common ports."
|
|
39
|
+
flags = ["-sV"]
|
|
40
|
+
|
|
41
|
+
[learning.recipes.theory]
|
|
42
|
+
concept = "Application Layer Banner Grabbing & Service Fingerprinting (RFC 793)"
|
|
43
|
+
explanation = """
|
|
44
|
+
Service version detection (-sV) queries open TCP ports with a series of protocol-specific probes.
|
|
45
|
+
Nmap inspects the initial banner responses (e.g. SSH protocol strings, HTTP Server headers, FTP greetings) and matches them against nmap-service-probes to identify the exact application daemon and version.
|
|
46
|
+
"""
|
|
47
|
+
packet_wire_summary = "Client completes 3-way handshake -> Reads application welcome banner or transmits GET / probe"
|
|
48
|
+
remediation = "Sanitize or suppress verbose server version strings in daemon configuration files."
|
|
49
|
+
|
|
50
|
+
[[learning.recipes]]
|
|
51
|
+
name = "Pingless Firewall Evasion Scan"
|
|
52
|
+
difficulty = "Beginner"
|
|
53
|
+
description = "Bypass host-discovery ICMP ping probes to scan firewalled targets that drop ICMP echo requests."
|
|
54
|
+
flags = ["-sV", "-Pn"]
|
|
55
|
+
|
|
56
|
+
[learning.recipes.theory]
|
|
57
|
+
concept = "ICMP Host Discovery Suppression & Stateful Packet Filtering (RFC 792)"
|
|
58
|
+
explanation = """
|
|
59
|
+
By default, Nmap sends ICMP Echo requests, TCP SYN to 443, TCP ACK to 80, and ICMP Timestamp to determine if a host is active before port scanning.
|
|
60
|
+
Many corporate perimeter firewalls silently drop all ICMP and unsolicited TCP to ports 80/443, causing Nmap to mark live hosts as 'down'.
|
|
61
|
+
The '-Pn' flag instructs Nmap to skip host discovery entirely and proceed directly to port enumeration on every requested IP.
|
|
62
|
+
"""
|
|
63
|
+
packet_wire_summary = "Client skips ICMP Echo -> Directly transmits port probes to target socket addresses"
|
|
64
|
+
remediation = "Audit perimeter ACLs; do not rely on ICMP blocking as security-through-obscurity."
|
|
65
|
+
|
|
66
|
+
[[learning.recipes]]
|
|
67
|
+
name = "TCP SYN Half-Open Stealth Scan"
|
|
68
|
+
difficulty = "Beginner"
|
|
69
|
+
description = "Fast, stealthy port scan that determines port state without completing the full TCP 3-way handshake."
|
|
70
|
+
flags = ["-sS", "-sV", "--top-ports", "100"]
|
|
71
|
+
|
|
72
|
+
[learning.recipes.theory]
|
|
73
|
+
concept = "TCP 3-Way Handshake & Half-Open Connection Teardown (RFC 793)"
|
|
74
|
+
explanation = """
|
|
75
|
+
TCP SYN scanning is the default and most popular scan technique.
|
|
76
|
+
The scanner sends a raw TCP packet with only the SYN flag set.
|
|
77
|
+
- Open Port: Target replies with SYN/ACK. Scanner immediately sends a RST packet to tear down the connection before the target OS hands the socket to application logs.
|
|
78
|
+
- Closed Port: Target immediately replies with RST.
|
|
79
|
+
- Filtered: Packet is dropped by a firewall or answered with ICMP unreachable.
|
|
80
|
+
"""
|
|
81
|
+
packet_wire_summary = "Client SYN -> Server SYN/ACK -> Client RST (Connection terminated before application logging)"
|
|
82
|
+
remediation = "Employ stateful firewall inspection (conntrack) and next-gen firewalls (NGFW) to detect and rate-limit half-open SYN sweeps."
|
|
83
|
+
|
|
84
|
+
[[learning.recipes]]
|
|
85
|
+
name = "Default NSE Script Engine Audit"
|
|
86
|
+
difficulty = "Intermediate"
|
|
87
|
+
description = "Execute safe default Nmap Scripting Engine (NSE) scripts to fingerprint software banners, SSL certs, and known CVEs."
|
|
88
|
+
flags = ["-sC", "-sV"]
|
|
89
|
+
|
|
90
|
+
[learning.recipes.theory]
|
|
91
|
+
concept = "Automated Protocol Handshakes & Lua Script Sandboxing (NSE Architecture)"
|
|
92
|
+
explanation = """
|
|
93
|
+
The Nmap Scripting Engine (NSE) allows users to write and execute Lua scripts to automate network checks.
|
|
94
|
+
The '-sC' flag triggers scripts in the 'default' category, vetted by the community for safety, speed, and low invasiveness.
|
|
95
|
+
NSE queries application layers directly: fetching HTTP titles, parsing SSL/TLS X.509 certificates, checking SSH hostkeys, and verifying anonymous FTP access.
|
|
96
|
+
"""
|
|
97
|
+
packet_wire_summary = "Client negotiates application-layer protocols (HTTP GET, SSH banner exchange, TLS ClientHello) via Lua socket engine"
|
|
98
|
+
remediation = "Disable anonymous access, sanitize public software banners, and restrict administrative services to management subnets."
|
|
99
|
+
|
|
100
|
+
[[learning.recipes]]
|
|
101
|
+
name = "Comprehensive 65,535 Full Port Audit"
|
|
102
|
+
difficulty = "Intermediate"
|
|
103
|
+
description = "Enumerate the entire 16-bit TCP port range to locate unannounced services listening on non-standard high ports."
|
|
104
|
+
flags = ["-sV", "-p-", "-T4"]
|
|
105
|
+
|
|
106
|
+
[learning.recipes.theory]
|
|
107
|
+
concept = "Transport Layer Addressing Space & High-Port Obfuscation"
|
|
108
|
+
explanation = """
|
|
109
|
+
TCP port numbers are 16-bit unsigned integers ranging from 1 to 65,535 (ports 1–1023 well-known, 1024–49151 registered, 49152–65535 dynamic/ephemeral).
|
|
110
|
+
Administrators frequently bind sensitive services (SSH on port 2222, web consoles on 8080/8443, database proxies on 54321) to evade default scans that only check top 1,000 ports.
|
|
111
|
+
The '-p-' flag forces a scan of all 65,535 ports, while '-T4' optimizes timing for modern high-bandwidth networks.
|
|
112
|
+
"""
|
|
113
|
+
packet_wire_summary = "Client systematically cycles through port range 1..65535 using adaptive round-trip-time (RTT) congestion algorithms"
|
|
114
|
+
remediation = "Enforce a strict default-deny egress and ingress firewall policy; inspect network listening sockets using 'ss -tulpn'."
|
|
115
|
+
|
|
116
|
+
[[learning.recipes]]
|
|
117
|
+
name = "UDP Service Discovery (DNS, SNMP, NTP)"
|
|
118
|
+
difficulty = "Advanced"
|
|
119
|
+
description = "Probe critical connectionless UDP services including DNS (53), SNMP (161), and NTP (123)."
|
|
120
|
+
flags = ["-sU", "--top-ports", "25", "-sV"]
|
|
121
|
+
|
|
122
|
+
[learning.recipes.theory]
|
|
123
|
+
concept = "User Datagram Protocol (UDP) & ICMP Port Unreachable Semantics (RFC 768 / RFC 792)"
|
|
124
|
+
explanation = """
|
|
125
|
+
Unlike TCP, UDP is connectionless and does not utilize a handshake.
|
|
126
|
+
When a scanner transmits a UDP packet to an open port, the application usually does not respond unless the packet matches its exact payload format.
|
|
127
|
+
However, if the port is closed, the host's IP stack MUST reply with an ICMP Type 3 Code 3 (Destination Unreachable: Port Unreachable) packet.
|
|
128
|
+
Linux kernels strictly rate-limit ICMP error messages (typically 1 packet per second), making UDP scans significantly slower.
|
|
129
|
+
"""
|
|
130
|
+
packet_wire_summary = "Client sends protocol-specific UDP datagram -> If Port Closed: Server returns ICMP Type 3 Code 3"
|
|
131
|
+
remediation = "Firewall unused UDP ports and disable legacy protocols (SNMPv1/v2c, NTP monlist reflection) vulnerable to amplification attacks."
|
|
132
|
+
|
|
133
|
+
[[learning.recipes]]
|
|
134
|
+
name = "OS Fingerprinting & TCP/IP Stack Profiling"
|
|
135
|
+
difficulty = "Advanced"
|
|
136
|
+
description = "Analyze quirks in TCP/IP packet generation to fingerprint the target operating system kernel and version."
|
|
137
|
+
flags = ["-O", "-sV"]
|
|
138
|
+
|
|
139
|
+
[learning.recipes.theory]
|
|
140
|
+
concept = "TCP/IP Stack Quirks & Initial Sequence Number (ISN) Predictability"
|
|
141
|
+
explanation = """
|
|
142
|
+
Different operating systems (Linux kernel versions, Windows NT, FreeBSD) implement RFC specifications with minor vendor differences.
|
|
143
|
+
Nmap's '-O' engine transmits a sequence of crafted TCP/UDP/ICMP probes and evaluates responses against thousands of OS signatures:
|
|
144
|
+
1. TCP Initial Sequence Number (ISN) generation algorithm.
|
|
145
|
+
2. TCP Window Size and Window Scale option support.
|
|
146
|
+
3. IP Header Don't Fragment (DF) and Type of Service (TOS) handling.
|
|
147
|
+
4. TCP Options ordering and timestamp behaviors.
|
|
148
|
+
"""
|
|
149
|
+
packet_wire_summary = "Client transmits crafted probes with unusual flag combinations -> Compares response packet headers against nmap-os-db"
|
|
150
|
+
remediation = "Modern Linux kernels randomize ISN and IP ID by default; maintain up-to-date kernel patches to prevent legacy OS fingerprinting."
|
|
151
|
+
|
|
152
|
+
[power]
|
|
153
|
+
enabled = true
|
|
154
|
+
suggests = [
|
|
155
|
+
{ when_output_contains = "open_ports:80", suggest = "gobuster" },
|
|
156
|
+
{ when_output_contains = "open_ports:443", suggest = "gobuster" },
|
|
157
|
+
{ when_output_contains = "service:http", suggest = "ffuf" },
|
|
158
|
+
{ when_output_contains = "service:http", suggest = "nuclei" }
|
|
159
|
+
]
|
tools/nuclei/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Nuclei tool package."""
|