core

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Sessions - Manages implant connections
	Sessions = &sessions{
		active: &sync.Map{},
	}
	ExtensionModules = []string{consts.ModuleExecuteBof, consts.ModuleExecuteDll}
	// ErrUnknownMessageType - Returned if the implant did not understand the message for
	//                         example when the command is not supported on the platform
	ErrUnknownMessageType = errors.New("unknown message type")

	// ErrImplantSendTimeout - The implant did not respond prior to timeout deadline
	ErrImplantSendTimeout = errors.New("implant timeout")
)
View Source
var (
	// Clients - Manages client active
	Clients = &clients{
		mutex:  &sync.Mutex{},
		active: map[int]*Client{},
	}
)
View Source
var (
	Connections = &connections{
		connections: &sync.Map{},
	}
)
View Source
var (
	// EventBroker - Distributes event messages
	EventBroker = newBroker()
)
View Source
var (
	Forwarders = &forwarders{
		forwarders: &sync.Map{},
	}
)
View Source
var (
	Jobs = &jobs{
		Map:  &sync.Map{},
		Ctrl: make(chan *clientpb.JobCtrl),
	}
)
View Source
var (
	Listeners = listeners{
		&sync.Map{},
	}
)

Functions

func CurrentJobID

func CurrentJobID() uint32

func NextCtrlID

func NextCtrlID() uint32

func NextJobID

func NextJobID() uint32

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache(maxSize int, savePath string) *Cache

func (*Cache) AddMessage

func (c *Cache) AddMessage(spite *implantpb.Spite, cur int)

func (*Cache) GetAll

func (c *Cache) GetAll()

func (*Cache) GetLastMessage

func (c *Cache) GetLastMessage(taskID int) (*implantpb.Spite, bool)

func (*Cache) GetMessage

func (c *Cache) GetMessage(taskID, cur int) (*implantpb.Spite, bool)

func (*Cache) GetMessages

func (c *Cache) GetMessages(taskID int) ([]*implantpb.Spite, bool)

func (*Cache) Load

func (c *Cache) Load() error

func (*Cache) Save

func (c *Cache) Save() error

func (*Cache) SetSize

func (c *Cache) SetSize(size int)

type Client

type Client struct {
	*clientpb.Client
}

Client - Single client connection

func NewClient

func NewClient(operatorName string) *Client

NewClient - Create a new client object

func (*Client) ToProtobuf

func (c *Client) ToProtobuf() *clientpb.Client

type Connection

type Connection struct {
	RawID       []byte
	SessionID   string
	LastMessage time.Time
	C           chan *implantpb.Spite // spite
	Sender      chan *implantpb.Spites
	Alive       bool
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(rawid []byte) *Connection

func (*Connection) Send

func (c *Connection) Send(ctx context.Context, conn net.Conn)

type Event

type Event struct {
	Session *Session
	Job     *Job
	Client  *Client
	Task    *Task

	EventType  string
	SourceName string
	Message    string
	Data       []byte
	Err        string
}

type Forward

type Forward struct {
	Pipeline

	ImplantRpc  listenerrpc.ImplantRPCClient
	ListenerRpc listenerrpc.ListenerRPCClient
	// contains filtered or unexported fields
}

Forward is a struct that handles messages from listener and server

func NewForward

func NewForward(conn *grpc.ClientConn, pipeline Pipeline) (*Forward, error)

func (*Forward) Add

func (f *Forward) Add(msg *Message)

func (*Forward) Count

func (f *Forward) Count() int

func (*Forward) Handler

func (f *Forward) Handler()

Handler is a loop that handles messages from implant

type Job

type Job struct {
	ID           uint32
	Message      proto.Message
	JobCtrl      chan bool
	PersistentID string
}

func (*Job) ToProtobuf

func (j *Job) ToProtobuf() *clientpb.Job

type Listener

type Listener struct {
	Name      string
	Host      string
	Active    bool
	Pipelines Pipelines
}

func (*Listener) ToProtobuf

func (l *Listener) ToProtobuf() *clientpb.Listener

type Message

type Message struct {
	proto.Message
	SessionID  string
	MessageID  string
	RemoteAddr string
}

type Pipeline

type Pipeline interface {
	ID() string
	Start() error
	Addr() string
	Close() error
	ToProtobuf() proto.Message
	ToTLSProtobuf() proto.Message
}

type Pipelines

type Pipelines map[string]Pipeline

func (Pipelines) Add

func (ps Pipelines) Add(p Pipeline)

func (Pipelines) Get

func (ps Pipelines) Get(id string) Pipeline

func (Pipelines) ToProtobuf

func (ps Pipelines) ToProtobuf() *lispb.Pipelines

type Session

type Session struct {
	PipelineID string
	ID         string
	Name       string
	Group      string
	RemoteAddr string
	Os         *implantpb.Os
	Process    *implantpb.Process
	Timer      *implantpb.Timer
	Filepath   string
	WordDir    string
	ProxyURL   string
	Modules    []string
	Extensions *implantpb.Extensions
	Locale     string
	Tasks      *Tasks // task manager

	*Cache
	// contains filtered or unexported fields
}

Session - Represents a connection to an implant

func NewSession

func NewSession(req *lispb.RegisterSession) *Session

func (*Session) AllTask

func (s *Session) AllTask() []*Task

func (*Session) DeleteResp

func (s *Session) DeleteResp(taskId uint32)

func (*Session) GetResp

func (s *Session) GetResp(taskId uint32) (chan *implantpb.Spite, bool)

func (*Session) Logger

func (s *Session) Logger() *logs.Logger

func (*Session) NewTask

func (s *Session) NewTask(name string, total int) *Task

func (*Session) Request

func (s *Session) Request(msg *lispb.SpiteSession, stream grpc.ServerStream, timeout time.Duration) error

Request

func (*Session) RequestAndWait

func (s *Session) RequestAndWait(msg *lispb.SpiteSession, stream grpc.ServerStream, timeout time.Duration) (*implantpb.Spite, error)

func (*Session) RequestWithAsync

func (s *Session) RequestWithAsync(msg *lispb.SpiteSession, stream grpc.ServerStream, timeout time.Duration) (chan *implantpb.Spite, error)

func (*Session) RequestWithStream

func (s *Session) RequestWithStream(msg *lispb.SpiteSession, stream grpc.ServerStream, timeout time.Duration) (chan *implantpb.Spite, chan *implantpb.Spite, error)

RequestWithStream - 'async' means that the response is not returned immediately, but is returned through the channel 'ch

func (*Session) SetLastTaskId

func (s *Session) SetLastTaskId(id uint32)

func (*Session) StoreResp

func (s *Session) StoreResp(taskId uint32, ch chan *implantpb.Spite)

func (*Session) ToProtobuf

func (s *Session) ToProtobuf() *clientpb.Session

func (*Session) Update

func (s *Session) Update(req *lispb.RegisterSession)

func (*Session) UpdateLastCheckin

func (s *Session) UpdateLastCheckin()

func (*Session) UpdateSysInfo

func (s *Session) UpdateSysInfo(info *implantpb.SysInfo)

type Task

type Task struct {
	Id        uint32
	Type      string
	SessionId string
	Cur       int
	Total     int
	Callback  func()
	Ctx       context.Context
	Cancel    context.CancelFunc
	Status    *implantpb.Spite //
	// contains filtered or unexported fields
}

func (*Task) Close

func (t *Task) Close()

func (*Task) Done

func (t *Task) Done(event Event)

func (*Task) Finish

func (t *Task) Finish()

func (*Task) Handler

func (t *Task) Handler()

func (*Task) Name

func (t *Task) Name() string

func (*Task) Panic

func (t *Task) Panic(event Event, status *implantpb.Spite)

func (*Task) Percent

func (t *Task) Percent() string

func (*Task) String

func (t *Task) String() string

func (*Task) ToProtobuf

func (t *Task) ToProtobuf() *clientpb.Task

type Tasks

type Tasks struct {
	// contains filtered or unexported fields
}

func (*Tasks) Add

func (t *Tasks) Add(task *Task)

func (*Tasks) All

func (t *Tasks) All() []*Task

All - Return a list of all tasks

func (*Tasks) Get

func (t *Tasks) Get(taskID uint32) *Task

get

func (*Tasks) Remove

func (t *Tasks) Remove(task *Task)

func (*Tasks) ToProtobuf

func (t *Tasks) ToProtobuf() *clientpb.Tasks

type Ticker

type Ticker struct {
	// contains filtered or unexported fields
}
var (
	GlobalTicker *Ticker
)

func NewTicker

func NewTicker() *Ticker

func (*Ticker) Remove

func (t *Ticker) Remove(id cron.EntryID)

func (*Ticker) RemoveAll

func (t *Ticker) RemoveAll()

func (*Ticker) Start

func (t *Ticker) Start(interval int, cmd func()) (cron.EntryID, error)

type Website

type Website interface {
	ID() string
	Start() error
	Addr() string
	Close() error
	ToProtobuf() proto.Message
	ToTLSProtobuf() proto.Message
}

type Websites

type Websites map[string]Website

func (Websites) Add

func (web Websites) Add(w Website)

func (Websites) Get

func (web Websites) Get(id string) Website

Jump to

Keyboard shortcuts

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