Documentation ¶
Index ¶
- Constants
- func OptsModule(L *lua.LState) *lua.LTable
- type CmdArgs
- func (args *CmdArgs) Array() []string
- func (args *CmdArgs) ArrayWithCommand(cmd string) []string
- func (args *CmdArgs) ForEach(callback func(string, any))
- func (args *CmdArgs) Get(key string) any
- func (args *CmdArgs) Parse()
- func (args *CmdArgs) ParseOpts(optsConfig *OptConfig, multiCharSingleDash bool) (map[string]any, []string, error)
- type CommandFn
- type Config
- type LoginMessageFn
- type OptConfig
- type PasswordInterceptFn
- type Perm
- type Plugin
- func (p *Plugin) CallPasswordInterceptor(username, password string, ip *net.IP) bool
- func (p *Plugin) Commands() map[string]CommandFn
- func (p *Plugin) GetPath(withMain bool) string
- func (p *Plugin) HasCommandDefined() bool
- func (p *Plugin) HasLoginMessage() bool
- func (p *Plugin) HasPasswordIntercept() bool
- func (p *Plugin) HasPromptFn() bool
- func (p *Plugin) Init(vfs *VFS) error
- func (p *Plugin) SetVFS(vfs *VFS)
- type PluginManager
- type PromptFn
- type Session
- type TermWriteFn
- type User
- type VFS
- type VFSFile
Constants ¶
const T_ANY = 4
const T_DIR = 1
const T_FILE = 2
const T_SYMLINK = 3
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CmdArgs ¶
type CmdArgs struct { RawArgs string // contains filtered or unexported fields }
func (*CmdArgs) ArrayWithCommand ¶
type Config ¶
type Config struct { CommandCallbacks map[string]CommandFn PasswordInterceptor PasswordInterceptFn PromptFn PromptFn LoginMessageFn LoginMessageFn // contains filtered or unexported fields }
Config is a struct that handles everything related to the sandbox. For example, the registered commands, the password interceptor, the fake prompt, and other things.
func (*Config) Init ¶
func (c *Config) Init()
Init initializes the instance. This must run, as it instanciates the command callbacks.
func (*Config) RegisterCommand ¶
RegisterCommand adds a command to the list of supported commands. This means that an attacker can run the command by the supplied `cmd` and then that will run the command function (`cmdFn`).
func (*Config) RegisterLoginMessage ¶
func (c *Config) RegisterLoginMessage(loginMsgFn LoginMessageFn)
func (*Config) RegisterPasswordIntercept ¶
func (c *Config) RegisterPasswordIntercept(interceptor PasswordInterceptFn)
func (*Config) RegisterPrompt ¶
type LoginMessageFn ¶
type OptConfig ¶
OptConfig manages options.
func CreateOptsConfig ¶
func CreateOptsConfig() *OptConfig
type Plugin ¶
type Plugin struct { Path string Dir fs.DirEntry Main fs.DirEntry L *lua.LState Config *Config DB *gorm.DB // contains filtered or unexported fields }
func (*Plugin) CallPasswordInterceptor ¶
func (*Plugin) HasCommandDefined ¶
func (*Plugin) HasLoginMessage ¶
func (*Plugin) HasPasswordIntercept ¶
func (*Plugin) HasPromptFn ¶
type PluginManager ¶
type PluginManager struct { DB *gorm.DB PluginVFS *VFS PromptPlugin PromptFn LoginMessageFn LoginMessageFn // contains filtered or unexported fields }
PluginManager handles all things related to the plugins. Use this instance to load plugins and get commands.
func (*PluginManager) GetCommand ¶
func (pm *PluginManager) GetCommand(cmd string) (CommandFn, bool)
GetComand returns a function handler and a boolean (if it was found or not) for a command (as a string).
func (*PluginManager) GetPasswordIntercepts ¶
func (pm *PluginManager) GetPasswordIntercepts() []*Plugin
func (*PluginManager) LoadPlugins ¶
func (pm *PluginManager) LoadPlugins(path string) error
LoadPlugins loads the plugin by supplying a `path`.
func (*PluginManager) MatchCommand ¶
func (pm *PluginManager) MatchCommand(part string) ([]CommandFn, []string)
type Session ¶
type Session struct { VFS *VFS Term *term.Terminal Manager *PluginManager User *User // contains filtered or unexported fields }
func (*Session) AutoCompleteCallback ¶
type TermWriteFn ¶
type TermWriteFn func(...string)
type VFS ¶
type VFS struct { Root VFSFile `json:"root"` Home string `json:"home"` PWD string `json:"-"` User *User `json:"-"` }
VFS is the recursive struct that describes the virtual file system.
func ReadVFSJSONFile ¶
ReadVFSJSONFile reads the JSON file which contains the the virtual file system model.
type VFSFile ¶
type VFSFile struct { Type int `json:"t"` Name string `json:"n"` Files map[string]VFSFile `json:"f"` Contents string `json:"c"` Mode os.FileMode `json:"m"` Owner string `json:"o"` Group string `json:"g"` ModTime time.Time `json:"mt"` LinkTo string `json:"lt"` NLink int `json:"nl"` CmdFn CommandFn `json:"-"` }
VFSFile represents the virtual file in the VFS. It can be a regular file (text, executable, etc) or a directory containing its own set of files.