Documentation
¶
Index ¶
- type AgentInfo
- type AgentStatus
- type EncryptedWireProtocol
- type HandlerContext
- type Heartbeat
- type HeartbeatHandler
- type MessageHandler
- type MessageRouter
- func (r *MessageRouter) CreateErrorResponse(errMsg string) ([]byte, error)
- func (r *MessageRouter) CreateTaskResponse(task *pb.Task) ([]byte, error)
- func (r *MessageRouter) RegisterHandler(messageType string, handler MessageHandler)
- func (r *MessageRouter) Route(ctx *HandlerContext, messageType string, data []byte) ([]byte, error)
- type ObfuscatedWireProtocol
- type ObfuscationType
- type Registration
- type RegistrationHandler
- type ResponseType
- type Serializer
- type ServerResponse
- type SimpleWireProtocol
- type Task
- type TaskResult
- type TaskResultHandler
- type WireProtocol
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentInfo ¶
type AgentInfo struct { AgentID string `protobuf:"bytes,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` Hostname string `protobuf:"bytes,2,opt,name=hostname,proto3" json:"hostname,omitempty"` Username string `protobuf:"bytes,3,opt,name=username,proto3" json:"username,omitempty"` OSInfo string `protobuf:"bytes,4,opt,name=os_info,json=osInfo,proto3" json:"os_info,omitempty"` Architecture string `protobuf:"bytes,5,opt,name=architecture,proto3" json:"architecture,omitempty"` Capabilities []string `protobuf:"bytes,6,rep,name=capabilities,proto3" json:"capabilities,omitempty"` FirstSeen int64 `protobuf:"varint,7,opt,name=first_seen,json=firstSeen,proto3" json:"first_seen,omitempty"` LastSeen int64 `protobuf:"varint,8,opt,name=last_seen,json=lastSeen,proto3" json:"last_seen,omitempty"` }
AgentInfo represents information about an agent
type AgentStatus ¶
type AgentStatus int32
AgentStatus represents the current state of an agent
const ( AgentStatus_UNKNOWN AgentStatus = 0 AgentStatus_ACTIVE AgentStatus = 1 AgentStatus_SLEEPING AgentStatus = 2 AgentStatus_DEAD AgentStatus = 3 )
type EncryptedWireProtocol ¶
type EncryptedWireProtocol struct {
// contains filtered or unexported fields
}
EncryptedWireProtocol is a wire protocol that encrypts the message
func NewEncryptedWireProtocol ¶
func NewEncryptedWireProtocol(key []byte) *EncryptedWireProtocol
NewEncryptedWireProtocol creates a new encrypted wire protocol
type HandlerContext ¶
HandlerContext contains context information for message handlers
type Heartbeat ¶
type Heartbeat struct { AgentID string `protobuf:"bytes,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` Status AgentStatus `protobuf:"varint,3,opt,name=status,proto3,enum=proto.AgentStatus" json:"status,omitempty"` PendingTasks []string `protobuf:"bytes,4,rep,name=pending_tasks,json=pendingTasks,proto3" json:"pending_tasks,omitempty"` }
Heartbeat is used for agent-server communication
type HeartbeatHandler ¶
type HeartbeatHandler struct { // Callback function to process heartbeat OnHeartbeat func(ctx *HandlerContext, heartbeat *pb.Heartbeat) error // contains filtered or unexported fields }
HeartbeatHandler handles agent heartbeat messages
func NewHeartbeatHandler ¶
func NewHeartbeatHandler(serializer *Serializer, onHeartbeat func(ctx *HandlerContext, heartbeat *pb.Heartbeat) error) *HeartbeatHandler
NewHeartbeatHandler creates a new heartbeat handler
func (*HeartbeatHandler) Handle ¶
func (h *HeartbeatHandler) Handle(ctx *HandlerContext, data []byte) ([]byte, error)
Handle processes a heartbeat message
type MessageHandler ¶
type MessageHandler interface {
Handle(ctx *HandlerContext, data []byte) ([]byte, error)
}
MessageHandler defines the interface for all message handlers
type MessageRouter ¶
type MessageRouter struct {
// contains filtered or unexported fields
}
MessageRouter routes messages to the appropriate handler
func NewMessageRouter ¶
func NewMessageRouter(serializer *Serializer) *MessageRouter
NewMessageRouter creates a new message router
func (*MessageRouter) CreateErrorResponse ¶
func (r *MessageRouter) CreateErrorResponse(errMsg string) ([]byte, error)
CreateErrorResponse creates an error response
func (*MessageRouter) CreateTaskResponse ¶
func (r *MessageRouter) CreateTaskResponse(task *pb.Task) ([]byte, error)
CreateTaskResponse creates a response with a task for an agent
func (*MessageRouter) RegisterHandler ¶
func (r *MessageRouter) RegisterHandler(messageType string, handler MessageHandler)
RegisterHandler registers a handler for a message type
func (*MessageRouter) Route ¶
func (r *MessageRouter) Route(ctx *HandlerContext, messageType string, data []byte) ([]byte, error)
Route routes a message to the appropriate handler
type ObfuscatedWireProtocol ¶
type ObfuscatedWireProtocol struct {
// contains filtered or unexported fields
}
ObfuscatedWireProtocol is a wire protocol that obfuscates the message
func NewObfuscatedWireProtocol ¶
func NewObfuscatedWireProtocol(key []byte) *ObfuscatedWireProtocol
NewObfuscatedWireProtocol creates a new obfuscated wire protocol
type ObfuscationType ¶
type ObfuscationType int
ObfuscationType defines the type of obfuscation to apply
const ( // NoObfuscation - no obfuscation applied NoObfuscation ObfuscationType = iota // SimpleObfuscation - simple XOR obfuscation SimpleObfuscation // AESObfuscation - AES encryption obfuscation AESObfuscation )
type Registration ¶
type Registration struct { AgentInfo *AgentInfo `protobuf:"bytes,1,opt,name=agent_info,json=agentInfo,proto3" json:"agent_info,omitempty"` PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` ProtocolVersion string `protobuf:"bytes,3,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"` }
Registration is used when an agent first connects to the server
type RegistrationHandler ¶
type RegistrationHandler struct { // Callback function to process registration OnRegistration func(ctx *HandlerContext, reg *pb.Registration) error // contains filtered or unexported fields }
RegistrationHandler handles agent registration messages
func NewRegistrationHandler ¶
func NewRegistrationHandler(serializer *Serializer, onRegistration func(ctx *HandlerContext, reg *pb.Registration) error) *RegistrationHandler
NewRegistrationHandler creates a new registration handler
func (*RegistrationHandler) Handle ¶
func (h *RegistrationHandler) Handle(ctx *HandlerContext, data []byte) ([]byte, error)
Handle processes a registration message
type ResponseType ¶
type ResponseType int32
ResponseType indicates the type of server response
const ( ResponseType_NONE ResponseType = 0 ResponseType_TASK ResponseType = 1 ResponseType_CONFIG ResponseType = 2 ResponseType_ERROR ResponseType = 3 ResponseType_ACK ResponseType = 4 )
type Serializer ¶
type Serializer struct {
// contains filtered or unexported fields
}
Serializer handles protobuf message serialization and deserialization with obfuscation
func NewSerializer ¶
func NewSerializer(obfuscationType ObfuscationType, key []byte) *Serializer
NewSerializer creates a new serializer with the specified obfuscation type and key
func (*Serializer) DecodeWithLengthPrefix ¶
func (s *Serializer) DecodeWithLengthPrefix(data []byte, msg proto.Message) error
DecodeWithLengthPrefix decodes a message with a length prefix for framing
func (*Serializer) Deserialize ¶
func (s *Serializer) Deserialize(data []byte, msg proto.Message) error
Deserialize deserializes a protobuf message with optional deobfuscation
func (*Serializer) EncodeWithLengthPrefix ¶
func (s *Serializer) EncodeWithLengthPrefix(msg proto.Message) ([]byte, error)
EncodeWithLengthPrefix encodes a message with a length prefix for framing
type ServerResponse ¶
type ServerResponse struct { MessageID string `protobuf:"bytes,1,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"` Type ResponseType `protobuf:"varint,2,opt,name=type,proto3,enum=proto.ResponseType" json:"type,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` Error string `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"` }
ServerResponse is the generic response from the server
type SimpleWireProtocol ¶
type SimpleWireProtocol struct { // Header magic bytes to identify the protocol HeaderMagic []byte FooterMagic []byte }
SimpleWireProtocol is a simple wire protocol that adds a header and footer
func NewSimpleWireProtocol ¶
func NewSimpleWireProtocol() *SimpleWireProtocol
NewSimpleWireProtocol creates a new simple wire protocol
type Task ¶
type Task struct { TaskID string `protobuf:"bytes,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` Command string `protobuf:"bytes,2,opt,name=command,proto3" json:"command,omitempty"` Arguments []string `protobuf:"bytes,3,rep,name=arguments,proto3" json:"arguments,omitempty"` Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` Timeout int32 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"` }
Task represents a command to be executed by an agent
type TaskResult ¶
type TaskResult struct { TaskID string `protobuf:"bytes,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` AgentID string `protobuf:"bytes,2,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` ExitCode int32 `protobuf:"varint,3,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` Output []byte `protobuf:"bytes,4,opt,name=output,proto3" json:"output,omitempty"` Error []byte `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` }
TaskResult contains the output of an executed task
type TaskResultHandler ¶
type TaskResultHandler struct { // Callback function to process task result OnTaskResult func(ctx *HandlerContext, result *pb.TaskResult) error // contains filtered or unexported fields }
TaskResultHandler handles task result messages
func NewTaskResultHandler ¶
func NewTaskResultHandler(serializer *Serializer, onTaskResult func(ctx *HandlerContext, result *pb.TaskResult) error) *TaskResultHandler
NewTaskResultHandler creates a new task result handler
func (*TaskResultHandler) Handle ¶
func (h *TaskResultHandler) Handle(ctx *HandlerContext, data []byte) ([]byte, error)
Handle processes a task result message