base_worker

package
v0.0.0-...-76ecfd8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type C2Bridge

type C2Bridge interface {
	WorkflowActivities // Embed the common workflow activities
	// Name returns the name of the C2 server (e.g., "mythic", "cobaltstrike").
	Name() string

	// Initialize stores the client and other fields.
	Initialize(ctx context.Context, harbingerClient messagesv1.HarbingerClient, c2ServerID string, settings *messagesv1.SettingsResponse) error
	// InitializeC2 sets up the C2-specific client and performs any initial login/setup.
	// SettingsResponse is provided by the base worker.
	InitializeC2(ctx context.Context, settings *messagesv1.SettingsResponse) error

	// RunC2SpecificReaders starts all C2-specific goroutines for reading data (tasks, outputs, etc.).
	// It should use the provided context for cancellation and the WaitGroup for graceful shutdown.
	RunC2SpecificReaders(ctx context.Context, wg *sync.WaitGroup)

	// SendC2Status updates the C2 server's status.
	// (This can be handled by the base worker, but kept here if C2-specific logic is needed).
	SendC2Status(ctx context.Context, status string) error

	// RefreshC2Session attempts to refresh the C2 session (e.g., re-authenticate).
	RefreshC2Session() error

	// Stop performs any necessary stop actions for the C2 bridge (e.g., closing subscriptions).
	Stop() error
}

C2Bridge defines the interface that any specific C2 integration must implement. This decouples the generic worker logic from C2-specific interactions. It embeds the WorkflowActivities interface, meaning any C2Bridge must also implement SyncAll, RunJob, and WaitForTask.

type C2Implant

type C2Implant struct {
	InternalId   string `json:"internal_id"`
	Architecture string `json:"architecture"`
	C2Type       string `json:"c2_type"`
	OS           string `json:"os"`
	PayloadType  string `json:"payload_type"`
}

type C2Job

type C2Job struct {
	Id         string `json:"id"`
	Command    string `json:"command"`
	Arguments  string `json:"arguments"`
	InputFiles []File `json:"input_files"`
}

type C2Task

type C2Task struct {
	InternalId        string `json:"internal_id"`
	InternalImplantId string `json:"internal_implant_id"`
	Id                string `json:"id"`
	Status            string `json:"status"`
	C2ServerId        string `json:"c2_server_id"`
}

type DefaultC2Bridge

type DefaultC2Bridge struct {
	HarbingerClient messagesv1.HarbingerClient
	C2ServerID      string
	Settings        *messagesv1.SettingsResponse // The fetched settings
}

DefaultC2Bridge provides common fields and a default InitializeC2 implementation. Concrete C2Bridge implementations can embed this struct.

func (*DefaultC2Bridge) Initialize

func (d *DefaultC2Bridge) Initialize(
	ctx context.Context,
	harbingerClient messagesv1.HarbingerClient,
	c2ServerID string,
	settings *messagesv1.SettingsResponse,
) error

Initialize sets the common fields, no need to implement this yourself.

type File

type File struct {
	Id       string `json:"id"`
	Filename string `json:"filename"`
	Bucket   string `json:"bucket"`
	Path     string `json:"path"`
}

type FileEntry

type FileEntry struct {
	IsFile       bool     `json:"is_file"`
	Name         string   `json:"name"`
	Permissions  struct{} `json:"-"`
	AccessTime   int64    `json:"access_time"`
	CreationTime int64    `json:"creation_time"`
	ModifyTime   int64    `json:"modify_time"`
	Size         int64    `json:"size"`
}

type FileResponse

type FileResponse struct {
	Host         string      `json:"host"`
	IsFile       bool        `json:"is_file"`
	Success      bool        `json:"success"`
	Permissions  struct{}    `json:"-"`
	AccessTime   int64       `json:"access_time"`
	CreationTime int64       `json:"creation_time"`
	ModifyTime   int64       `json:"modify_time"`
	Size         int64       `json:"size"`
	Name         string      `json:"name"`
	ParentPath   string      `json:"parent_path"`
	Files        []FileEntry `json:"files"`
}

type HarbingerArguments

type HarbingerArguments struct {
	Sleep       *int   `json:"sleep,omitempty"`
	Jitter      *int   `json:"jitter,omitempty"`
	File        string `json:"file,omitempty"`
	Remotename  string `json:"remotename,omitempty"`
	Path        string `json:"path,omitempty"`
	Host        string `json:"host,omitempty"`
	Arguments   string `json:"arguments_str,omitempty"`
	Safe        bool   `json:"safe,omitempty"`
	Source      string `json:"source,omitempty"`
	Dest        string `json:"dest,omitempty"`
	Port        int    `json:"port,omitempty"`
	Action      string `json:"action,omitempty"`
	Command     string `json:"command,omitempty"`
	Folder      string `json:"folder,omitempty"`
	Destination string `json:"destination,omitempty"`
	Filename    string `json:"filename,omitempty"`
	Cmdline     string `json:"cmdline,omitempty"`
	Hwbp        bool   `json:"hwbp,omitempty"`
}

type InputFile

type InputFile struct {
	Id   string
	Name string
}

type Process

type Process struct {
	ProcessId       int32  `json:"process_id"`
	Architecture    string `json:"architecture"`
	Name            string `json:"name"`
	User            string `json:"user"`
	BinPath         string `json:"bin_path"`
	ParentProcessId int32  `json:"parent_process_id"`
}

type RunJob

type RunJob struct {
	C2Job     C2Job     `json:"c2_job"`
	C2Implant C2Implant `json:"c2_implant"`
}

type Task

type Task struct {
	Command   string
	Arguments string
}

type Worker

type Worker struct {
	HarbingerClient messagesv1.HarbingerClient   // Client to the main Harbinger gRPC service
	C2ServerID      string                       // Unique ID for this C2 server instance
	Hostname        string                       // Hostname where this worker is running (optional, but useful)
	Settings        *messagesv1.SettingsResponse // Settings fetched from Harbinger for this C2
	C2              C2Bridge                     // The specific C2 implementation (e.g., MythicBridge)
	// contains filtered or unexported fields
}

Worker represents the generic base worker for a C2 integration.

func NewWorker

func NewWorker(c2Bridge C2Bridge) (*Worker, error)

NewWorker initializes a new generic Worker. The `c2Bridge` parameter is the concrete implementation for a specific C2.

func (*Worker) Run

func (w *Worker) Run()

Run starts the base worker, managing goroutines, signal handling, and Temporal worker.

type WorkflowActivities

type WorkflowActivities interface {
	SyncAll(ctx context.Context) error
	RunJob(ctx context.Context, job RunJob) (C2Task, error)
	WaitForTask(ctx context.Context, task C2Task) (WorkflowStepResult, error)
}

Workflow activities common to all C2 integrations. These methods will be directly called and registered by the base worker.

type WorkflowStepResult

type WorkflowStepResult struct {
	Id      string `json:"id"`
	Status  string `json:"status"`
	ProxyId string `json:"proxy_id"`
	Output  string `json:"output"`
	Label   string `json:"label"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL