MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / extractCommand

Function extractCommand

internal/bridge/commands.go:57–71  ·  view source on GitHub ↗

extractCommand builds the actual command from an ExecRequest. The server sends Path="/bin/sh" Args=["-c","whoami"] for shell commands. We strip the shell invocation and extract the real command.

(path string, args []string)

Source from the content-addressed store, hash-verified

55// The server sends Path="/bin/sh" Args=["-c","whoami"] for shell commands.
56// We strip the shell invocation and extract the real command.
57func extractCommand(path string, args []string) string {
58 // If path is a shell and args start with "-c", extract the actual command.
59 if len(args) >= 2 && args[0] == "-c" {
60 return strings.Join(args[1:], " ")
61 }
62 // If path is a shell with /c (cmd.exe /c whoami), extract actual command.
63 if len(args) >= 2 && strings.EqualFold(args[0], "/c") {
64 return strings.Join(args[1:], " ")
65 }
66 // Otherwise, treat as path + args.
67 if len(args) > 0 {
68 return path + " " + strings.Join(args, " ")
69 }
70 return path
71}
72
73// ---------------------------------------------------------------------------
74// Shared module execution helpers

Callers 1

HandleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected