kmcp 0.1.5.dev0__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.
- kali_mcp/__init__.py +3 -0
- kali_mcp/__main__.py +28 -0
- kali_mcp/_version.py +24 -0
- kali_mcp/cli.py +169 -0
- kali_mcp/config.py +95 -0
- kali_mcp/db/__init__.py +1 -0
- kali_mcp/db/manager.py +248 -0
- kali_mcp/execution.py +439 -0
- kali_mcp/logging_utils.py +74 -0
- kali_mcp/models.py +51 -0
- kali_mcp/monitor/__init__.py +105 -0
- kali_mcp/monitor/sessions.py +70 -0
- kali_mcp/monitor/sse_client.py +87 -0
- kali_mcp/monitor/tui.py +364 -0
- kali_mcp/notifications.py +130 -0
- kali_mcp/prompts.py +184 -0
- kali_mcp/registry.py +33 -0
- kali_mcp/resources.py +263 -0
- kali_mcp/responses.py +39 -0
- kali_mcp/security.py +15 -0
- kali_mcp/server.py +535 -0
- kali_mcp/tools/__init__.py +125 -0
- kali_mcp/tools/amass.py +83 -0
- kali_mcp/tools/arjun.py +86 -0
- kali_mcp/tools/base.py +100 -0
- kali_mcp/tools/bettercap.py +99 -0
- kali_mcp/tools/bloodhound.py +68 -0
- kali_mcp/tools/commix.py +73 -0
- kali_mcp/tools/crackmapexec.py +100 -0
- kali_mcp/tools/dirb.py +75 -0
- kali_mcp/tools/dursgo.py +156 -0
- kali_mcp/tools/enum4linux.py +59 -0
- kali_mcp/tools/farsight.py +127 -0
- kali_mcp/tools/ffuf.py +85 -0
- kali_mcp/tools/file_download.py +119 -0
- kali_mcp/tools/file_read.py +144 -0
- kali_mcp/tools/file_write.py +141 -0
- kali_mcp/tools/flowlyt.py +88 -0
- kali_mcp/tools/generic_command.py +95 -0
- kali_mcp/tools/gobuster.py +84 -0
- kali_mcp/tools/hashcat.py +101 -0
- kali_mcp/tools/httpx.py +85 -0
- kali_mcp/tools/hydra.py +99 -0
- kali_mcp/tools/john.py +100 -0
- kali_mcp/tools/katana.py +81 -0
- kali_mcp/tools/masscan.py +85 -0
- kali_mcp/tools/medusa.py +102 -0
- kali_mcp/tools/msfconsole.py +59 -0
- kali_mcp/tools/naabu.py +100 -0
- kali_mcp/tools/netexec.py +86 -0
- kali_mcp/tools/nmap.py +94 -0
- kali_mcp/tools/normalization.py +18 -0
- kali_mcp/tools/nuclei.py +87 -0
- kali_mcp/tools/parallel_execute.py +246 -0
- kali_mcp/tools/persist.py +436 -0
- kali_mcp/tools/playbook_ad.py +99 -0
- kali_mcp/tools/playbook_engine.py +142 -0
- kali_mcp/tools/playbook_engine_tool.py +72 -0
- kali_mcp/tools/playbook_recon.py +115 -0
- kali_mcp/tools/playbook_tools.py +125 -0
- kali_mcp/tools/playbook_webapp.py +105 -0
- kali_mcp/tools/python_command.py +100 -0
- kali_mcp/tools/responder.py +85 -0
- kali_mcp/tools/searchsploit.py +123 -0
- kali_mcp/tools/spiderfoot.py +75 -0
- kali_mcp/tools/sqlmap.py +73 -0
- kali_mcp/tools/subfinder.py +69 -0
- kali_mcp/tools/theharvester.py +80 -0
- kali_mcp/tools/vault_tool.py +489 -0
- kali_mcp/tools/wfuzz.py +87 -0
- kali_mcp/tools/whatweb.py +82 -0
- kali_mcp/tools/wpscan.py +76 -0
- kali_mcp/tools/zap.py +79 -0
- kali_mcp/tools/zighound.py +139 -0
- kali_mcp/tools/zizmor.py +98 -0
- kali_mcp/utils/__init__.py +0 -0
- kali_mcp/utils/process.py +36 -0
- kali_mcp/utils/vault.py +471 -0
- kali_mcp/validation.py +82 -0
- kmcp-0.1.5.dev0.dist-info/METADATA +251 -0
- kmcp-0.1.5.dev0.dist-info/RECORD +84 -0
- kmcp-0.1.5.dev0.dist-info/WHEEL +5 -0
- kmcp-0.1.5.dev0.dist-info/entry_points.txt +4 -0
- kmcp-0.1.5.dev0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""File write tool — write/create files on the Kali machine."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import logging
|
|
7
|
+
import os
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from kali_mcp.models import ExecutionResult, ToolError, utc_now_iso
|
|
11
|
+
from kali_mcp.responses import error_response, success_response
|
|
12
|
+
from kali_mcp.tools.base import BaseTool
|
|
13
|
+
from kali_mcp.validation import validate_required
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger("kali_mcp.tools")
|
|
16
|
+
|
|
17
|
+
# Allowed directories for file writes (configurable via env)
|
|
18
|
+
import os as _os
|
|
19
|
+
|
|
20
|
+
_ALLOWED_DIRS_ENV = _os.getenv("MCP_ALLOWED_WRITE_DIRS", "")
|
|
21
|
+
ALLOWED_WRITE_DIRS = [d.strip() for d in _ALLOWED_DIRS_ENV.split(",") if d.strip()]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class FileWriteTool(BaseTool):
|
|
25
|
+
@property
|
|
26
|
+
def name(self) -> str:
|
|
27
|
+
return "file_write"
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def description(self) -> str:
|
|
31
|
+
return (
|
|
32
|
+
"Write content to a file on the Kali machine. Creates parent "
|
|
33
|
+
"directories automatically. Use for saving scan results, reports, "
|
|
34
|
+
"scripts, wordlists, configs, or any file output."
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def default_timeout(self) -> int:
|
|
39
|
+
return 30
|
|
40
|
+
|
|
41
|
+
def input_schema(self) -> dict[str, Any]:
|
|
42
|
+
return {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"properties": {
|
|
45
|
+
"path": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "Absolute path where the file will be written",
|
|
48
|
+
},
|
|
49
|
+
"content": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"description": "Content to write to the file",
|
|
52
|
+
},
|
|
53
|
+
"mode": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "Write mode: 'overwrite' (default) or 'append'",
|
|
56
|
+
"enum": ["overwrite", "append"],
|
|
57
|
+
"default": "overwrite",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
"required": ["path", "content"],
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
def validate(self, arguments: dict[str, Any]) -> None:
|
|
64
|
+
validate_required(arguments, "path")
|
|
65
|
+
validate_required(arguments, "content")
|
|
66
|
+
path = arguments["path"]
|
|
67
|
+
if not isinstance(path, str) or not path.strip():
|
|
68
|
+
raise ValueError("Path must be a non-empty string")
|
|
69
|
+
content = arguments["content"]
|
|
70
|
+
if not isinstance(content, str):
|
|
71
|
+
raise TypeError("Content must be a string")
|
|
72
|
+
# Path containment check (skip if no dirs configured = unrestricted)
|
|
73
|
+
if ALLOWED_WRITE_DIRS:
|
|
74
|
+
resolved = os.path.realpath(path)
|
|
75
|
+
if not any(resolved.startswith(d + "/") or resolved == d for d in ALLOWED_WRITE_DIRS):
|
|
76
|
+
raise ValueError(
|
|
77
|
+
f"Path not in allowed directories: {resolved}. "
|
|
78
|
+
f"Allowed: {', '.join(ALLOWED_WRITE_DIRS)}"
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
def build_command(self, arguments: dict[str, Any]) -> list[str]:
|
|
82
|
+
return ["true"]
|
|
83
|
+
|
|
84
|
+
async def execute(self, arguments: dict[str, Any]) -> dict[str, Any]:
|
|
85
|
+
try:
|
|
86
|
+
self.validate(arguments)
|
|
87
|
+
except ValueError as e:
|
|
88
|
+
return error_response(ToolError(error="Validation error", details=str(e)))
|
|
89
|
+
except Exception as e:
|
|
90
|
+
logger.exception("Tool %s failed", self.name)
|
|
91
|
+
return error_response(ToolError(error="Execution failed", details=str(e)))
|
|
92
|
+
|
|
93
|
+
path = arguments["path"]
|
|
94
|
+
content = arguments["content"]
|
|
95
|
+
mode = arguments.get("mode", "overwrite")
|
|
96
|
+
|
|
97
|
+
try:
|
|
98
|
+
os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
|
|
99
|
+
|
|
100
|
+
file_mode = "w" if mode == "overwrite" else "a"
|
|
101
|
+
with open(path, file_mode) as f: # noqa: ASYNC230
|
|
102
|
+
f.write(content)
|
|
103
|
+
|
|
104
|
+
file_size = os.path.getsize(path)
|
|
105
|
+
|
|
106
|
+
result = ExecutionResult(
|
|
107
|
+
tool=self.name,
|
|
108
|
+
command=f"write {len(content)} bytes to {path}",
|
|
109
|
+
stdout=json.dumps(
|
|
110
|
+
{
|
|
111
|
+
"path": path,
|
|
112
|
+
"mode": mode,
|
|
113
|
+
"bytes_written": len(content.encode("utf-8")),
|
|
114
|
+
"file_size": file_size,
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
stderr="",
|
|
118
|
+
exit_code=0,
|
|
119
|
+
success=True,
|
|
120
|
+
timed_out=False,
|
|
121
|
+
duration=0.0,
|
|
122
|
+
start_time=utc_now_iso(),
|
|
123
|
+
end_time=utc_now_iso(),
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
return success_response(result)
|
|
127
|
+
|
|
128
|
+
except PermissionError:
|
|
129
|
+
return error_response(
|
|
130
|
+
ToolError(
|
|
131
|
+
error="Permission denied",
|
|
132
|
+
details=f"Cannot write to {path}",
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
except OSError as e:
|
|
136
|
+
return error_response(
|
|
137
|
+
ToolError(
|
|
138
|
+
error="Write failed",
|
|
139
|
+
details=f"{type(e).__name__}: {e}",
|
|
140
|
+
)
|
|
141
|
+
)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Flowlyt CI/CD security analyzer tool."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import shlex
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from kali_mcp.execution import engine
|
|
10
|
+
from kali_mcp.models import ToolError
|
|
11
|
+
from kali_mcp.responses import error_response, success_response
|
|
12
|
+
from kali_mcp.tools.base import BaseTool
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger("kali_mcp.tools")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class FlowlytTool(BaseTool):
|
|
18
|
+
@property
|
|
19
|
+
def name(self) -> str:
|
|
20
|
+
return "flowlyt"
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def description(self) -> str:
|
|
24
|
+
return (
|
|
25
|
+
"Run Flowlyt multi-platform CI/CD security analyzer. "
|
|
26
|
+
"Scans GitHub/GitLab/Bitbucket repos and workflow files for security issues."
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def default_timeout(self) -> int:
|
|
31
|
+
return 300
|
|
32
|
+
|
|
33
|
+
def input_schema(self) -> dict[str, Any]:
|
|
34
|
+
return {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"properties": {
|
|
37
|
+
"repo": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "Repository to scan (e.g. 'owner/repo' or full URL)",
|
|
40
|
+
},
|
|
41
|
+
"workflow_file": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "Specific workflow file to scan (e.g. '.github/workflows/ci.yml')",
|
|
44
|
+
},
|
|
45
|
+
"extra_args": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "Additional Flowlyt arguments",
|
|
48
|
+
},
|
|
49
|
+
"timeout": {
|
|
50
|
+
"type": "integer",
|
|
51
|
+
"description": "Timeout in seconds (default 300)",
|
|
52
|
+
"default": 300,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
"required": ["repo"],
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
def validate(self, arguments: dict[str, Any]) -> None:
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
def build_command(self, arguments: dict[str, Any]) -> list[str]:
|
|
62
|
+
cmd = ["flowlyt", "scan"]
|
|
63
|
+
|
|
64
|
+
if arguments.get("workflow_file"):
|
|
65
|
+
cmd.extend(["--file", arguments["workflow_file"]])
|
|
66
|
+
|
|
67
|
+
cmd.append(arguments["repo"])
|
|
68
|
+
|
|
69
|
+
extra = arguments.get("extra_args")
|
|
70
|
+
if extra:
|
|
71
|
+
cmd.extend(shlex.split(extra))
|
|
72
|
+
|
|
73
|
+
return cmd
|
|
74
|
+
|
|
75
|
+
async def execute(self, arguments: dict[str, Any]) -> dict[str, Any]:
|
|
76
|
+
try:
|
|
77
|
+
self.validate(arguments)
|
|
78
|
+
except ValueError as e:
|
|
79
|
+
return error_response(ToolError(error="Validation error", details=str(e)))
|
|
80
|
+
except Exception as e:
|
|
81
|
+
logger.exception("Tool %s failed", self.name)
|
|
82
|
+
return error_response(ToolError(error="Execution failed", details=str(e)))
|
|
83
|
+
|
|
84
|
+
timeout = arguments.get("timeout", self.default_timeout)
|
|
85
|
+
cmd = self.build_command(arguments)
|
|
86
|
+
|
|
87
|
+
result = await engine.execute(cmd, tool=self.name, timeout=timeout)
|
|
88
|
+
return success_response(result)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""Generic command execution tool — the escape hatch."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from kali_mcp.execution import engine
|
|
10
|
+
from kali_mcp.models import ToolError
|
|
11
|
+
from kali_mcp.responses import error_response, success_response
|
|
12
|
+
from kali_mcp.tools.base import BaseTool
|
|
13
|
+
from kali_mcp.validation import validate_required, validate_timeout
|
|
14
|
+
|
|
15
|
+
logger = logging.getLogger("kali_mcp.tools")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class GenericCommandTool(BaseTool):
|
|
19
|
+
@property
|
|
20
|
+
def name(self) -> str:
|
|
21
|
+
return "generic_command"
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def description(self) -> str:
|
|
25
|
+
return (
|
|
26
|
+
"Execute an arbitrary shell command on the Kali machine. "
|
|
27
|
+
"Use this for any tool not listed as a native tool. "
|
|
28
|
+
"Returns stdout, stderr, exit code, and timing information."
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def default_timeout(self) -> int:
|
|
33
|
+
return 300
|
|
34
|
+
|
|
35
|
+
def input_schema(self) -> dict[str, Any]:
|
|
36
|
+
return {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"command": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "The full command string to execute (e.g. 'nmap -sV 10.0.0.1')",
|
|
42
|
+
},
|
|
43
|
+
"timeout": {
|
|
44
|
+
"type": "integer",
|
|
45
|
+
"description": "Execution timeout in seconds (default 300, max 3600)",
|
|
46
|
+
"default": 300,
|
|
47
|
+
},
|
|
48
|
+
"cwd": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Working directory for command execution (optional)",
|
|
51
|
+
"default": "",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
"required": ["command"],
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
def validate(self, arguments: dict[str, Any]) -> None:
|
|
58
|
+
validate_required(arguments, "command")
|
|
59
|
+
cmd = arguments["command"]
|
|
60
|
+
if not isinstance(cmd, str) or not cmd.strip():
|
|
61
|
+
raise ValueError("Command must be a non-empty string")
|
|
62
|
+
if "timeout" in arguments:
|
|
63
|
+
validate_timeout(arguments["timeout"])
|
|
64
|
+
|
|
65
|
+
def build_command(self, arguments: dict[str, Any]) -> str:
|
|
66
|
+
"""Return the raw shell command string — execution engine handles shell mode."""
|
|
67
|
+
return arguments["command"]
|
|
68
|
+
|
|
69
|
+
async def execute(self, arguments: dict[str, Any]) -> dict[str, Any]:
|
|
70
|
+
try:
|
|
71
|
+
self.validate(arguments)
|
|
72
|
+
except ValueError as e:
|
|
73
|
+
return error_response(ToolError(error="Validation error", details=str(e)))
|
|
74
|
+
except Exception as e:
|
|
75
|
+
logger.exception("Tool %s failed", self.name)
|
|
76
|
+
return error_response(ToolError(error="Execution failed", details=str(e)))
|
|
77
|
+
|
|
78
|
+
command_str = self.build_command(arguments)
|
|
79
|
+
timeout = arguments.get("timeout", self.default_timeout)
|
|
80
|
+
cwd = arguments.get("cwd") or None
|
|
81
|
+
env = arguments.get("env")
|
|
82
|
+
|
|
83
|
+
exec_env = os.environ.copy()
|
|
84
|
+
if env:
|
|
85
|
+
exec_env.update(env)
|
|
86
|
+
|
|
87
|
+
result = await engine.execute(
|
|
88
|
+
command=command_str,
|
|
89
|
+
tool=self.name,
|
|
90
|
+
timeout=timeout,
|
|
91
|
+
cwd=cwd,
|
|
92
|
+
env=exec_env,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
return success_response(result)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""Gobuster wrapper for directory/DNS/vhost brute-force."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from kali_mcp.tools.base import BaseTool
|
|
8
|
+
from kali_mcp.tools.normalization import NormalizedToolMixin
|
|
9
|
+
from kali_mcp.tools.persist import parse_gobuster, run_tool_with_persistence
|
|
10
|
+
from kali_mcp.validation import validate_required
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _parse(stdout: str) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:
|
|
14
|
+
return parse_gobuster(stdout), []
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class GobusterTool(BaseTool, NormalizedToolMixin):
|
|
18
|
+
_skip_central_persist = True
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def name(self) -> str:
|
|
22
|
+
return "gobuster"
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def description(self) -> str:
|
|
26
|
+
return (
|
|
27
|
+
"Gobuster directory/DNS/vhost brute-forcer. Discovered paths with "
|
|
28
|
+
"status codes are parsed into structured findings."
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def default_timeout(self) -> int:
|
|
33
|
+
return 600
|
|
34
|
+
|
|
35
|
+
def input_schema(self) -> dict[str, Any]:
|
|
36
|
+
return {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"target": {"type": "string", "description": "Target URL or host"},
|
|
40
|
+
"wordlist": {"type": "string", "description": "Path to wordlist"},
|
|
41
|
+
"mode": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "Mode: dir, dns, vhost (default dir)",
|
|
44
|
+
"enum": ["dir", "dns", "vhost"],
|
|
45
|
+
"default": "dir",
|
|
46
|
+
},
|
|
47
|
+
"extensions": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "Comma-separated extensions (e.g. php,html)",
|
|
50
|
+
},
|
|
51
|
+
"threads": {"type": "integer", "description": "Threads", "default": 10},
|
|
52
|
+
"timeout": {
|
|
53
|
+
"type": "integer",
|
|
54
|
+
"description": "Timeout in seconds",
|
|
55
|
+
"default": 600,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
"required": ["target", "wordlist"],
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
def validate(self, arguments: dict[str, Any]) -> None:
|
|
62
|
+
validate_required(arguments, "target", "wordlist")
|
|
63
|
+
|
|
64
|
+
def build_command(self, arguments: dict[str, Any]) -> list[str]:
|
|
65
|
+
mode = arguments.get("mode", "dir")
|
|
66
|
+
cmd = ["gobuster", mode, "-u", arguments["target"], "-w", arguments["wordlist"]]
|
|
67
|
+
extensions = arguments.get("extensions")
|
|
68
|
+
if extensions and mode == "dir":
|
|
69
|
+
cmd.extend(["-x", extensions])
|
|
70
|
+
cmd.extend(["-t", str(arguments.get("threads", 10))])
|
|
71
|
+
return cmd
|
|
72
|
+
|
|
73
|
+
def normalize(self, stdout: str, stderr: str, exit_code: int, **kwargs: Any) -> dict[str, Any]:
|
|
74
|
+
findings = parse_gobuster(stdout)
|
|
75
|
+
return {
|
|
76
|
+
"normalized": {
|
|
77
|
+
"paths_found": len(findings),
|
|
78
|
+
"paths": [f["url"] for f in findings],
|
|
79
|
+
"raw_output": (stdout or "").strip()[:2000],
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async def execute(self, arguments: dict[str, Any]) -> dict[str, Any]:
|
|
84
|
+
return await run_tool_with_persistence(self, arguments, parser=_parse)
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""Hashcat wrapper for GPU-accelerated hash cracking."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from kali_mcp.tools.base import BaseTool
|
|
8
|
+
from kali_mcp.tools.normalization import NormalizedToolMixin
|
|
9
|
+
from kali_mcp.tools.persist import parse_hashcat, run_tool_with_persistence
|
|
10
|
+
from kali_mcp.validation import validate_required
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _parse(stdout: str) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:
|
|
14
|
+
creds = parse_hashcat(stdout)
|
|
15
|
+
findings = [
|
|
16
|
+
{
|
|
17
|
+
"type": "cracked_password",
|
|
18
|
+
"severity": "high",
|
|
19
|
+
"title": f"Cracked hash: {c['username'][:24]}…",
|
|
20
|
+
"description": f"password={c['password']}",
|
|
21
|
+
"evidence": str(c),
|
|
22
|
+
}
|
|
23
|
+
for c in creds
|
|
24
|
+
]
|
|
25
|
+
return findings, creds
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class HashcatTool(BaseTool, NormalizedToolMixin):
|
|
29
|
+
_skip_central_persist = True
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def name(self) -> str:
|
|
33
|
+
return "hashcat"
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def description(self) -> str:
|
|
37
|
+
return (
|
|
38
|
+
"Hashcat GPU password recovery. Cracked hash:password pairs are "
|
|
39
|
+
"parsed from output and stored as credentials."
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def default_timeout(self) -> int:
|
|
44
|
+
return 900
|
|
45
|
+
|
|
46
|
+
def input_schema(self) -> dict[str, Any]:
|
|
47
|
+
return {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"properties": {
|
|
50
|
+
"hash_file": {"type": "string", "description": "Path to the hash file"},
|
|
51
|
+
"mode": {
|
|
52
|
+
"type": "integer",
|
|
53
|
+
"description": "Hash mode number (-m), e.g. 0 for MD5",
|
|
54
|
+
},
|
|
55
|
+
"wordlist": {"type": "string", "description": "Path to wordlist"},
|
|
56
|
+
"rule": {"type": "string", "description": "Rule file (-r)"},
|
|
57
|
+
"show": {
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"description": "Show cracked hashes (--show)",
|
|
60
|
+
"default": False,
|
|
61
|
+
},
|
|
62
|
+
"timeout": {
|
|
63
|
+
"type": "integer",
|
|
64
|
+
"description": "Timeout in seconds",
|
|
65
|
+
"default": 900,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
"required": ["hash_file"],
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
def validate(self, arguments: dict[str, Any]) -> None:
|
|
72
|
+
validate_required(arguments, "hash_file")
|
|
73
|
+
|
|
74
|
+
def build_command(self, arguments: dict[str, Any]) -> list[str]:
|
|
75
|
+
cmd = ["hashcat"]
|
|
76
|
+
mode = arguments.get("mode")
|
|
77
|
+
if mode is not None:
|
|
78
|
+
cmd.extend(["-m", str(mode)])
|
|
79
|
+
wordlist = arguments.get("wordlist")
|
|
80
|
+
if wordlist:
|
|
81
|
+
cmd.append(wordlist)
|
|
82
|
+
rule = arguments.get("rule")
|
|
83
|
+
if rule:
|
|
84
|
+
cmd.extend(["-r", rule])
|
|
85
|
+
if arguments.get("show"):
|
|
86
|
+
cmd.append("--show")
|
|
87
|
+
cmd.append(arguments["hash_file"])
|
|
88
|
+
return cmd
|
|
89
|
+
|
|
90
|
+
def normalize(self, stdout: str, stderr: str, exit_code: int, **kwargs: Any) -> dict[str, Any]:
|
|
91
|
+
creds = parse_hashcat(stdout)
|
|
92
|
+
return {
|
|
93
|
+
"normalized": {
|
|
94
|
+
"cracked_count": len(creds),
|
|
95
|
+
"credentials": creds,
|
|
96
|
+
"raw_output": (stdout or "").strip()[:2000],
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async def execute(self, arguments: dict[str, Any]) -> dict[str, Any]:
|
|
101
|
+
return await run_tool_with_persistence(self, arguments, parser=_parse)
|
kali_mcp/tools/httpx.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""httpx HTTP toolkit tool (ProjectDiscovery httpx-toolkit)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import shlex
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from kali_mcp.execution import engine
|
|
9
|
+
from kali_mcp.models import ToolError
|
|
10
|
+
from kali_mcp.responses import error_response, success_response
|
|
11
|
+
from kali_mcp.tools.base import BaseTool
|
|
12
|
+
from kali_mcp.validation import validate_required, validate_timeout
|
|
13
|
+
|
|
14
|
+
HTTPX_BIN = "/usr/bin/httpx-toolkit"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class HttpxTool(BaseTool):
|
|
18
|
+
@property
|
|
19
|
+
def name(self) -> str:
|
|
20
|
+
return "httpx"
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def description(self) -> str:
|
|
24
|
+
return "Run httpx for HTTP probing, technology detection, and web reconnaissance."
|
|
25
|
+
|
|
26
|
+
def input_schema(self) -> dict[str, Any]:
|
|
27
|
+
return {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"properties": {
|
|
30
|
+
"target": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "URL, domain, or IP to probe",
|
|
33
|
+
},
|
|
34
|
+
"scan_type": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "httpx flags (e.g. '-status-code -title -tech-detect')",
|
|
37
|
+
"default": "-status-code -title -tech-detect",
|
|
38
|
+
},
|
|
39
|
+
"input_file": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "Path to input file with targets (one per line)",
|
|
42
|
+
},
|
|
43
|
+
"extra_args": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "Additional httpx arguments",
|
|
46
|
+
},
|
|
47
|
+
"timeout": {
|
|
48
|
+
"type": "integer",
|
|
49
|
+
"description": "Timeout in seconds (default 300)",
|
|
50
|
+
"default": 300,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
"required": ["target"],
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
def validate(self, arguments: dict[str, Any]) -> None:
|
|
57
|
+
validate_required(arguments, "target")
|
|
58
|
+
if "timeout" in arguments:
|
|
59
|
+
validate_timeout(arguments["timeout"])
|
|
60
|
+
|
|
61
|
+
def build_command(self, arguments: dict[str, Any]) -> list[str]:
|
|
62
|
+
cmd = [HTTPX_BIN]
|
|
63
|
+
if arguments.get("input_file"):
|
|
64
|
+
cmd.extend(["-l", arguments["input_file"]])
|
|
65
|
+
elif arguments.get("target"):
|
|
66
|
+
cmd.extend(["-u", arguments["target"]])
|
|
67
|
+
scan_type = arguments.get("scan_type") or "-status-code -title -tech-detect"
|
|
68
|
+
cmd.extend(shlex.split(scan_type))
|
|
69
|
+
extra = arguments.get("extra_args")
|
|
70
|
+
if extra:
|
|
71
|
+
cmd.extend(shlex.split(extra))
|
|
72
|
+
return cmd
|
|
73
|
+
|
|
74
|
+
async def execute(self, arguments: dict[str, Any]) -> dict[str, Any]:
|
|
75
|
+
try:
|
|
76
|
+
self.validate(arguments)
|
|
77
|
+
except ValueError as e:
|
|
78
|
+
return error_response(ToolError(error="Validation error", details=str(e)))
|
|
79
|
+
return success_response(
|
|
80
|
+
await engine.execute(
|
|
81
|
+
command=self.build_command(arguments),
|
|
82
|
+
tool=self.name,
|
|
83
|
+
timeout=arguments.get("timeout", self.default_timeout),
|
|
84
|
+
)
|
|
85
|
+
)
|