fix(server): convert command list to string - #49
Conversation
Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com>
There was a problem hiding this comment.
Great fix! This resolves the issue effectively for most cases.
One small suggestion worth considering: using shlex.quote when joining
the list would make it more robust against arguments that contain spaces,
such as passwords with spaces in the Hydra endpoint or file paths with
spaces in the John endpoint.
For example, with the current fix:
["hydra", "-t", "4", "-l", "admin", "-p", "my secret pass", "192.168.1.1", "ssh"]
# becomes → "hydra -t 4 -l admin -p my secret pass 192.168.1.1 ssh"
# shell splits "my secret pass" into 3 separate arguments ❌
With shlex.quote:
command = " ".join(shlex.quote(c) for c in command)
# becomes → "hydra -t 4 -l admin -p 'my secret pass' 192.168.1.1 ssh"
# shell treats 'my secret pass' as a single argument ✅
The suggested change would be:
def execute_command(command) -> Dict[str, Any]:
if isinstance(command, list):
command = " ".join(shlex.quote(c) for c in command) # shlex.quote instead of just join
executor = CommandExecutor(command)
return executor.execute()I tested both versions locally and confirmed the difference in the server logs:
# join only
Executing command: hydra -t 4 -l admin -p minha senha secreta 127.0.0.1 ssh
# shlex.quote
Executing command: hydra -t 4 -l admin -p 'minha senha secreta' 127.0.0.1 ssh
Since shlex is already imported in the file, it would be a one-word change.
That said, for typical pentesting targets (IPs, domains) this PR works perfectly as-is. 👍
Tested on: Kali Linux 2026.1 (ARM64) — MacBook M4 Pro Apple Silicon
|
Added |
|
This bug has been officially tracked in the Kali Linux Bug Tracker as #0009610, confirming it affects users of the mcp-kali-server apt package. Since the apt package is built from this repo's main branch, merging this PR would resolve the issue for all Kali users installing via |
As discussed in #46 the MCP server throws the following error:
I confirmed that the solution provided by @0liwer in #46 (comment) is working:
Add type conversion in execute_command() — this fixes ALL
endpoints at once without changing every individual endpoint: