executeConsoleCommand executes a console command on the beacon
(ctx context.Context, client *csclient.Client, beaconID string, action Action)
| 230 | |
| 231 | // executeConsoleCommand executes a console command on the beacon |
| 232 | func (e *Executor) executeConsoleCommand(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) { |
| 233 | command, ok := action.Parameters["command"].(string) |
| 234 | if !ok { |
| 235 | return "", fmt.Errorf("command parameter required for console_command") |
| 236 | } |
| 237 | |
| 238 | arguments, _ := action.Parameters["arguments"].(string) // optional |
| 239 | |
| 240 | // Files parameter is optional, parse if present |
| 241 | var files map[string]string |
| 242 | if filesInterface, ok := action.Parameters["files"].(map[string]interface{}); ok { |
| 243 | files = make(map[string]string) |
| 244 | for k, v := range filesInterface { |
| 245 | if strVal, ok := v.(string); ok { |
| 246 | files[k] = strVal |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | resp, err := client.ConsoleCommand(ctx, beaconID, command, arguments, files) |
| 252 | if err != nil { |
| 253 | return "", err |
| 254 | } |
| 255 | return e.waitForOutput(ctx, client, resp.TaskID) |
| 256 | } |
| 257 | |
| 258 | // executeListJobs lists all active jobs for the specified beacon |
| 259 | func (e *Executor) executeListJobs(ctx context.Context, client *csclient.Client, beaconID string) (string, error) { |
no test coverage detected