MCPcopy Create free account
hub / github.com/Xenov-X/csbot / executeRunAs

Method executeRunAs

workflow/executor_spawn.go:28–49  ·  view source on GitHub ↗

executeRunAs executes a command as another user

(ctx context.Context, client *csclient.Client, beaconID string, action Action)

Source from the content-addressed store, hash-verified

26
27// executeRunAs executes a command as another user
28func (e *Executor) executeRunAs(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) {
29 user, ok := action.Parameters["user"].(string)
30 if !ok {
31 return "", fmt.Errorf("user parameter required for runas")
32 }
33 password, ok := action.Parameters["password"].(string)
34 if !ok {
35 return "", fmt.Errorf("password parameter required for runas")
36 }
37 command, ok := action.Parameters["command"].(string)
38 if !ok {
39 return "", fmt.Errorf("command parameter required for runas")
40 }
41 domain, _ := action.Parameters["domain"].(string) // optional
42 args, _ := action.Parameters["args"].(string) // optional
43
44 resp, err := client.RunAs(ctx, beaconID, domain, user, password, command, args)
45 if err != nil {
46 return "", err
47 }
48 return e.waitForOutput(ctx, client, resp.TaskID)
49}
50
51// executeRunUnder executes a command with specified PID as parent
52func (e *Executor) executeRunUnder(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) {

Callers 1

executeActionMethod · 0.95

Calls 1

waitForOutputMethod · 0.95

Tested by

no test coverage detected