mirror of
https://github.com/gsmith257-cyber/better-sliver
synced 2026-06-06 15:44:30 +00:00
Revert "attempt to remove BeaconID sig"
This reverts commit c094bd7582.
This commit is contained in:
@@ -39,7 +39,7 @@ func Commands(con *console.SliverClient) []*cobra.Command {
|
||||
f.StringP("filter-re", "e", "", "filter beacons by regular expression")
|
||||
})
|
||||
flags.BindFlagCompletions(beaconsCmd, func(comp *carapace.ActionMap) {
|
||||
(*comp)["kill"] = BaconIDCompleter(con)
|
||||
(*comp)["kill"] = BeaconIDCompleter(con)
|
||||
})
|
||||
beaconsRmCmd := &cobra.Command{
|
||||
Use: consts.RmStr,
|
||||
@@ -49,7 +49,7 @@ func Commands(con *console.SliverClient) []*cobra.Command {
|
||||
BeaconsRmCmd(cmd, con, args)
|
||||
},
|
||||
}
|
||||
carapace.Gen(beaconsRmCmd).PositionalCompletion(BaconIDCompleter(con))
|
||||
carapace.Gen(beaconsRmCmd).PositionalCompletion(BeaconIDCompleter(con))
|
||||
beaconsCmd.AddCommand(beaconsRmCmd)
|
||||
|
||||
beaconsWatchCmd := &cobra.Command{
|
||||
@@ -78,8 +78,8 @@ func Commands(con *console.SliverClient) []*cobra.Command {
|
||||
return []*cobra.Command{beaconsCmd}
|
||||
}
|
||||
|
||||
// BaconIDCompleter completes beacon IDs
|
||||
func BaconIDCompleter(con *console.SliverClient) carapace.Action {
|
||||
// BeaconIDCompleter completes beacon IDs
|
||||
func BeaconIDCompleter(con *console.SliverClient) carapace.Action {
|
||||
callback := func(_ carapace.Context) carapace.Action {
|
||||
results := make([]string, 0)
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ func KillBeacon(beacon *clientpb.Beacon, cmd *cobra.Command, con *console.Sliver
|
||||
|
||||
_, err := con.Rpc.Kill(context.Background(), &sliverpb.KillReq{
|
||||
Request: &commonpb.Request{
|
||||
BaconID: beacon.ID,
|
||||
BeaconID: beacon.ID,
|
||||
Timeout: timeout,
|
||||
},
|
||||
Force: force,
|
||||
|
||||
@@ -152,7 +152,7 @@ func getPID(session *clientpb.Session, beacon *clientpb.Beacon) int32 {
|
||||
}
|
||||
|
||||
func updateBeaconIntegrityInformation(con *console.SliverClient, beaconID string, integrity string) error {
|
||||
_, err := con.Rpc.UpdateBeaconIntegrityInformation(context.Background(), &clientpb.BeaconIntegrity{BaconID: beaconID,
|
||||
_, err := con.Rpc.UpdateBeaconIntegrityInformation(context.Background(), &clientpb.BeaconIntegrity{BeaconID: beaconID,
|
||||
Integrity: integrity})
|
||||
|
||||
return err
|
||||
|
||||
@@ -50,7 +50,7 @@ func RenameCmd(cmd *cobra.Command, con *console.SliverClient, args []string) {
|
||||
}
|
||||
_, err := con.Rpc.Rename(context.Background(), &clientpb.RenameReq{
|
||||
SessionID: sessionID,
|
||||
BaconID: beaconID,
|
||||
BeaconID: beaconID,
|
||||
Name: name,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -243,7 +243,7 @@ func renderTaskResponse(task *clientpb.BeaconTask, con *console.SliverClient) {
|
||||
con.PrintErrorf("Failed to decode task response: %s\n", err)
|
||||
return
|
||||
}
|
||||
beacon, _ := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BaconID})
|
||||
beacon, _ := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BeaconID})
|
||||
hostname := "hostname"
|
||||
if beacon != nil {
|
||||
hostname = beacon.Hostname
|
||||
@@ -304,7 +304,7 @@ func renderTaskResponse(task *clientpb.BeaconTask, con *console.SliverClient) {
|
||||
con.PrintErrorf("Failed to decode task response: %s\n", err)
|
||||
return
|
||||
}
|
||||
beacon, _ := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BaconID})
|
||||
beacon, _ := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BeaconID})
|
||||
hostname := "hostname"
|
||||
if beacon != nil {
|
||||
hostname = beacon.Hostname
|
||||
@@ -326,7 +326,7 @@ func renderTaskResponse(task *clientpb.BeaconTask, con *console.SliverClient) {
|
||||
con.PrintErrorf("Failed to decode task response: %s\n", err)
|
||||
return
|
||||
}
|
||||
beacon, _ := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BaconID})
|
||||
beacon, _ := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BeaconID})
|
||||
hostname := "hostname"
|
||||
if beacon != nil {
|
||||
hostname = beacon.Hostname
|
||||
@@ -504,7 +504,7 @@ func renderTaskResponse(task *clientpb.BeaconTask, con *console.SliverClient) {
|
||||
con.PrintErrorf("Failed to decode task response: %s\n", err)
|
||||
return
|
||||
}
|
||||
beacon, err := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BaconID})
|
||||
beacon, err := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BeaconID})
|
||||
if err != nil {
|
||||
con.PrintErrorf("Failed to fetch beacon: %s\n", err)
|
||||
return
|
||||
@@ -521,7 +521,7 @@ func renderTaskResponse(task *clientpb.BeaconTask, con *console.SliverClient) {
|
||||
con.PrintErrorf("Failed to decode task response: %s\n", err)
|
||||
return
|
||||
}
|
||||
beacon, err := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BaconID})
|
||||
beacon, err := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BeaconID})
|
||||
if err != nil {
|
||||
con.PrintErrorf("Failed to fetch beacon: %s\n", err)
|
||||
return
|
||||
@@ -588,7 +588,7 @@ func renderTaskResponse(task *clientpb.BeaconTask, con *console.SliverClient) {
|
||||
con.PrintErrorf("Failed to decode task request: %s\n", err)
|
||||
return
|
||||
}
|
||||
beacon, err := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BaconID})
|
||||
beacon, err := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BeaconID})
|
||||
if err != nil {
|
||||
con.PrintErrorf("Failed to fetch beacon: %s\n", err)
|
||||
return
|
||||
@@ -614,7 +614,7 @@ func renderTaskResponse(task *clientpb.BeaconTask, con *console.SliverClient) {
|
||||
con.PrintErrorf("Failed to decode task response: %s\n", err)
|
||||
return
|
||||
}
|
||||
beacon, err := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BaconID})
|
||||
beacon, err := con.Rpc.GetBeacon(context.Background(), &clientpb.Beacon{ID: task.BeaconID})
|
||||
if err != nil {
|
||||
con.PrintErrorf("Failed to get beacon: %s\n", err)
|
||||
return
|
||||
|
||||
@@ -47,7 +47,7 @@ func Commands(con *console.SliverClient) []*cobra.Command {
|
||||
UseBeaconCmd(cmd, con, args)
|
||||
},
|
||||
}
|
||||
carapace.Gen(useBeaconCmd).PositionalCompletion(beacons.BaconIDCompleter(con))
|
||||
carapace.Gen(useBeaconCmd).PositionalCompletion(beacons.BeaconIDCompleter(con))
|
||||
useCmd.AddCommand(useBeaconCmd)
|
||||
|
||||
return []*cobra.Command{useCmd}
|
||||
|
||||
@@ -189,7 +189,7 @@ func BeaconAndSessionIDCompleter(con *console.SliverClient) carapace.Action {
|
||||
|
||||
return action.Invoke(ctx).Merge(
|
||||
SessionIDCompleter(con).Invoke(ctx),
|
||||
beacons.BaconIDCompleter(con).Invoke(ctx),
|
||||
beacons.BeaconIDCompleter(con).Invoke(ctx),
|
||||
).ToA()
|
||||
}
|
||||
|
||||
|
||||
@@ -374,7 +374,7 @@ func (con *SliverClient) triggerBeaconTaskCallback(data []byte) {
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
beacon, _ := con.Rpc.GetBeacon(ctx, &clientpb.Beacon{ID: task.BaconID})
|
||||
beacon, _ := con.Rpc.GetBeacon(ctx, &clientpb.Beacon{ID: task.BeaconID})
|
||||
|
||||
// If the callback is not in our map then we don't do anything, the beacon task
|
||||
// was either issued by another operator in multiplayer mode or the client process
|
||||
@@ -764,7 +764,7 @@ func (s *ActiveTarget) Request(cmd *cobra.Command) *commonpb.Request {
|
||||
}
|
||||
if s.beacon != nil {
|
||||
req.Async = true
|
||||
req.BaconID = s.beacon.ID
|
||||
req.BeaconID = s.beacon.ID
|
||||
}
|
||||
return req
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ func getConsoleAsciicastFile() *os.File {
|
||||
func (con *SliverClient) PrintAsyncResponse(resp *commonpb.Response) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
beacon, err := con.Rpc.GetBeacon(ctx, &clientpb.Beacon{ID: resp.BaconID})
|
||||
beacon, err := con.Rpc.GetBeacon(ctx, &clientpb.Beacon{ID: resp.BeaconID})
|
||||
if err != nil {
|
||||
con.PrintWarnf(err.Error())
|
||||
return
|
||||
|
||||
@@ -1792,7 +1792,7 @@ type BeaconTask struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
|
||||
BaconID string `protobuf:"bytes,2,opt,name=BaconID,proto3" json:"BaconID,omitempty"`
|
||||
BeaconID string `protobuf:"bytes,2,opt,name=BeaconID,proto3" json:"BeaconID,omitempty"`
|
||||
CreatedAt int64 `protobuf:"varint,3,opt,name=CreatedAt,proto3" json:"CreatedAt,omitempty"`
|
||||
State string `protobuf:"bytes,4,opt,name=State,proto3" json:"State,omitempty"`
|
||||
SentAt int64 `protobuf:"varint,5,opt,name=SentAt,proto3" json:"SentAt,omitempty"`
|
||||
@@ -1841,9 +1841,9 @@ func (x *BeaconTask) GetID() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *BeaconTask) GetBaconID() string {
|
||||
func (x *BeaconTask) GetBeaconID() string {
|
||||
if x != nil {
|
||||
return x.BaconID
|
||||
return x.BeaconID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -1902,7 +1902,7 @@ type BaconTasks struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
BaconID string `protobuf:"bytes,1,opt,name=BaconID,proto3" json:"BaconID,omitempty"`
|
||||
BeaconID string `protobuf:"bytes,1,opt,name=BeaconID,proto3" json:"BeaconID,omitempty"`
|
||||
Tasks []*BeaconTask `protobuf:"bytes,2,rep,name=Tasks,proto3" json:"Tasks,omitempty"`
|
||||
}
|
||||
|
||||
@@ -1938,9 +1938,9 @@ func (*BaconTasks) Descriptor() ([]byte, []int) {
|
||||
return file_clientpb_client_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *BaconTasks) GetBaconID() string {
|
||||
func (x *BaconTasks) GetBeaconID() string {
|
||||
if x != nil {
|
||||
return x.BaconID
|
||||
return x.BeaconID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -1957,7 +1957,7 @@ type BeaconIntegrity struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
BaconID string `protobuf:"bytes,1,opt,name=BaconID,proto3" json:"BaconID,omitempty"`
|
||||
BeaconID string `protobuf:"bytes,1,opt,name=BeaconID,proto3" json:"BeaconID,omitempty"`
|
||||
Integrity string `protobuf:"bytes,2,opt,name=Integrity,proto3" json:"Integrity,omitempty"`
|
||||
}
|
||||
|
||||
@@ -1993,9 +1993,9 @@ func (*BeaconIntegrity) Descriptor() ([]byte, []int) {
|
||||
return file_clientpb_client_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *BeaconIntegrity) GetBaconID() string {
|
||||
func (x *BeaconIntegrity) GetBeaconID() string {
|
||||
if x != nil {
|
||||
return x.BaconID
|
||||
return x.BeaconID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -4897,7 +4897,7 @@ type RenameReq struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
SessionID string `protobuf:"bytes,1,opt,name=SessionID,proto3" json:"SessionID,omitempty"`
|
||||
BaconID string `protobuf:"bytes,2,opt,name=BaconID,proto3" json:"BaconID,omitempty"`
|
||||
BeaconID string `protobuf:"bytes,2,opt,name=BeaconID,proto3" json:"BeaconID,omitempty"`
|
||||
Name string `protobuf:"bytes,3,opt,name=Name,proto3" json:"Name,omitempty"`
|
||||
}
|
||||
|
||||
@@ -4940,9 +4940,9 @@ func (x *RenameReq) GetSessionID() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RenameReq) GetBaconID() string {
|
||||
func (x *RenameReq) GetBeaconID() string {
|
||||
if x != nil {
|
||||
return x.BaconID
|
||||
return x.BeaconID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ message Beacons { repeated Beacon Beacons = 2; }
|
||||
|
||||
message BeaconTask {
|
||||
string ID = 1;
|
||||
string BaconID = 2;
|
||||
string BeaconID = 2;
|
||||
int64 CreatedAt = 3;
|
||||
string State = 4;
|
||||
int64 SentAt = 5;
|
||||
@@ -108,12 +108,12 @@ message BeaconTask {
|
||||
}
|
||||
|
||||
message BaconTasks {
|
||||
string BaconID = 1;
|
||||
string BeaconID = 1;
|
||||
repeated BeaconTask Tasks = 2;
|
||||
}
|
||||
|
||||
message BeaconIntegrity {
|
||||
string BaconID = 1;
|
||||
string BeaconID = 1;
|
||||
string Integrity = 2;
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ message Sessions {
|
||||
|
||||
message RenameReq {
|
||||
string SessionID = 1;
|
||||
string BaconID = 2;
|
||||
string BeaconID = 2;
|
||||
string Name = 3;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ type Request struct {
|
||||
|
||||
Async bool `protobuf:"varint,1,opt,name=Async,proto3" json:"Async,omitempty"`
|
||||
Timeout int64 `protobuf:"varint,2,opt,name=Timeout,proto3" json:"Timeout,omitempty"`
|
||||
BaconID string `protobuf:"bytes,8,opt,name=BaconID,proto3" json:"BaconID,omitempty"`
|
||||
BeaconID string `protobuf:"bytes,8,opt,name=BeaconID,proto3" json:"BeaconID,omitempty"`
|
||||
SessionID string `protobuf:"bytes,9,opt,name=SessionID,proto3" json:"SessionID,omitempty"`
|
||||
}
|
||||
|
||||
@@ -116,9 +116,9 @@ func (x *Request) GetTimeout() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Request) GetBaconID() string {
|
||||
func (x *Request) GetBeaconID() string {
|
||||
if x != nil {
|
||||
return x.BaconID
|
||||
return x.BeaconID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -141,7 +141,7 @@ type Response struct {
|
||||
|
||||
Err string `protobuf:"bytes,1,opt,name=Err,proto3" json:"Err,omitempty"`
|
||||
Async bool `protobuf:"varint,2,opt,name=Async,proto3" json:"Async,omitempty"`
|
||||
BaconID string `protobuf:"bytes,8,opt,name=BaconID,proto3" json:"BaconID,omitempty"`
|
||||
BeaconID string `protobuf:"bytes,8,opt,name=BeaconID,proto3" json:"BeaconID,omitempty"`
|
||||
TaskID string `protobuf:"bytes,9,opt,name=TaskID,proto3" json:"TaskID,omitempty"`
|
||||
}
|
||||
|
||||
@@ -191,9 +191,9 @@ func (x *Response) GetAsync() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *Response) GetBaconID() string {
|
||||
func (x *Response) GetBeaconID() string {
|
||||
if x != nil {
|
||||
return x.BaconID
|
||||
return x.BeaconID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ message Request {
|
||||
bool Async = 1;
|
||||
int64 Timeout = 2;
|
||||
|
||||
string BaconID = 8;
|
||||
string BeaconID = 8;
|
||||
string SessionID = 9;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ message Request {
|
||||
message Response {
|
||||
string Err = 1;
|
||||
bool Async = 2;
|
||||
string BaconID = 8;
|
||||
string BeaconID = 8;
|
||||
string TaskID = 9;
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -922,10 +922,10 @@ func BeaconByID(id string) (*models.Beacon, error) {
|
||||
return beacon, err
|
||||
}
|
||||
|
||||
// BeaconTasksByBaconID - Get all tasks for a specific beacon
|
||||
// BeaconTasksByBeaconID - Get all tasks for a specific beacon
|
||||
// by default will not fetch the request/response columns since
|
||||
// these could be arbitrarily large.
|
||||
func BeaconTasksByBaconID(beaconID string) ([]*clientpb.BeaconTask, error) {
|
||||
func BeaconTasksByBeaconID(beaconID string) ([]*clientpb.BeaconTask, error) {
|
||||
if len(beaconID) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
@@ -935,9 +935,9 @@ func BeaconTasksByBaconID(beaconID string) ([]*clientpb.BeaconTask, error) {
|
||||
}
|
||||
BaconTasks := []*models.BeaconTask{}
|
||||
err := Session().Select([]string{
|
||||
"ID", "EnvelopeID", "BaconID", "CreatedAt", "State", "SentAt", "CompletedAt",
|
||||
"ID", "EnvelopeID", "BeaconID", "CreatedAt", "State", "SentAt", "CompletedAt",
|
||||
"Description",
|
||||
}).Where(&models.BeaconTask{BaconID: id}).Find(&BaconTasks).Error
|
||||
}).Where(&models.BeaconTask{BeaconID: id}).Find(&BaconTasks).Error
|
||||
|
||||
pbBeaconTasks := []*clientpb.BeaconTask{}
|
||||
for _, beaconTask := range BaconTasks {
|
||||
@@ -996,8 +996,8 @@ func RenameBeacon(id string, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// PendingBeaconTasksByBaconID - Select a Beacon by ID, ordered by creation time
|
||||
func PendingBeaconTasksByBaconID(id string) ([]*models.BeaconTask, error) {
|
||||
// PendingBeaconTasksByBeaconID - Select a Beacon by ID, ordered by creation time
|
||||
func PendingBeaconTasksByBeaconID(id string) ([]*models.BeaconTask, error) {
|
||||
if len(id) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
@@ -1008,7 +1008,7 @@ func PendingBeaconTasksByBaconID(id string) ([]*models.BeaconTask, error) {
|
||||
tasks := []*models.BeaconTask{}
|
||||
err := Session().Where(
|
||||
&models.BeaconTask{
|
||||
BaconID: beaconID,
|
||||
BeaconID: beaconID,
|
||||
State: models.PENDING,
|
||||
},
|
||||
).Order("created_at").Find(&tasks).Error
|
||||
@@ -1046,7 +1046,7 @@ func BeaconTaskByEnvelopeID(beaconID string, envelopeID int64) (*clientpb.Beacon
|
||||
task := &models.BeaconTask{}
|
||||
err := Session().Where(
|
||||
&models.BeaconTask{
|
||||
BaconID: beaconUUID,
|
||||
BeaconID: beaconUUID,
|
||||
EnvelopeID: envelopeID,
|
||||
State: models.SENT,
|
||||
},
|
||||
@@ -1054,8 +1054,8 @@ func BeaconTaskByEnvelopeID(beaconID string, envelopeID int64) (*clientpb.Beacon
|
||||
return task.ToProtobuf(true), err
|
||||
}
|
||||
|
||||
// CountTasksByBaconID - Select a (sent) BeaconTask by its envelope ID
|
||||
func CountTasksByBaconID(beaconID string) (int64, int64, error) {
|
||||
// CountTasksByBeaconID - Select a (sent) BeaconTask by its envelope ID
|
||||
func CountTasksByBeaconID(beaconID string) (int64, int64, error) {
|
||||
beaconUUID, _ := uuid.FromString(beaconID)
|
||||
if beaconUUID == uuid.Nil {
|
||||
return 0, 0, ErrRecordNotFound
|
||||
@@ -1064,7 +1064,7 @@ func CountTasksByBaconID(beaconID string) (int64, int64, error) {
|
||||
completedTasks := int64(0)
|
||||
err := Session().Model(&models.BeaconTask{}).Where(
|
||||
&models.BeaconTask{
|
||||
BaconID: beaconUUID,
|
||||
BeaconID: beaconUUID,
|
||||
},
|
||||
).Count(&allTasks).Error
|
||||
if err != nil {
|
||||
@@ -1072,7 +1072,7 @@ func CountTasksByBaconID(beaconID string) (int64, int64, error) {
|
||||
}
|
||||
err = Session().Model(&models.BeaconTask{}).Where(
|
||||
&models.BeaconTask{
|
||||
BaconID: beaconUUID,
|
||||
BeaconID: beaconUUID,
|
||||
State: models.COMPLETED,
|
||||
},
|
||||
).Count(&completedTasks).Error
|
||||
|
||||
@@ -106,7 +106,7 @@ func (b *Beacon) Task(envelope *sliverpb.Envelope) (*BeaconTask, error) {
|
||||
return nil, err
|
||||
}
|
||||
task := &BeaconTask{
|
||||
BaconID: b.ID,
|
||||
BeaconID: b.ID,
|
||||
State: PENDING,
|
||||
Request: data,
|
||||
}
|
||||
@@ -124,7 +124,7 @@ const (
|
||||
type BeaconTask struct {
|
||||
ID uuid.UUID `gorm:"primaryKey;->;<-:create;type:uuid;"`
|
||||
EnvelopeID int64 `gorm:"uniqueIndex"`
|
||||
BaconID uuid.UUID `gorm:"type:uuid;"`
|
||||
BeaconID uuid.UUID `gorm:"type:uuid;"`
|
||||
CreatedAt time.Time `gorm:"->;<-:create;"`
|
||||
State string
|
||||
SentAt int64
|
||||
@@ -154,7 +154,7 @@ func (b *BeaconTask) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
func (b *BeaconTask) ToProtobuf(content bool) *clientpb.BeaconTask {
|
||||
task := &clientpb.BeaconTask{
|
||||
ID: b.ID.String(),
|
||||
BaconID: b.BaconID.String(),
|
||||
BeaconID: b.BeaconID.String(),
|
||||
CreatedAt: b.CreatedAt.Unix(),
|
||||
State: b.State,
|
||||
SentAt: b.SentAt,
|
||||
|
||||
@@ -149,7 +149,7 @@ func beaconTasksHandler(implantConn *core.ImplantConnection, data []byte) *slive
|
||||
beaconHandlerLog.Infof("Beacon %s requested pending task(s)", BaconTasks.ID)
|
||||
|
||||
// Pending tasks are ordered by their creation time.
|
||||
pendingTasks, err := db.PendingBeaconTasksByBaconID(BaconTasks.ID)
|
||||
pendingTasks, err := db.PendingBeaconTasksByBeaconID(BaconTasks.ID)
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
beaconHandlerLog.Errorf("Beacon task database error: %s", err)
|
||||
return nil
|
||||
|
||||
@@ -27,8 +27,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrInvalidBaconID - Invalid Beacon ID in request
|
||||
ErrInvalidBaconID = status.Error(codes.InvalidArgument, "Invalid beacon ID")
|
||||
// ErrInvalidBeaconID - Invalid Beacon ID in request
|
||||
ErrInvalidBeaconID = status.Error(codes.InvalidArgument, "Invalid beacon ID")
|
||||
// ErrInvalidBeaconTaskID - Invalid Beacon ID in request
|
||||
ErrInvalidBeaconTaskID = status.Error(codes.InvalidArgument, "Invalid beacon task ID")
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (rpc *Server) GetBeacons(ctx context.Context, req *commonpb.Empty) (*client
|
||||
return nil, ErrDatabaseFailure
|
||||
}
|
||||
for id, beacon := range beacons {
|
||||
all, completed, err := db.CountTasksByBaconID(beacon.ID)
|
||||
all, completed, err := db.CountTasksByBeaconID(beacon.ID)
|
||||
if err != nil {
|
||||
beaconRpcLog.Errorf("Task count failed: %s", err)
|
||||
}
|
||||
@@ -65,11 +65,11 @@ func (rpc *Server) RmBeacon(ctx context.Context, req *clientpb.Beacon) (*commonp
|
||||
beacon, err := db.BeaconByID(req.ID)
|
||||
if err != nil {
|
||||
beaconRpcLog.Error(err)
|
||||
return nil, ErrInvalidBaconID
|
||||
return nil, ErrInvalidBeaconID
|
||||
}
|
||||
|
||||
err = db.Session().Where(&models.BeaconTask{
|
||||
BaconID: beacon.ID},
|
||||
BeaconID: beacon.ID},
|
||||
).Delete(&models.BeaconTask{}).Error
|
||||
if err != nil {
|
||||
beaconRpcLog.Errorf("Database error: %s", err)
|
||||
@@ -87,9 +87,9 @@ func (rpc *Server) RmBeacon(ctx context.Context, req *clientpb.Beacon) (*commonp
|
||||
func (rpc *Server) GetBeaconTasks(ctx context.Context, req *clientpb.Beacon) (*clientpb.BaconTasks, error) {
|
||||
beacon, err := db.BeaconByID(req.ID)
|
||||
if err != nil {
|
||||
return nil, ErrInvalidBaconID
|
||||
return nil, ErrInvalidBeaconID
|
||||
}
|
||||
tasks, err := db.BeaconTasksByBaconID(beacon.ID.String())
|
||||
tasks, err := db.BeaconTasksByBeaconID(beacon.ID.String())
|
||||
return &clientpb.BaconTasks{Tasks: tasks}, err
|
||||
}
|
||||
|
||||
@@ -129,9 +129,9 @@ func (rpc *Server) CancelBeaconTask(ctx context.Context, req *clientpb.BeaconTas
|
||||
// UpdateBeaconIntegrityInformation - Update process integrity information for a beacon
|
||||
func (rpc *Server) UpdateBeaconIntegrityInformation(ctx context.Context, req *clientpb.BeaconIntegrity) (*commonpb.Empty, error) {
|
||||
resp := &commonpb.Empty{}
|
||||
beacon, err := db.BeaconByID(req.BaconID)
|
||||
beacon, err := db.BeaconByID(req.BeaconID)
|
||||
if err != nil || beacon == nil {
|
||||
return resp, ErrInvalidBaconID
|
||||
return resp, ErrInvalidBeaconID
|
||||
}
|
||||
beacon.Integrity = req.Integrity
|
||||
err = db.Session().Save(beacon).Error
|
||||
|
||||
@@ -39,9 +39,9 @@ func (rpc *Server) Kill(ctx context.Context, kill *sliverpb.KillReq) (*commonpb.
|
||||
)
|
||||
session := core.Sessions.Get(kill.Request.SessionID)
|
||||
if session == nil {
|
||||
beacon, err = db.BeaconByID(kill.Request.BaconID)
|
||||
beacon, err = db.BeaconByID(kill.Request.BeaconID)
|
||||
if err != nil {
|
||||
return &commonpb.Empty{}, ErrInvalidBaconID
|
||||
return &commonpb.Empty{}, ErrInvalidBeaconID
|
||||
} else {
|
||||
return rpc.killBeacon(kill, beacon)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func (rpc *Server) killBeacon(kill *sliverpb.KillReq, beacon *models.Beacon) (*c
|
||||
request := kill.GetRequest()
|
||||
request.SessionID = ""
|
||||
request.Async = true
|
||||
request.BaconID = beacon.ID.String()
|
||||
request.BeaconID = beacon.ID.String()
|
||||
reqData, err := proto.Marshal(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -52,13 +52,13 @@ func (rpc *Server) Msf(ctx context.Context, req *clientpb.MSFReq) (*sliverpb.Tas
|
||||
os = session.OS
|
||||
arch = session.Arch
|
||||
} else {
|
||||
beacon, err := db.BeaconByID(req.Request.BaconID)
|
||||
beacon, err := db.BeaconByID(req.Request.BeaconID)
|
||||
if err != nil {
|
||||
msfLog.Errorf("%s\n", err)
|
||||
return nil, ErrDatabaseFailure
|
||||
}
|
||||
if beacon == nil {
|
||||
return nil, ErrInvalidBaconID
|
||||
return nil, ErrInvalidBeaconID
|
||||
}
|
||||
os = beacon.OS
|
||||
arch = beacon.Arch
|
||||
@@ -104,13 +104,13 @@ func (rpc *Server) MsfRemote(ctx context.Context, req *clientpb.MSFRemoteReq) (*
|
||||
os = session.OS
|
||||
arch = session.Arch
|
||||
} else {
|
||||
beacon, err := db.BeaconByID(req.Request.BaconID)
|
||||
beacon, err := db.BeaconByID(req.Request.BeaconID)
|
||||
if err != nil {
|
||||
msfLog.Errorf("%s\n", err)
|
||||
return nil, ErrDatabaseFailure
|
||||
}
|
||||
if beacon == nil {
|
||||
return nil, ErrInvalidBaconID
|
||||
return nil, ErrInvalidBeaconID
|
||||
}
|
||||
os = beacon.OS
|
||||
arch = beacon.Arch
|
||||
|
||||
@@ -35,7 +35,7 @@ const maxNameLength = 32
|
||||
func (rpc *Server) Reconfigure(ctx context.Context, req *sliverpb.ReconfigureReq) (*sliverpb.Reconfigure, error) {
|
||||
// We have to preserve these because GenericHandler clears them in req.Request
|
||||
sessionID := req.Request.SessionID
|
||||
beaconID := req.Request.BaconID
|
||||
beaconID := req.Request.BeaconID
|
||||
|
||||
resp := &sliverpb.Reconfigure{Response: &commonpb.Response{}}
|
||||
err := rpc.GenericHandler(req, resp)
|
||||
@@ -56,7 +56,7 @@ func (rpc *Server) Reconfigure(ctx context.Context, req *sliverpb.ReconfigureReq
|
||||
} else if beaconID != "" {
|
||||
beacon, err := db.BeaconByID(beaconID)
|
||||
if err != nil || beacon == nil {
|
||||
return nil, ErrInvalidBaconID
|
||||
return nil, ErrInvalidBeaconID
|
||||
}
|
||||
if req.BaconInterval != 0 {
|
||||
beacon.Interval = req.BaconInterval
|
||||
@@ -91,10 +91,10 @@ func (rpc *Server) Rename(ctx context.Context, req *clientpb.RenameReq) (*common
|
||||
return nil, ErrInvalidSessionID
|
||||
}
|
||||
session.Name = req.Name
|
||||
} else if req.BaconID != "" {
|
||||
beacon, err := db.BeaconByID(req.BaconID)
|
||||
} else if req.BeaconID != "" {
|
||||
beacon, err := db.BeaconByID(req.BeaconID)
|
||||
if err != nil || beacon == nil {
|
||||
return nil, ErrInvalidBaconID
|
||||
return nil, ErrInvalidBeaconID
|
||||
}
|
||||
err = db.RenameBeacon(beacon.ID.String(), req.Name)
|
||||
if err != nil {
|
||||
|
||||
@@ -73,14 +73,14 @@ func (rpc *Server) Migrate(ctx context.Context, req *clientpb.MigrateReq) (*sliv
|
||||
return nil, ErrInvalidSessionID
|
||||
}
|
||||
} else { // then it must be a beacon
|
||||
dbBeacon, err = db.BeaconByID(req.Request.BaconID)
|
||||
dbBeacon, err = db.BeaconByID(req.Request.BeaconID)
|
||||
if err != nil {
|
||||
tasksLog.Errorf("%s", err)
|
||||
return nil, ErrDatabaseFailure
|
||||
}
|
||||
beacon = dbBeacon.ToProtobuf()
|
||||
if beacon == nil {
|
||||
return nil, ErrInvalidBaconID
|
||||
return nil, ErrInvalidBeaconID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,14 +183,14 @@ func (rpc *Server) ExecuteAssembly(ctx context.Context, req *sliverpb.ExecuteAss
|
||||
return nil, ErrInvalidSessionID
|
||||
}
|
||||
} else {
|
||||
dbBeacon, err = db.BeaconByID(req.Request.BaconID)
|
||||
dbBeacon, err = db.BeaconByID(req.Request.BeaconID)
|
||||
if err != nil {
|
||||
tasksLog.Errorf("%s", err)
|
||||
return nil, ErrDatabaseFailure
|
||||
}
|
||||
beacon = dbBeacon.ToProtobuf()
|
||||
if beacon == nil {
|
||||
return nil, ErrInvalidBaconID
|
||||
return nil, ErrInvalidBeaconID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,14 +253,14 @@ func (rpc *Server) Sideload(ctx context.Context, req *sliverpb.SideloadReq) (*sl
|
||||
}
|
||||
arch = session.Arch
|
||||
} else {
|
||||
dbBeacon, err = db.BeaconByID(req.Request.BaconID)
|
||||
dbBeacon, err = db.BeaconByID(req.Request.BeaconID)
|
||||
if err != nil {
|
||||
msfLog.Errorf("%s", err)
|
||||
return nil, ErrDatabaseFailure
|
||||
}
|
||||
beacon = dbBeacon.ToProtobuf()
|
||||
if beacon == nil {
|
||||
return nil, ErrInvalidBaconID
|
||||
return nil, ErrInvalidBeaconID
|
||||
}
|
||||
arch = beacon.Arch
|
||||
}
|
||||
@@ -300,14 +300,14 @@ func (rpc *Server) SpawnDll(ctx context.Context, req *sliverpb.InvokeSpwnDllReq)
|
||||
return nil, ErrInvalidSessionID
|
||||
}
|
||||
} else {
|
||||
dbBeacon, err = db.BeaconByID(req.Request.BaconID)
|
||||
dbBeacon, err = db.BeaconByID(req.Request.BeaconID)
|
||||
if err != nil {
|
||||
msfLog.Errorf("%s", err)
|
||||
return nil, ErrDatabaseFailure
|
||||
}
|
||||
beacon = dbBeacon.ToProtobuf()
|
||||
if beacon == nil {
|
||||
return nil, ErrInvalidBaconID
|
||||
return nil, ErrInvalidBeaconID
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -140,22 +140,22 @@ func (rpc *Server) asyncGenericHandler(req GenericRequest, resp GenericResponse)
|
||||
return ErrMissingRequestField
|
||||
}
|
||||
|
||||
beacon, err := db.BeaconByID(request.BaconID)
|
||||
beacon, err := db.BeaconByID(request.BeaconID)
|
||||
if beacon == nil || err != nil {
|
||||
rpcLog.Errorf("Invalid beacon ID in request: %s", err)
|
||||
return ErrInvalidBaconID
|
||||
return ErrInvalidBeaconID
|
||||
}
|
||||
|
||||
// Overwrite unused implant fields before re-serializing
|
||||
request.SessionID = ""
|
||||
request.BaconID = ""
|
||||
request.BeaconID = ""
|
||||
reqData, err := proto.Marshal(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
taskResponse := resp.GetResponse()
|
||||
taskResponse.Async = true
|
||||
taskResponse.BaconID = beacon.ID.String()
|
||||
taskResponse.BeaconID = beacon.ID.String()
|
||||
task, err := beacon.Task(&sliverpb.Envelope{
|
||||
Type: sliverpb.MsgNumber(req),
|
||||
Data: reqData,
|
||||
|
||||
@@ -353,8 +353,8 @@ func getActiveTarget(rawRequest []byte) (*clientpb.Session, *clientpb.Beacon, er
|
||||
|
||||
middlewareLog.Debugf("RPC Request: %v", rpcRequest)
|
||||
|
||||
if rawBaconID, ok := rpcRequest["BaconID"]; ok {
|
||||
beaconID := rawBaconID.(string)
|
||||
if rawBeaconID, ok := rpcRequest["BeaconID"]; ok {
|
||||
beaconID := rawBeaconID.(string)
|
||||
middlewareLog.Debugf("Found Beacon ID: %s", beaconID)
|
||||
beacon, err := db.BeaconByID(beaconID)
|
||||
middlewareLog.Infof("query complete")
|
||||
|
||||
Reference in New Issue
Block a user