Documentation
¶
Index ¶
- Variables
- func ExecuteLuaScript(con *Console, script string) (string, error)
- func FormatResponseWithCommands(response string, commands []CommandSuggestion) string
- func HandlerTask(sess *client.Session, log *client.Logger, ctx *clientpb.TaskContext, ...)
- func Login(con *Console, config *mtls.ClientConfig) error
- func LoginWithOptions(con *Console, config *mtls.ClientConfig, options LoginOptions) error
- func NewConfigLogin(con *Console, yamlFile string) error
- func RenderTaskOutput(taskCtx *clientpb.TaskContext) (string, error)
- func RunCommand(con *Console, cmdline interface{}) (string, error)
- func WrapClientCallback(callback ImplantFuncCallback) intermediate.ImplantCallback
- func WrapImplantFunc(con *Console, fun interface{}, callback ImplantFuncCallback) *mals.MalFunction
- func WrapServerFunc(con *Console, fun interface{}) *mals.MalFunction
- type AIClient
- type BindCmds
- type ClaudeChatRequest
- type ClaudeChatResponse
- type ClaudeMessage
- type ClaudeStreamEvent
- type CommandSuggestion
- type Console
- func (c *Console) AddCommandFuncHelper(cmdName string, funcName string, example string, input, output []string) error
- func (c *Console) Context() context.Context
- func (c *Console) GetPrompt() string
- func (c *Console) GetRecentHistory(limit int) []string
- func (c *Console) ImplantMenu() *cobra.Command
- func (con *Console) InitLocalRPCServer()
- func (con *Console) InitMCPServer()
- func (c *Console) IsDaemonExecution() bool
- func (c *Console) IsMuxIndex() bool
- func (c *Console) IsNonInteractiveExecution() bool
- func (c *Console) NewConsole()
- func (c *Console) RefreshActiveSession()
- func (c *Console) RefreshCmd(sess *client.Session) int
- func (c *Console) RegisterAggressiveFunc(name string, fn interface{}, internalCallback ImplantFuncCallback, ...)
- func (c *Console) RegisterBuiltinFunc(pkg, name string, fn interface{}, callback ImplantFuncCallback) error
- func (c *Console) RegisterImplantFunc(name string, fn interface{}, bname string, bfn interface{}, ...)
- func (c *Console) RegisterServerFunc(name string, fn interface{}, helper *mals.Helper) error
- func (c *Console) Start(bindCmds ...BindCmds) error
- func (c *Console) SwitchImplant(sess *client.Session, callee string)
- func (c *Console) SyncBuildContext() context.Context
- func (c *Console) WithDaemonExecution(enabled bool) func()
- func (c *Console) WithNonInteractiveExecution(enabled bool) func()
- func (c *Console) WithREPLExecution(enabled bool) func()
- type ImplantFuncCallback
- type LocalRPC
- type LocalRPCServer
- func (s *LocalRPCServer) ExecuteCommand(ctx context.Context, req *localrpc.ExecuteCommandRequest) (*localrpc.ExecuteCommandResponse, error)
- func (s *LocalRPCServer) ExecuteLua(ctx context.Context, req *localrpc.ExecuteLuaRequest) (*localrpc.ExecuteLuaResponse, error)
- func (s *LocalRPCServer) GetGroups(ctx context.Context, req *localrpc.GetGroupsRequest) (*localrpc.GetGroupsResponse, error)
- func (s *LocalRPCServer) GetHistory(ctx context.Context, req *localrpc.GetHistoryRequest) (*localrpc.GetHistoryResponse, error)
- func (s *LocalRPCServer) GetSchemas(ctx context.Context, req *localrpc.GetSchemasRequest) (*localrpc.GetSchemasResponse, error)
- func (s *LocalRPCServer) SearchCommands(ctx context.Context, req *localrpc.SearchCommandsRequest) (*localrpc.SearchCommandsResponse, error)
- func (s *LocalRPCServer) StreamCommand(req *localrpc.ExecuteCommandRequest, ...) error
- type LoginOptions
- type MCPServer
- type Message
- type OpenAIChatRequest
- type OpenAIChatResponse
- type OpenAIStreamChunk
- type Server
- func (s *Server) AddCallback(task *clientpb.Task, callback client.TaskCallback)
- func (s *Server) AddDoneCallback(task *clientpb.Task, callback client.TaskCallback)
- func (s *Server) AddEventHook(event client.EventCondition, callback client.OnEventFunc)
- func (s *Server) EventHandler()
- func (s *Server) HandlerEvent(event *clientpb.Event)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFoundSession = errors.New("session not found") Prompt = "IoM" )
var ErrLuaVMDead = fmt.Errorf("lua vm is dead")
var ErrMCPAlreadyRunning = errors.New("mcp already running")
Functions ¶
func ExecuteLuaScript ¶ added in v0.3.0
ExecuteLuaScript 执行Lua脚本并返回结果
func FormatResponseWithCommands ¶ added in v0.3.0
func FormatResponseWithCommands(response string, commands []CommandSuggestion) string
FormatResponseWithCommands formats the AI response with numbered command suggestions
func HandlerTask ¶ added in v0.1.0
func LoginWithOptions ¶ added in v0.3.0
func LoginWithOptions(con *Console, config *mtls.ClientConfig, options LoginOptions) error
func NewConfigLogin ¶ added in v0.3.0
func RenderTaskOutput ¶ added in v0.3.0
func RenderTaskOutput(taskCtx *clientpb.TaskContext) (string, error)
func RunCommand ¶ added in v0.3.0
func WrapClientCallback ¶ added in v0.3.0
func WrapClientCallback(callback ImplantFuncCallback) intermediate.ImplantCallback
func WrapImplantFunc ¶ added in v0.3.0
func WrapImplantFunc(con *Console, fun interface{}, callback ImplantFuncCallback) *mals.MalFunction
func WrapServerFunc ¶ added in v0.3.0
func WrapServerFunc(con *Console, fun interface{}) *mals.MalFunction
Types ¶
type AIClient ¶ added in v0.3.0
type AIClient struct {
// contains filtered or unexported fields
}
AIClient handles communication with AI APIs (OpenAI and Claude)
func NewAIClient ¶ added in v0.3.0
func NewAIClient(settings *assets.AISettings) *AIClient
NewAIClient creates a new AI client
type ClaudeChatRequest ¶ added in v0.3.0
type ClaudeChatRequest struct {
Model string `json:"model"`
MaxTokens int `json:"max_tokens"`
System string `json:"system,omitempty"`
Messages []ClaudeMessage `json:"messages"`
}
Claude API structures
type ClaudeChatResponse ¶ added in v0.3.0
type ClaudeChatResponse struct {
ID string `json:"id"`
Type string `json:"type"`
Role string `json:"role"`
Content []struct {
Type string `json:"type"`
Text string `json:"text"`
} `json:"content"`
StopReason string `json:"stop_reason"`
Error *struct {
Type string `json:"type"`
Message string `json:"message"`
} `json:"error,omitempty"`
}
type ClaudeMessage ¶ added in v0.3.0
type ClaudeStreamEvent ¶ added in v0.3.0
type ClaudeStreamEvent struct {
Type string `json:"type"`
Index int `json:"index,omitempty"`
Delta *struct {
Type string `json:"type"`
Text string `json:"text"`
} `json:"delta,omitempty"`
}
Claude streaming response structures
type CommandSuggestion ¶ added in v0.3.0
CommandSuggestion represents a command extracted from AI response
func ParseCommandSuggestions ¶ added in v0.3.0
func ParseCommandSuggestions(response string) []CommandSuggestion
ParseCommandSuggestions extracts command suggestions from AI response Commands are expected to be wrapped in backticks like `command`
type Console ¶ added in v0.3.0
type Console struct {
//*core.ActiveTarget
*Server
Log *client.Logger
App *console.Console
Profile *assets.Profile
MCPAddr string
RPCAddr string
MCP *MCPServer
LocalRPC *LocalRPC
CMDs map[string]*cobra.Command
Helpers map[string]*cobra.Command
MalManager *plugin.MalManager
// ConfigPath is the auth config file path used for the current login.
// Populated by LoginCmd so the multiplexer can forward it to child processes.
ConfigPath string
// MuxChild indicates this process was spawned by the terminal multiplexer.
MuxChild bool
// Quiet suppresses notification event output, startup banners, and
// MCP/LocalRPC initialization. Used by non-index mux child panes.
// Task events (user command results) still display.
Quiet bool
// contains filtered or unexported fields
}
func (*Console) AddCommandFuncHelper ¶ added in v0.3.0
func (*Console) GetRecentHistory ¶ added in v0.3.0
func (*Console) ImplantMenu ¶ added in v0.3.0
func (*Console) InitLocalRPCServer ¶ added in v0.3.0
func (con *Console) InitLocalRPCServer()
InitLocalRPCServer 在命令注册完成后初始化 Local RPC 服务器 该函数应该在所有命令注册完成后调用,避免并发映射访问错误 Local RPC 服务器在后台 goroutine 中启动,不会阻塞主流程 Local RPC 默认关闭,需要通过 --rpc 参数或配置文件中设置 localrpc_enable: true 来启用
func (*Console) InitMCPServer ¶ added in v0.3.0
func (con *Console) InitMCPServer()
InitMCPServer 在命令注册完成后初始化 MCP 服务器 该函数应该在所有命令注册完成后调用,避免并发映射访问错误 MCP 服务器在后台 goroutine 中启动,不会阻塞主流程 MCP 默认关闭,需要通过 --mcp 参数或配置文件中设置 mcp_enable: true 来启用
func (*Console) IsDaemonExecution ¶ added in v0.3.0
func (*Console) IsMuxIndex ¶ added in v0.3.0
IsMuxIndex returns true when this process is the index (first) pane of the terminal multiplexer. The index pane acts as the notification bus — it receives all global events and intercepts `use` to open new panes via OSC.
func (*Console) IsNonInteractiveExecution ¶ added in v0.3.0
func (*Console) NewConsole ¶ added in v0.3.0
func (c *Console) NewConsole()
func (*Console) RefreshActiveSession ¶ added in v0.3.0
func (c *Console) RefreshActiveSession()
func (*Console) RegisterAggressiveFunc ¶ added in v0.3.0
func (c *Console) RegisterAggressiveFunc(name string, fn interface{}, internalCallback ImplantFuncCallback, callback intermediate.ImplantCallback)
func (*Console) RegisterBuiltinFunc ¶ added in v0.3.0
func (c *Console) RegisterBuiltinFunc(pkg, name string, fn interface{}, callback ImplantFuncCallback) error
func (*Console) RegisterImplantFunc ¶ added in v0.3.0
func (c *Console) RegisterImplantFunc(name string, fn interface{}, bname string, bfn interface{}, internalCallback ImplantFuncCallback, callback intermediate.ImplantCallback)
func (*Console) RegisterServerFunc ¶ added in v0.3.0
func (*Console) SwitchImplant ¶ added in v0.3.0
func (*Console) SyncBuildContext ¶ added in v0.3.0
func (*Console) WithDaemonExecution ¶ added in v0.3.0
func (*Console) WithNonInteractiveExecution ¶ added in v0.3.0
func (*Console) WithREPLExecution ¶ added in v0.3.0
type ImplantFuncCallback ¶ added in v0.3.0
type ImplantFuncCallback func(content *clientpb.TaskContext) (interface{}, error)
ImplantFuncCallback, function internal callback func, retrun golang struct
type LocalRPC ¶ added in v0.3.0
type LocalRPC struct {
// contains filtered or unexported fields
}
LocalRPC wraps the gRPC server instance
func NewLocalRPC ¶ added in v0.3.0
NewLocalRPC creates and starts a new LocalRPC server
type LocalRPCServer ¶ added in v0.3.0
type LocalRPCServer struct {
localrpc.UnimplementedCommandServiceServer
// contains filtered or unexported fields
}
LocalRPCServer wraps the gRPC server for local command execution
func NewLocalRPCServer ¶ added in v0.3.0
func NewLocalRPCServer(console *Console) *LocalRPCServer
NewLocalRPCServer creates a new LocalRPCServer instance
func (*LocalRPCServer) ExecuteCommand ¶ added in v0.3.0
func (s *LocalRPCServer) ExecuteCommand(ctx context.Context, req *localrpc.ExecuteCommandRequest) (*localrpc.ExecuteCommandResponse, error)
ExecuteCommand implements the CommandService.ExecuteCommand RPC method
func (*LocalRPCServer) ExecuteLua ¶ added in v0.3.0
func (s *LocalRPCServer) ExecuteLua(ctx context.Context, req *localrpc.ExecuteLuaRequest) (*localrpc.ExecuteLuaResponse, error)
ExecuteLua implements the CommandService.ExecuteLua RPC method
func (*LocalRPCServer) GetGroups ¶ added in v0.3.0
func (s *LocalRPCServer) GetGroups(ctx context.Context, req *localrpc.GetGroupsRequest) (*localrpc.GetGroupsResponse, error)
GetGroups implements the CommandService.GetGroups RPC method
func (*LocalRPCServer) GetHistory ¶ added in v0.3.0
func (s *LocalRPCServer) GetHistory(ctx context.Context, req *localrpc.GetHistoryRequest) (*localrpc.GetHistoryResponse, error)
GetHistory implements the CommandService.GetHistory RPC method
func (*LocalRPCServer) GetSchemas ¶ added in v0.3.0
func (s *LocalRPCServer) GetSchemas(ctx context.Context, req *localrpc.GetSchemasRequest) (*localrpc.GetSchemasResponse, error)
GetSchemas implements the CommandService.GetSchemas RPC method
func (*LocalRPCServer) SearchCommands ¶ added in v0.3.0
func (s *LocalRPCServer) SearchCommands(ctx context.Context, req *localrpc.SearchCommandsRequest) (*localrpc.SearchCommandsResponse, error)
SearchCommands implements the CommandService.SearchCommands RPC method
func (*LocalRPCServer) StreamCommand ¶ added in v0.3.0
func (s *LocalRPCServer) StreamCommand(req *localrpc.ExecuteCommandRequest, stream localrpc.CommandService_StreamCommandServer) error
StreamCommand executes a command and continuously streams back task event output. It is a general-purpose streaming RPC: any command that produces persistent EventTaskDone events (tapping, poison, etc.) will have its rendered output streamed to the caller.
Design:
- Register an EventHook BEFORE executing the command (no race window).
- Execute the command via cobra; read Session.LastTask for the task ID (no polling).
- EventHook filters events by task ID, renders via InternalFunctions, writes to channel.
- Main loop reads channel and streams to gRPC client.
- On context cancel: remove EventHook, return.
type LoginOptions ¶ added in v0.3.0
type LoginOptions struct {
SuppressStartupOutput bool
}
type MCPServer ¶ added in v0.3.0
type MCPServer struct {
// contains filtered or unexported fields
}
MCPServer 包装了MCP服务器实例
func (*MCPServer) AddTool ¶ added in v0.3.0
func (m *MCPServer) AddTool(tool mcp.Tool, handler server.ToolHandlerFunc)
AddTool 添加新的工具到 MCP 服务器
type OpenAIChatRequest ¶ added in v0.3.0
type OpenAIChatRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
Stream bool `json:"stream,omitempty"`
}
OpenAI API structures
type OpenAIChatResponse ¶ added in v0.3.0
type OpenAIStreamChunk ¶ added in v0.3.0
type OpenAIStreamChunk struct {
Choices []struct {
Delta struct {
Content string `json:"content"`
} `json:"delta"`
FinishReason string `json:"finish_reason"`
} `json:"choices"`
}
OpenAI streaming response structures
type Server ¶ added in v0.3.0
type Server struct {
*client.ServerState
// Quiet suppresses console event output while still updating internal state.
Quiet bool
// contains filtered or unexported fields
}
func NewServer ¶ added in v0.3.0
func NewServer(conn *grpc.ClientConn, config *mtls.ClientConfig) (*Server, error)
NewServer wraps client.ServerState into core.ServerState
func NewServerWithOptions ¶ added in v0.3.0
func NewServerWithOptions(conn *grpc.ClientConn, config *mtls.ClientConfig, suppressStartupOutput bool) (*Server, error)
func (*Server) AddCallback ¶ added in v0.3.0
func (s *Server) AddCallback(task *clientpb.Task, callback client.TaskCallback)
func (*Server) AddDoneCallback ¶ added in v0.3.0
func (s *Server) AddDoneCallback(task *clientpb.Task, callback client.TaskCallback)
func (*Server) AddEventHook ¶ added in v0.3.0
func (s *Server) AddEventHook(event client.EventCondition, callback client.OnEventFunc)
func (*Server) EventHandler ¶ added in v0.3.0
func (s *Server) EventHandler()