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

Method executePsInject

workflow/executor_spawn.go:309–339  ·  view source on GitHub ↗

executePsInject executes unmanaged PowerShell (inject)

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

Source from the content-addressed store, hash-verified

307
308// executePsInject executes unmanaged PowerShell (inject)
309func (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
342func (e *Executor) executeExecuteAssembly(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