mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
fix: modules that require net.recon can now specify it as a dependency
This commit is contained in:
parent
5ef330f80b
commit
36e5fe8bdb
5 changed files with 30 additions and 0 deletions
|
@ -38,6 +38,8 @@ func NewArpSpoofer(s *session.Session) *ArpSpoofer {
|
||||||
waitGroup: &sync.WaitGroup{},
|
waitGroup: &sync.WaitGroup{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod.SessionModule.Requires("net.recon")
|
||||||
|
|
||||||
mod.AddParam(session.NewStringParameter("arp.spoof.targets", session.ParamSubnet, "", "Comma separated list of IP addresses, MAC addresses or aliases to spoof, also supports nmap style IP ranges."))
|
mod.AddParam(session.NewStringParameter("arp.spoof.targets", session.ParamSubnet, "", "Comma separated list of IP addresses, MAC addresses or aliases to spoof, also supports nmap style IP ranges."))
|
||||||
|
|
||||||
mod.AddParam(session.NewStringParameter("arp.spoof.whitelist", "", "", "Comma separated list of IP addresses, MAC addresses or aliases to skip while spoofing."))
|
mod.AddParam(session.NewStringParameter("arp.spoof.whitelist", "", "", "Comma separated list of IP addresses, MAC addresses or aliases to skip while spoofing."))
|
||||||
|
|
|
@ -42,6 +42,8 @@ func NewDHCP6Spoofer(s *session.Session) *DHCP6Spoofer {
|
||||||
waitGroup: &sync.WaitGroup{},
|
waitGroup: &sync.WaitGroup{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod.SessionModule.Requires("net.recon")
|
||||||
|
|
||||||
mod.AddParam(session.NewStringParameter("dhcp6.spoof.domains",
|
mod.AddParam(session.NewStringParameter("dhcp6.spoof.domains",
|
||||||
"microsoft.com, google.com, facebook.com, apple.com, twitter.com",
|
"microsoft.com, google.com, facebook.com, apple.com, twitter.com",
|
||||||
``,
|
``,
|
||||||
|
|
|
@ -34,6 +34,8 @@ func NewDNSSpoofer(s *session.Session) *DNSSpoofer {
|
||||||
waitGroup: &sync.WaitGroup{},
|
waitGroup: &sync.WaitGroup{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod.SessionModule.Requires("net.recon")
|
||||||
|
|
||||||
mod.AddParam(session.NewStringParameter("dns.spoof.hosts",
|
mod.AddParam(session.NewStringParameter("dns.spoof.hosts",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -30,6 +30,8 @@ func NewProber(s *session.Session) *Prober {
|
||||||
waitGroup: &sync.WaitGroup{},
|
waitGroup: &sync.WaitGroup{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod.SessionModule.Requires("net.recon")
|
||||||
|
|
||||||
mod.AddParam(session.NewBoolParameter("net.probe.nbns",
|
mod.AddParam(session.NewBoolParameter("net.probe.nbns",
|
||||||
"true",
|
"true",
|
||||||
"Enable NetBIOS name service discovery probes."))
|
"Enable NetBIOS name service discovery probes."))
|
||||||
|
|
|
@ -21,6 +21,7 @@ type Module interface {
|
||||||
Parameters() map[string]*ModuleParam
|
Parameters() map[string]*ModuleParam
|
||||||
|
|
||||||
Extra() map[string]interface{}
|
Extra() map[string]interface{}
|
||||||
|
Required() []string
|
||||||
Running() bool
|
Running() bool
|
||||||
Start() error
|
Start() error
|
||||||
Stop() error
|
Stop() error
|
||||||
|
@ -64,6 +65,7 @@ type SessionModule struct {
|
||||||
|
|
||||||
handlers []ModuleHandler
|
handlers []ModuleHandler
|
||||||
params map[string]*ModuleParam
|
params map[string]*ModuleParam
|
||||||
|
requires []string
|
||||||
tag string
|
tag string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +81,7 @@ func NewSessionModule(name string, s *Session) SessionModule {
|
||||||
StatusLock: &sync.RWMutex{},
|
StatusLock: &sync.RWMutex{},
|
||||||
State: &sync.Map{},
|
State: &sync.Map{},
|
||||||
|
|
||||||
|
requires: make([]string, 0),
|
||||||
handlers: make([]ModuleHandler, 0),
|
handlers: make([]ModuleHandler, 0),
|
||||||
params: make(map[string]*ModuleParam),
|
params: make(map[string]*ModuleParam),
|
||||||
tag: AsTag(name),
|
tag: AsTag(name),
|
||||||
|
@ -129,6 +132,14 @@ func (m *SessionModule) Fatal(format string, args ...interface{}) {
|
||||||
m.Session.Events.Log(log.FATAL, m.tag+format, args...)
|
m.Session.Events.Log(log.FATAL, m.tag+format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *SessionModule) Requires(modName string) {
|
||||||
|
m.requires = append(m.requires, modName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SessionModule) Required() []string {
|
||||||
|
return m.requires
|
||||||
|
}
|
||||||
|
|
||||||
func (m *SessionModule) Handlers() []ModuleHandler {
|
func (m *SessionModule) Handlers() []ModuleHandler {
|
||||||
return m.handlers
|
return m.handlers
|
||||||
}
|
}
|
||||||
|
@ -237,6 +248,17 @@ func (m *SessionModule) SetRunning(running bool, cb func()) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if running == true {
|
||||||
|
for _, modName := range m.Required() {
|
||||||
|
if m.Session.IsOn(modName) == false {
|
||||||
|
m.Info("starting %s as a requirement for %s", modName, m.Name)
|
||||||
|
if err := m.Session.Run(modName + " on"); err != nil {
|
||||||
|
return fmt.Errorf("error while starting module %s as a requirement for %s: %v", modName, m.Name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m.StatusLock.Lock()
|
m.StatusLock.Lock()
|
||||||
m.Started = running
|
m.Started = running
|
||||||
m.StatusLock.Unlock()
|
m.StatusLock.Unlock()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue