mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
new: modules enabled by default can now be controlled with the -autostart argument
This commit is contained in:
parent
72ac7e63fc
commit
5727fa3c56
3 changed files with 17 additions and 5 deletions
11
core/core.go
11
core/core.go
|
@ -41,6 +41,17 @@ func UniqueInts(a []int, sorted bool) []int {
|
|||
return uniq
|
||||
}
|
||||
|
||||
func CommaSplit(csv string) []string {
|
||||
filtered := make([]string, 0)
|
||||
for _, part := range strings.Split(csv, ",") {
|
||||
part = Trim(part)
|
||||
if part != "" {
|
||||
filtered = append(filtered, part)
|
||||
}
|
||||
}
|
||||
return filtered
|
||||
}
|
||||
|
||||
func ExecSilent(executable string, args []string) (string, error) {
|
||||
path, err := exec.LookPath(executable)
|
||||
if err != nil {
|
||||
|
|
|
@ -5,6 +5,7 @@ import "flag"
|
|||
type Options struct {
|
||||
InterfaceName *string
|
||||
Caplet *string
|
||||
AutoStart *string
|
||||
Debug *bool
|
||||
Silent *bool
|
||||
NoColors *bool
|
||||
|
@ -18,6 +19,7 @@ type Options struct {
|
|||
func ParseOptions() (Options, error) {
|
||||
o := Options{
|
||||
InterfaceName: flag.String("iface", "", "Network interface to bind to, if empty the default interface will be auto selected."),
|
||||
AutoStart: flag.String("autostart", "events.stream, net.recon", "Comma separated list of modules to auto start."),
|
||||
Caplet: flag.String("caplet", "", "Read commands from this file and execute them in the interactive session."),
|
||||
Debug: flag.Bool("debug", false, "Print debug messages."),
|
||||
Silent: flag.Bool("silent", false, "Suppress all logs which are not errors."),
|
||||
|
|
9
main.go
9
main.go
|
@ -14,8 +14,6 @@ import (
|
|||
var sess *session.Session
|
||||
var err error
|
||||
|
||||
// Some modules are enabled by default in order
|
||||
// to make the interactive session useful.
|
||||
var autoEnableList = []string{
|
||||
"events.stream",
|
||||
"net.recon",
|
||||
|
@ -75,10 +73,11 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
// Start modules that are enabled by default.
|
||||
for _, modName := range autoEnableList {
|
||||
// Some modules are enabled by default in order
|
||||
// to make the interactive session useful.
|
||||
for _, modName := range core.CommaSplit(*sess.Options.AutoStart) {
|
||||
if err = sess.Run(modName + " on"); err != nil {
|
||||
log.Fatal("Error while starting module %s: %", modName, err)
|
||||
log.Fatal("Error while starting module %s: %s", modName, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue