Documentation ¶
Index ¶
- Constants
- Variables
- func ParseCommands(buffer string) []string
- type CommandHandler
- type Environment
- type Event
- type EventPool
- type LogMessage
- type Module
- type ModuleHandler
- type ModuleParam
- func NewBoolParameter(name string, def_value string, desc string) *ModuleParam
- func NewIntParameter(name string, def_value string, desc string) *ModuleParam
- func NewModuleParameter(name string, def_value string, t ParamType, validator string, desc string) *ModuleParam
- func NewStringParameter(name string, def_value string, validator string, desc string) *ModuleParam
- type ParamType
- type Prompt
- type Session
- func (s *Session) Close()
- func (s *Session) Module(name string) (err error, mod Module)
- func (s *Session) ReadLine() (string, error)
- func (s *Session) Refresh()
- func (s *Session) Register(mod Module) error
- func (s *Session) Run(line string) error
- func (s *Session) RunCaplet(filename string) error
- func (s *Session) Start() error
- type SessionModule
- func (m *SessionModule) AddHandler(h ModuleHandler)
- func (m *SessionModule) AddParam(p *ModuleParam) *ModuleParam
- func (m SessionModule) BoolParam(name string) (error, bool)
- func (m *SessionModule) Handlers() []ModuleHandler
- func (m SessionModule) IntParam(name string) (error, int)
- func (m SessionModule) ListParam(name string) (err error, values []string)
- func (m *SessionModule) Param(name string) *ModuleParam
- func (m *SessionModule) Parameters() map[string]*ModuleParam
- func (m *SessionModule) Running() bool
- func (m *SessionModule) SetRunning(running bool)
- func (m SessionModule) StringParam(name string) (error, string)
- type Targets
Constants ¶
View Source
const ( STRING ParamType = iota BOOL = iota INT = iota )
View Source
const ( PromptVariable = "$" DefaultPrompt = "{by}{fw}{cidr} {fb}> {env.iface.ipv4} {reset} {bold}» {reset}" )
View Source
const HistoryFile = "~/bettercap.history"
View Source
const IPv4Validator = `^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`
View Source
const ParamIfaceAddress = "<interface address>"
View Source
const ParamRandomMAC = "<random mac>"
View Source
const ParamSubnet = "<entire subnet>"
View Source
const TargetsAliasesFile = "~/bettercap.aliases"
View Source
const TargetsDefaultTTL = 2
Variables ¶
View Source
var ( I = (*Session)(nil) ErrAlreadyStarted = errors.New("Module is already running.") ErrAlreadyStopped = errors.New("Module is not running.") )
View Source
var PromptCallbacks = map[string]func(s *Session) string{ "{cidr}": func(s *Session) string { return s.Interface.CIDR() }, "{net.sent}": func(s *Session) string { return fmt.Sprintf("%d", s.Queue.Sent) }, "{net.sent.human}": func(s *Session) string { return humanize.Bytes(s.Queue.Sent) }, "{net.received}": func(s *Session) string { return fmt.Sprintf("%d", s.Queue.Received) }, "{net.received.human}": func(s *Session) string { return humanize.Bytes(s.Queue.Received) }, "{net.packets}": func(s *Session) string { return fmt.Sprintf("%d", s.Queue.PktReceived) }, "{net.errors}": func(s *Session) string { return fmt.Sprintf("%d", s.Queue.Errors) }, }
View Source
var PromptEffects = map[string]string{ "{bold}": core.BOLD, "{dim}": core.DIM, "{r}": core.RED, "{g}": core.GREEN, "{b}": core.BLUE, "{y}": core.YELLOW, "{fb}": core.FG_BLACK, "{fw}": core.FG_WHITE, "{bdg}": core.BG_DGRAY, "{br}": core.BG_RED, "{bg}": core.BG_GREEN, "{by}": core.BG_YELLOW, "{blb}": core.BG_LBLUE, "{reset}": core.RESET, }
Functions ¶
func ParseCommands ¶
Types ¶
type CommandHandler ¶
type CommandHandler struct { Name string Description string Completer *readline.PrefixCompleter Parser *regexp.Regexp Exec func(args []string, s *Session) error }
func NewCommandHandler ¶
type Environment ¶
type Environment struct { sync.Mutex Padding int `json:"-"` Storage map[string]string `json:"storage"` // contains filtered or unexported fields }
func NewEnvironment ¶
func NewEnvironment(s *Session) *Environment
func (*Environment) Has ¶
func (env *Environment) Has(name string) bool
func (*Environment) Set ¶
func (env *Environment) Set(name, value string) string
func (*Environment) Sorted ¶
func (env *Environment) Sorted() []string
type Event ¶
type EventPool ¶
func NewEventPool ¶
type LogMessage ¶
type Module ¶
type Module interface { Name() string Description() string Author() string Handlers() []ModuleHandler Parameters() map[string]*ModuleParam Running() bool Start() error Stop() error }
type ModuleHandler ¶
type ModuleHandler struct { Name string Description string Parser *regexp.Regexp Exec func(args []string) error }
func NewModuleHandler ¶
func (*ModuleHandler) Help ¶
func (h *ModuleHandler) Help(padding int) string
type ModuleParam ¶
type ModuleParam struct { Name string Type ParamType Value string Description string Validator *regexp.Regexp }
func NewBoolParameter ¶
func NewBoolParameter(name string, def_value string, desc string) *ModuleParam
func NewIntParameter ¶
func NewIntParameter(name string, def_value string, desc string) *ModuleParam
func NewModuleParameter ¶
func NewStringParameter ¶
func NewStringParameter(name string, def_value string, validator string, desc string) *ModuleParam
func (ModuleParam) Dump ¶
func (p ModuleParam) Dump(padding int) string
func (ModuleParam) Get ¶
func (p ModuleParam) Get(s *Session) (error, interface{})
func (ModuleParam) Help ¶
func (p ModuleParam) Help(padding int) string
func (ModuleParam) Register ¶
func (p ModuleParam) Register(s *Session)
func (ModuleParam) Validate ¶
func (p ModuleParam) Validate(value string) (error, interface{})
type Session ¶
type Session struct { Options core.Options `json:"options"` Interface *net.Endpoint `json:"interface"` Gateway *net.Endpoint `json:"gateway"` Firewall firewall.FirewallManager `json:"-"` Env *Environment `json:"env"` Targets *Targets `json:"targets"` Queue *packets.Queue `json:"packets"` Input *readline.Instance `json:"-"` StartedAt time.Time `json:"started_at"` Active bool `json:"active"` Prompt Prompt `json:"-"` CoreHandlers []CommandHandler `json:"-"` Modules []Module `json:"-"` HelpPadding int `json:"-"` Events *EventPool `json:"-"` }
type SessionModule ¶
type SessionModule struct { Name string `json:"name"` Session *Session `json:"-"` Started bool `json:"started"` StatusLock *sync.Mutex `json:"-"` // contains filtered or unexported fields }
func NewSessionModule ¶
func NewSessionModule(name string, s *Session) SessionModule
func (*SessionModule) AddHandler ¶
func (m *SessionModule) AddHandler(h ModuleHandler)
func (*SessionModule) AddParam ¶
func (m *SessionModule) AddParam(p *ModuleParam) *ModuleParam
func (*SessionModule) Handlers ¶
func (m *SessionModule) Handlers() []ModuleHandler
func (SessionModule) ListParam ¶
func (m SessionModule) ListParam(name string) (err error, values []string)
func (*SessionModule) Param ¶
func (m *SessionModule) Param(name string) *ModuleParam
func (*SessionModule) Parameters ¶
func (m *SessionModule) Parameters() map[string]*ModuleParam
func (*SessionModule) Running ¶
func (m *SessionModule) Running() bool
func (*SessionModule) SetRunning ¶
func (m *SessionModule) SetRunning(running bool)
func (SessionModule) StringParam ¶
func (m SessionModule) StringParam(name string) (error, string)
Click to show internal directories.
Click to hide internal directories.