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

Function acquireShellSession

internal/bridge/commands.go:89–107  ·  view source on GitHub ↗

acquireShellSession waits for the session and picks a shell tool. On failure it marks the task as failed and returns nil.

(ctx ModuleContext, sessionID string, taskID uint32, moduleName string)

Source from the content-addressed store, hash-verified

87// acquireShellSession waits for the session and picks a shell tool.
88// On failure it marks the task as failed and returns nil.
89func acquireShellSession(ctx ModuleContext, sessionID string, taskID uint32, moduleName string) (*sessions.Session, string) {
90 sess := ctx.WaitForSession(sessionID, DefaultSessionTimeout)
91 if sess == nil {
92 log.Warnf("[bridge] session %s not found for %s", sessionID, moduleName)
93 ctx.Tasks.Fail(sessionID, taskID, "session not found")
94 return nil, ""
95 }
96 // Re-attempt session listener now that the session exists.
97 // The initial call in handleSpiteRecv may have failed if the session
98 // was not yet created (e.g. after proxy restart).
99 ctx.Tasks.StartSessionListener(sessionID)
100 toolName := sessions.PickShellTool(sess)
101 if toolName == "" {
102 log.Warnf("[bridge] no shell tool found in session %s for %s", sessionID, moduleName)
103 ctx.Tasks.Fail(sessionID, taskID, "no shell tool")
104 return nil, ""
105 }
106 return sess, toolName
107}
108
109// enqueueAndAwait builds a PendingAction, enqueues it, binds it to the task,
110// and waits for the result. Returns nil if any step fails.

Callers 2

HandleMethod · 0.85
HandleMethod · 0.85

Calls 3

PickShellToolFunction · 0.92
FailMethod · 0.80
StartSessionListenerMethod · 0.80

Tested by

no test coverage detected