Help us shape the future of Go! Take the 2026 Go Developer Survey

core

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LogLevel = logs.WarnLevel
	Stdout   = NewStdoutWrapper(os.Stdout)
	Log      = &Logger{Logger: NewLog(LogLevel)}
	MuteLog  = &Logger{Logger: NewLog(logs.ImportantLevel + 1)}
)
View Source
var (
	NewLine                    = "\x1b[1E"
	Debug           logs.Level = 10
	Warn            logs.Level = 20
	Info            logs.Level = 30
	Error           logs.Level = 40
	Important       logs.Level = 50
	GroupStyle                 = lipgloss.NewStyle().Foreground(lipgloss.Color("#8BE9FD"))
	NameStyle                  = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF79C6"))
	DefaultLogStyle            = map[logs.Level]string{
		Debug:     NewLine + tui.BlueBg.Bold(true).Render(tui.Rocket+"[+]") + " %s",
		Warn:      NewLine + tui.YellowBg.Bold(true).Render(tui.Zap+"[warn]") + " %s",
		Important: NewLine + tui.PurpleBg.Bold(true).Render(tui.Fire+"[*]") + " %s",
		Info:      NewLine + tui.GreenBg.Bold(true).Render(tui.HotSpring+"[i]") + " %s",
		Error:     NewLine + tui.RedBg.Bold(true).Render(tui.Monster+"[-]") + " %s",
	}
)
View Source
var ErrLuaVMDead = fmt.Errorf("lua vm is dead")

Functions

func HandlerTask added in v0.1.0

func HandlerTask(sess *Session, ctx *clientpb.TaskContext, message []byte, callee string, isFinish bool)

func NewLog added in v0.1.0

func NewLog(level logs.Level) *logs.Logger

func RemoveANSI added in v0.1.0

func RemoveANSI(s string) string

Types

type ActiveTarget

type ActiveTarget struct {
	Session *Session
}

func (*ActiveTarget) Background

func (s *ActiveTarget) Background()

Background - Background the active session

func (*ActiveTarget) Context

func (s *ActiveTarget) Context() context.Context

func (*ActiveTarget) Get

func (s *ActiveTarget) Get() *Session

GetSessionInteractive - Get the active target(s)

func (*ActiveTarget) GetInteractive

func (s *ActiveTarget) GetInteractive() *Session

func (*ActiveTarget) Set

func (s *ActiveTarget) Set(session *Session)

Set - Change the active session

type LogEntry added in v0.1.0

type LogEntry struct {
	Timestamp time.Time
	Data      []byte
}

type Logger

type Logger struct {
	*logs.Logger
	// contains filtered or unexported fields
}

func NewLogger added in v0.1.0

func NewLogger(filename string) *Logger

func (*Logger) FileLog added in v0.1.0

func (l *Logger) FileLog(s string)

type Rpc added in v0.0.3

type ServerStatus

type ServerStatus struct {
	*Rpc
	Info   *clientpb.Basic
	Client *clientpb.Client
	*ActiveTarget
	Clients   []*clientpb.Client
	Listeners map[string]*clientpb.Listener
	Pipelines map[string]*clientpb.Pipeline
	Sessions  map[string]*Session
	Observers map[string]*Session

	EventStatus   bool
	EventHook     map[intermediate.EventCondition][]intermediate.OnEventFunc
	EventCallback map[string]func(*clientpb.Event)
	// contains filtered or unexported fields
}

func InitServerStatus

func InitServerStatus(conn *grpc.ClientConn, config *mtls.ClientConfig) (*ServerStatus, error)

func (*ServerStatus) AddCallback

func (s *ServerStatus) AddCallback(task *clientpb.Task, callback TaskCallback)

func (*ServerStatus) AddDoneCallback

func (s *ServerStatus) AddDoneCallback(task *clientpb.Task, callback TaskCallback)

func (*ServerStatus) AddEventHook added in v0.0.3

func (s *ServerStatus) AddEventHook(event intermediate.EventCondition, callback intermediate.OnEventFunc)

func (*ServerStatus) AddObserver

func (s *ServerStatus) AddObserver(session *Session) string

func (*ServerStatus) AddSession added in v0.0.3

func (s *ServerStatus) AddSession(sess *clientpb.Session) *Session

func (*ServerStatus) AlivedSessions

func (s *ServerStatus) AlivedSessions() []*clientpb.Session

func (*ServerStatus) EventHandler

func (s *ServerStatus) EventHandler()

func (*ServerStatus) GetLocalSession added in v0.1.0

func (s *ServerStatus) GetLocalSession(sid string) (*Session, bool)

func (*ServerStatus) GetOrUpdateSession added in v0.1.1

func (s *ServerStatus) GetOrUpdateSession(sid string) (*Session, error)

func (*ServerStatus) ObserverLog

func (s *ServerStatus) ObserverLog(sessionId string) *Logger

func (*ServerStatus) RemoveObserver

func (s *ServerStatus) RemoveObserver(observerID string)

func (*ServerStatus) Update added in v0.1.0

func (s *ServerStatus) Update() error

func (*ServerStatus) UpdateListener added in v0.0.3

func (s *ServerStatus) UpdateListener() error

func (*ServerStatus) UpdatePipeline added in v0.1.0

func (s *ServerStatus) UpdatePipeline() error

func (*ServerStatus) UpdateSession

func (s *ServerStatus) UpdateSession(sid string) (*Session, error)

func (*ServerStatus) UpdateSessions

func (s *ServerStatus) UpdateSessions(all bool) error

func (*ServerStatus) UpdateTasks

func (s *ServerStatus) UpdateTasks(session *Session) error

type Session

type Session struct {
	*clientpb.Session

	Data     *types.SessionContext
	Server   *ServerStatus
	Callee   string // cmd/mal/sdk
	LastTask *clientpb.Task
	Log      *Logger
	Locker   *sync.Mutex
	// contains filtered or unexported fields
}

func NewSession

func NewSession(sess *clientpb.Session, server *ServerStatus) *Session

func (*Session) Clone added in v0.0.3

func (s *Session) Clone(callee string) *Session

func (*Session) Console

func (s *Session) Console(task *clientpb.Task, msg string)

func (*Session) Context

func (s *Session) Context() context.Context

func (*Session) Error

func (s *Session) Error(task *clientpb.Task, err error)

func (*Session) GetAddon

func (s *Session) GetAddon(name string) *implantpb.Addon

func (*Session) GetHistory added in v0.0.3

func (s *Session) GetHistory()

func (*Session) HasAddon

func (s *Session) HasAddon(addon string) bool

func (*Session) HasDepend

func (s *Session) HasDepend(module string) bool

func (*Session) HasTask

func (s *Session) HasTask(taskId uint32) bool

func (*Session) Value added in v0.1.0

func (s *Session) Value(key string) (string, error)

func (*Session) WithValue added in v0.1.0

func (s *Session) WithValue(kv ...string) (*Session, error)

type StdoutWrapper added in v0.1.0

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

func NewStdoutWrapper added in v0.1.0

func NewStdoutWrapper(stdout io.Writer) *StdoutWrapper

func (*StdoutWrapper) GetBuffer added in v0.1.0

func (w *StdoutWrapper) GetBuffer() []LogEntry

func (*StdoutWrapper) Range added in v0.1.0

func (w *StdoutWrapper) Range(start, end time.Time) string

func (*StdoutWrapper) RemoveOldestEntries added in v0.1.0

func (w *StdoutWrapper) RemoveOldestEntries(count int)

RemoveOldestEntries 删除指定数量的最早日志条目

func (*StdoutWrapper) Write added in v0.1.0

func (w *StdoutWrapper) Write(p []byte) (n int, err error)

Write 实现 io.Writer 接口

type TaskCallback

type TaskCallback func(resp *clientpb.TaskContext)

Jump to

Keyboard shortcuts

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