mirror of
https://github.com/bettercap/bettercap
synced 2025-07-12 16:13:48 -07:00
new: improved menu and per module help
This commit is contained in:
parent
debdeba956
commit
31de46c14c
10 changed files with 60 additions and 129 deletions
110
README.md
110
README.md
|
@ -142,115 +142,7 @@ function onResponse(req, res) {
|
|||
|
||||
## Interactive Mode
|
||||
|
||||
Interactive mode allows you to start and stop modules manually on the fly, change options and apply new firewall rules on the fly, the basic commands are:
|
||||
|
||||
| Command | Description |
|
||||
| ------- | ------------|
|
||||
| help | Display list of available commands. |
|
||||
| active | Show information about active modules. |
|
||||
| exit | Close the session and exit. |
|
||||
| sleep SECONDS | Sleep for the given amount of seconds. |
|
||||
| get NAME | Get the value of variable NAME, use * for all. |
|
||||
| set NAME VALUE | Set the VALUE of variable NAME. |
|
||||
|
||||
For instance you can view a list of declared variables with `get *` and set new ones, for example `set some.new.variable some-value`, for a list of every module and its parameters, issue the `help` command:
|
||||
|
||||
192.168.1.0/24 > 192.168.1.17 » help
|
||||
|
||||
Basic commands:
|
||||
|
||||
help : Display list of available commands.
|
||||
active : Show information about active modules.
|
||||
exit : Close the session and exit.
|
||||
sleep SECONDS : Sleep for the given amount of seconds.
|
||||
get NAME : Get the value of variable NAME, use * for all.
|
||||
set NAME VALUE : Set the VALUE of variable NAME.
|
||||
|
||||
ARP Spoofer
|
||||
Keep spoofing selected hosts on the network.
|
||||
|
||||
arp.spoof on : Start ARP spoofer.
|
||||
arp.spoof off : Stop ARP spoofer.
|
||||
|
||||
Parameters
|
||||
|
||||
arp.spoof.targets : IP addresses to spoof. (default=<entire subnet>)
|
||||
|
||||
|
||||
Events Stream
|
||||
Print events as a continuous stream.
|
||||
|
||||
events.stream on : Start events stream.
|
||||
events.stream off : Stop events stream.
|
||||
events.clear : Clear events stream.
|
||||
|
||||
Parameters
|
||||
|
||||
events.stream.filter : If filled, filter events by this prefix type. (default=)
|
||||
|
||||
|
||||
HTTP Proxy
|
||||
A full featured HTTP proxy that can be used to inject malicious contents into webpages, all HTTP traffic will be redirected to it.
|
||||
|
||||
http.proxy on : Start HTTP proxy.
|
||||
http.proxy off : Stop HTTP proxy.
|
||||
|
||||
Parameters
|
||||
|
||||
http.port : HTTP port to redirect when the proxy is activated. (default=80)
|
||||
http.proxy.address : Address to bind the HTTP proxy to. (default=<interface address>)
|
||||
http.proxy.port : Port to bind the HTTP proxy to. (default=8080)
|
||||
http.proxy.script : Path of a proxy JS script. (default=)
|
||||
|
||||
|
||||
Network Prober
|
||||
Keep probing for new hosts on the network by sending dummy UDP packets to every possible IP on the subnet.
|
||||
|
||||
net.probe on : Start network hosts probing in background.
|
||||
net.probe off : Stop network hosts probing in background.
|
||||
|
||||
Parameters
|
||||
|
||||
net.probe.throttle : If greater than 0, probe packets will be throttled by this value in milliseconds. (default=10)
|
||||
|
||||
|
||||
Network Recon
|
||||
Read periodically the ARP cache in order to monitor for new hosts on the network.
|
||||
|
||||
net.recon on : Start network hosts discovery.
|
||||
net.recon off : Stop network hosts discovery.
|
||||
net.show : Show current hosts list.
|
||||
|
||||
Network Sniffer
|
||||
Sniff packets from the network.
|
||||
|
||||
net.sniffer stats : Print sniffer session configuration and statistics.
|
||||
net.sniffer on : Start network sniffer in background.
|
||||
net.sniffer off : Stop network sniffer in background.
|
||||
|
||||
Parameters
|
||||
|
||||
net.sniffer.regexp : If filled, only packets matching this regular expression will be considered. (default=)
|
||||
net.sniffer.output : If set, the sniffer will write captured packets to this file. (default=)
|
||||
net.sniffer.verbose : Print captured packets to screen. (default=true)
|
||||
net.sniffer.local : If true it will consider packets from/to this computer, otherwise it will skip them. (default=false)
|
||||
net.sniffer.filter : BPF filter for the sniffer. (default=not arp)
|
||||
|
||||
|
||||
REST API
|
||||
Expose a RESTful API.
|
||||
|
||||
api.rest on : Start REST API server.
|
||||
api.rest off : Stop REST API server.
|
||||
|
||||
Parameters
|
||||
|
||||
api.rest.address : Address to bind the API REST server to. (default=<interface address>)
|
||||
api.rest.port : Port to bind the API REST server to. (default=8083)
|
||||
api.rest.username : API authentication username. (default=)
|
||||
api.rest.certificate : API TLS certificate. (default=~/.bettercap-ng.api.rest.certificate.pem)
|
||||
api.rest.key : API TLS key (default=~/.bettercap-ng.api.rest.key.pem)
|
||||
api.rest.password : API authentication password. (default=)
|
||||
Interactive mode allows you to start and stop modules manually on the fly, change options and apply new firewall rules on the fly, to show the help menu type `help`, you can have module specific help by using `help module-name`.
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ type JSSessionResponse struct {
|
|||
}
|
||||
|
||||
func (api *RestAPI) Name() string {
|
||||
return "REST API"
|
||||
return "api.rest"
|
||||
}
|
||||
|
||||
func (api *RestAPI) Description() string {
|
||||
|
|
|
@ -53,7 +53,7 @@ func (p *ArpSpoofer) OnSessionEnded(s *session.Session) {
|
|||
}
|
||||
|
||||
func (p ArpSpoofer) Name() string {
|
||||
return "ARP Spoofer"
|
||||
return "arp.spoof"
|
||||
}
|
||||
|
||||
func (p ArpSpoofer) Description() string {
|
||||
|
|
|
@ -47,7 +47,7 @@ func NewEventsStream(s *session.Session) *EventsStream {
|
|||
}
|
||||
|
||||
func (s EventsStream) Name() string {
|
||||
return "Events Stream"
|
||||
return "events.stream"
|
||||
}
|
||||
|
||||
func (s EventsStream) Description() string {
|
||||
|
|
|
@ -115,7 +115,7 @@ func NewHttpProxy(s *session.Session) *HttpProxy {
|
|||
}
|
||||
|
||||
func (p *HttpProxy) Name() string {
|
||||
return "HTTP Proxy"
|
||||
return "http.proxy"
|
||||
}
|
||||
|
||||
func (p *HttpProxy) Description() string {
|
||||
|
|
|
@ -40,7 +40,7 @@ func NewProber(s *session.Session) *Prober {
|
|||
}
|
||||
|
||||
func (p Prober) Name() string {
|
||||
return "Network Prober"
|
||||
return "net.probe"
|
||||
}
|
||||
|
||||
func (p Prober) Description() string {
|
||||
|
|
|
@ -49,7 +49,7 @@ func NewDiscovery(s *session.Session) *Discovery {
|
|||
}
|
||||
|
||||
func (d Discovery) Name() string {
|
||||
return "Network Recon"
|
||||
return "net.recon"
|
||||
}
|
||||
|
||||
func (d Discovery) Description() string {
|
||||
|
|
|
@ -165,7 +165,7 @@ func NewSniffer(s *session.Session) *Sniffer {
|
|||
}
|
||||
|
||||
func (s Sniffer) Name() string {
|
||||
return "Network Sniffer"
|
||||
return "net.sniff"
|
||||
}
|
||||
|
||||
func (s Sniffer) Description() string {
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"os"
|
||||
"os/signal"
|
||||
"os/user"
|
||||
"sort"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
|
@ -76,6 +77,15 @@ func New() (*Session, error) {
|
|||
return s, nil
|
||||
}
|
||||
|
||||
func (s *Session) Module(name string) (err error, mod Module) {
|
||||
for _, m := range s.Modules {
|
||||
if m.Name() == name {
|
||||
return nil, m
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("Module %s not found", name), mod
|
||||
}
|
||||
|
||||
func (s *Session) setupInput() error {
|
||||
var err error
|
||||
|
||||
|
@ -138,6 +148,11 @@ func (s *Session) Register(mod Module) error {
|
|||
func (s *Session) Start() error {
|
||||
var err error
|
||||
|
||||
// make sure modules are always sorted by name
|
||||
sort.Slice(s.Modules, func(i, j int) bool {
|
||||
return s.Modules[i].Name() < s.Modules[j].Name()
|
||||
})
|
||||
|
||||
net.OuiInit()
|
||||
|
||||
if s.Interface, err = net.FindInterface(*s.Options.InterfaceName); err != nil {
|
||||
|
|
|
@ -2,7 +2,6 @@ package session
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -11,26 +10,46 @@ import (
|
|||
)
|
||||
|
||||
func (s *Session) helpHandler(args []string, sess *Session) error {
|
||||
fmt.Println()
|
||||
fmt.Printf("Basic commands:\n\n")
|
||||
for _, h := range s.CoreHandlers {
|
||||
fmt.Printf(" "+core.Bold("%"+strconv.Itoa(s.HelpPadding)+"s")+" : %s\n", h.Name, h.Description)
|
||||
filter := ""
|
||||
if len(args) == 2 {
|
||||
filter = args[1]
|
||||
}
|
||||
|
||||
sort.Slice(s.Modules, func(i, j int) bool {
|
||||
return s.Modules[i].Name() < s.Modules[j].Name()
|
||||
})
|
||||
if filter == "" {
|
||||
fmt.Println()
|
||||
fmt.Printf(core.Bold("MAIN COMMANDS\n\n"))
|
||||
for _, h := range s.CoreHandlers {
|
||||
fmt.Printf(" "+core.Yellow("%"+strconv.Itoa(s.HelpPadding)+"s")+" : %s\n", h.Name, h.Description)
|
||||
}
|
||||
|
||||
fmt.Printf(core.Bold("\nMODULES\n"))
|
||||
|
||||
for _, m := range s.Modules {
|
||||
status := ""
|
||||
if m.Running() {
|
||||
status = core.Green("running")
|
||||
} else {
|
||||
status = core.Red("not running")
|
||||
}
|
||||
fmt.Printf(" "+core.Yellow("%"+strconv.Itoa(s.HelpPadding)+"s")+" > %s\n", m.Name(), status)
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
|
||||
} else {
|
||||
err, m := s.Module(filter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
status := ""
|
||||
if m.Running() {
|
||||
status = core.Green("active")
|
||||
status = core.Green("running")
|
||||
} else {
|
||||
status = core.Red("not active")
|
||||
status = core.Red("not running")
|
||||
}
|
||||
fmt.Printf("%s [%s]\n", m.Name(), status)
|
||||
fmt.Println(core.Dim(m.Description()) + "\n")
|
||||
fmt.Printf("%s (%s): %s\n\n", core.Yellow(m.Name()), status, core.Dim(m.Description()))
|
||||
for _, h := range m.Handlers() {
|
||||
fmt.Printf(h.Help(s.HelpPadding))
|
||||
}
|
||||
|
@ -132,6 +151,11 @@ func (s *Session) registerCoreHandlers() {
|
|||
"Display list of available commands.",
|
||||
s.helpHandler))
|
||||
|
||||
s.CoreHandlers = append(s.CoreHandlers, NewCommandHandler("help MODULE",
|
||||
"^(help|\\?) (.+)$",
|
||||
"Show module specific help.",
|
||||
s.helpHandler))
|
||||
|
||||
s.CoreHandlers = append(s.CoreHandlers, NewCommandHandler("active",
|
||||
"^active$",
|
||||
"Show information about active modules.",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue