executePsInject executes unmanaged PowerShell (inject)
(ctx context.Context, client *csclient.Client, beaconID string, action Action)
| 307 | |
| 308 | // executePsInject executes unmanaged PowerShell (inject) |
| 309 | func (e *Executor) executePsInject(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) { |
| 310 | pidVal, ok := action.Parameters["pid"] |
| 311 | if !ok { |
| 312 | return "", fmt.Errorf("pid parameter required for psinject") |
| 313 | } |
| 314 | var pid int |
| 315 | switch v := pidVal.(type) { |
| 316 | case float64: |
| 317 | pid = int(v) |
| 318 | case int: |
| 319 | pid = v |
| 320 | default: |
| 321 | return "", fmt.Errorf("pid must be a number") |
| 322 | } |
| 323 | |
| 324 | arch, ok := action.Parameters["arch"].(string) |
| 325 | if !ok { |
| 326 | return "", fmt.Errorf("arch parameter required for psinject") |
| 327 | } |
| 328 | commandlet, ok := action.Parameters["commandlet"].(string) |
| 329 | if !ok { |
| 330 | return "", fmt.Errorf("commandlet parameter required for psinject") |
| 331 | } |
| 332 | args, _ := action.Parameters["args"].(string) // optional |
| 333 | |
| 334 | resp, err := client.PsInject(ctx, beaconID, pid, arch, commandlet, args) |
| 335 | if err != nil { |
| 336 | return "", err |
| 337 | } |
| 338 | return e.waitForOutput(ctx, client, resp.TaskID) |
| 339 | } |
| 340 | |
| 341 | // executeExecuteAssembly executes a .NET assembly |
| 342 | func (e *Executor) executeExecuteAssembly(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) { |
no test coverage detected