-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbeacons.go
More file actions
74 lines (66 loc) · 2.78 KB
/
beacons.go
File metadata and controls
74 lines (66 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package csclient
import (
"context"
"fmt"
)
// ListBeacons retrieves all beacons
func (c *Client) ListBeacons(ctx context.Context) ([]BeaconDto, error) {
var beacons []BeaconDto
if err := c.doRequest(ctx, "GET", "/api/v1/beacons", nil, &beacons, true); err != nil {
return nil, fmt.Errorf("failed to list beacons: %w", err)
}
return beacons, nil
}
// GetBeacon retrieves information about a specific beacon
func (c *Client) GetBeacon(ctx context.Context, bid string) (*BeaconDto, error) {
var beacon BeaconDto
if err := c.doRequest(ctx, "GET", fmt.Sprintf("/api/v1/beacons/%s", bid), nil, &beacon, true); err != nil {
return nil, fmt.Errorf("failed to get beacon: %w", err)
}
return &beacon, nil
}
// ExecuteBOFString executes a BOF with string arguments
func (c *Client) ExecuteBOFString(ctx context.Context, bid string, req InlineExecuteStringDto) (*AsyncCommandResponse, error) {
var resp AsyncCommandResponse
path := fmt.Sprintf("/api/v1/beacons/%s/execute/bof/string", bid)
if err := c.doRequest(ctx, "POST", path, req, &resp, true); err != nil {
return nil, fmt.Errorf("failed to execute BOF: %w", err)
}
return &resp, nil
}
// ExecuteBOFPacked executes a BOF with packed arguments
func (c *Client) ExecuteBOFPacked(ctx context.Context, bid string, req InlineExecutePackedDto) (*AsyncCommandResponse, error) {
var resp AsyncCommandResponse
path := fmt.Sprintf("/api/v1/beacons/%s/execute/bof/packed", bid)
if err := c.doRequest(ctx, "POST", path, req, &resp, true); err != nil {
return nil, fmt.Errorf("failed to execute BOF: %w", err)
}
return &resp, nil
}
// ExecuteBOFPack executes a BOF with typed arguments
func (c *Client) ExecuteBOFPack(ctx context.Context, bid string, req InlineExecutePackDto) (*AsyncCommandResponse, error) {
var resp AsyncCommandResponse
path := fmt.Sprintf("/api/v1/beacons/%s/execute/bof/pack", bid)
if err := c.doRequest(ctx, "POST", path, req, &resp, true); err != nil {
return nil, fmt.Errorf("failed to execute BOF: %w", err)
}
return &resp, nil
}
// GetUID executes the getuid command (whoami equivalent)
func (c *Client) GetUID(ctx context.Context, bid string) (*AsyncCommandResponse, error) {
var resp AsyncCommandResponse
path := fmt.Sprintf("/api/v1/beacons/%s/execute/getUid", bid)
if err := c.doRequest(ctx, "POST", path, EmptyDto{}, &resp, true); err != nil {
return nil, fmt.Errorf("failed to execute getuid: %w", err)
}
return &resp, nil
}
// GetSystem attempts to elevate to SYSTEM
func (c *Client) GetSystem(ctx context.Context, bid string) (*AsyncCommandResponse, error) {
var resp AsyncCommandResponse
path := fmt.Sprintf("/api/v1/beacons/%s/execute/getSystem", bid)
if err := c.doRequest(ctx, "POST", path, EmptyDto{}, &resp, true); err != nil {
return nil, fmt.Errorf("failed to execute getsystem: %w", err)
}
return &resp, nil
}