diff --git a/modules/arp_spoof/arp_spoof.go b/modules/arp_spoof/arp_spoof.go index 507d38af..9d3a9cf5 100644 --- a/modules/arp_spoof/arp_spoof.go +++ b/modules/arp_spoof/arp_spoof.go @@ -38,6 +38,8 @@ func NewArpSpoofer(s *session.Session) *ArpSpoofer { 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.whitelist", "", "", "Comma separated list of IP addresses, MAC addresses or aliases to skip while spoofing.")) diff --git a/modules/dhcp6_spoof/dhcp6_spoof.go b/modules/dhcp6_spoof/dhcp6_spoof.go index 2b0f729b..56d88388 100644 --- a/modules/dhcp6_spoof/dhcp6_spoof.go +++ b/modules/dhcp6_spoof/dhcp6_spoof.go @@ -42,6 +42,8 @@ func NewDHCP6Spoofer(s *session.Session) *DHCP6Spoofer { waitGroup: &sync.WaitGroup{}, } + mod.SessionModule.Requires("net.recon") + mod.AddParam(session.NewStringParameter("dhcp6.spoof.domains", "microsoft.com, google.com, facebook.com, apple.com, twitter.com", ``, diff --git a/modules/dns_spoof/dns_spoof.go b/modules/dns_spoof/dns_spoof.go index 2f6bf5f4..0db15410 100644 --- a/modules/dns_spoof/dns_spoof.go +++ b/modules/dns_spoof/dns_spoof.go @@ -34,6 +34,8 @@ func NewDNSSpoofer(s *session.Session) *DNSSpoofer { waitGroup: &sync.WaitGroup{}, } + mod.SessionModule.Requires("net.recon") + mod.AddParam(session.NewStringParameter("dns.spoof.hosts", "", "", diff --git a/modules/net_probe/net_probe.go b/modules/net_probe/net_probe.go index c3df280c..7fa9fb39 100644 --- a/modules/net_probe/net_probe.go +++ b/modules/net_probe/net_probe.go @@ -30,6 +30,8 @@ func NewProber(s *session.Session) *Prober { waitGroup: &sync.WaitGroup{}, } + mod.SessionModule.Requires("net.recon") + mod.AddParam(session.NewBoolParameter("net.probe.nbns", "true", "Enable NetBIOS name service discovery probes.")) diff --git a/session/module.go b/session/module.go index f8ba5e75..0803023b 100644 --- a/session/module.go +++ b/session/module.go @@ -21,6 +21,7 @@ type Module interface { Parameters() map[string]*ModuleParam Extra() map[string]interface{} + Required() []string Running() bool Start() error Stop() error @@ -64,6 +65,7 @@ type SessionModule struct { handlers []ModuleHandler params map[string]*ModuleParam + requires []string tag string } @@ -79,6 +81,7 @@ func NewSessionModule(name string, s *Session) SessionModule { StatusLock: &sync.RWMutex{}, State: &sync.Map{}, + requires: make([]string, 0), handlers: make([]ModuleHandler, 0), params: make(map[string]*ModuleParam), 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...) } +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 { 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.Started = running m.StatusLock.Unlock()