--- DLL Operations --- executeInjectDll injects a reflective DLL into a process
(ctx context.Context, client *csclient.Client, beaconID string, action Action)
| 412 | |
| 413 | // executeInjectDll injects a reflective DLL into a process |
| 414 | func (e *Executor) executeInjectDll(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) { |
| 415 | pidVal, ok := action.Parameters["pid"] |
| 416 | if !ok { |
| 417 | return "", fmt.Errorf("pid parameter required for inject_dll") |
| 418 | } |
| 419 | var pid int |
| 420 | switch v := pidVal.(type) { |
| 421 | case float64: |
| 422 | pid = int(v) |
| 423 | case int: |
| 424 | pid = v |
| 425 | default: |
| 426 | return "", fmt.Errorf("pid must be a number") |
| 427 | } |
| 428 | |
| 429 | dllPath, ok := action.Parameters["dll"].(string) |
| 430 | if !ok { |
| 431 | return "", fmt.Errorf("dll parameter required for inject_dll") |
| 432 | } |
| 433 | |
| 434 | resp, err := client.InjectDll(ctx, beaconID, pid, dllPath) |
| 435 | if err != nil { |
| 436 | return "", err |
| 437 | } |
| 438 | return e.waitForOutput(ctx, client, resp.TaskID) |
| 439 | } |
| 440 | |
| 441 | // executeInjectLoadDll loads a DLL from disk via LoadLibrary |
| 442 | func (e *Executor) executeInjectLoadDll(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) { |
no test coverage detected