executeRunAs executes a command as another user
(ctx context.Context, client *csclient.Client, beaconID string, action Action)
| 26 | |
| 27 | // executeRunAs executes a command as another user |
| 28 | func (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 |
| 52 | func (e *Executor) executeRunUnder(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) { |
no test coverage detected