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

Method Handle

internal/bridge/module_exec.go:15–49  ·  view source on GitHub ↗
(ctx ModuleContext, sessionID string, taskID uint32, spite *implantpb.Spite)

Source from the content-addressed store, hash-verified

13func (m *ExecModule) Name() string { return consts.ModuleExecute }
14
15func (m *ExecModule) Handle(ctx ModuleContext, sessionID string, taskID uint32, spite *implantpb.Spite) {
16 exec := spite.GetExecRequest()
17 if exec == nil {
18 ctx.SendSpite(sessionID, taskID, execSpite("missing ExecRequest"))
19 ctx.Tasks.Fail(sessionID, taskID, "missing ExecRequest")
20 return
21 }
22
23 command := extractCommand(exec.Path, exec.Args)
24
25 sess, toolName := acquireShellSession(ctx, sessionID, taskID, m.Name())
26 if sess == nil {
27 return
28 }
29
30 result := enqueueAndAwait(ctx, sessionID, taskID, sess, toolName, command)
31 if result == nil {
32 return
33 }
34
35 resp := parseToolOutput(result.Output)
36 resp.End = true
37 resultSpite := &implantpb.Spite{
38 Name: consts.ModuleExecute,
39 Body: &implantpb.Spite_ExecResponse{ExecResponse: resp},
40 }
41
42 if err := ctx.SendSpite(sessionID, taskID, resultSpite); err != nil {
43 log.Errorf("[bridge] failed to forward exec task %d: %v", taskID, err)
44 ctx.Tasks.Fail(sessionID, taskID, err.Error())
45 } else {
46 log.Infof("[bridge] forwarded exec task %d result for session %s", taskID, sessionID)
47 ctx.Tasks.Complete(sessionID, taskID)
48 }
49}

Callers

nothing calls this directly

Calls 9

NameMethod · 0.95
execSpiteFunction · 0.85
extractCommandFunction · 0.85
acquireShellSessionFunction · 0.85
enqueueAndAwaitFunction · 0.85
parseToolOutputFunction · 0.85
FailMethod · 0.80
ErrorMethod · 0.45
CompleteMethod · 0.45

Tested by

no test coverage detected