new: new net.probe.nbns and net.probe.mdns boolean parameters to selectively enable or disable specific probe agents

This commit is contained in:
evilsocket 2018-09-09 12:47:08 +03:00
commit 03161b1a95
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -12,9 +12,15 @@ import (
"github.com/malfunkt/iprange" "github.com/malfunkt/iprange"
) )
type Probes struct {
NBNS bool
MDNS bool
}
type Prober struct { type Prober struct {
session.SessionModule session.SessionModule
throttle int throttle int
probes Probes
waitGroup *sync.WaitGroup waitGroup *sync.WaitGroup
} }
@ -24,6 +30,14 @@ func NewProber(s *session.Session) *Prober {
waitGroup: &sync.WaitGroup{}, waitGroup: &sync.WaitGroup{},
} }
p.AddParam(session.NewBoolParameter("net.probe.nbns",
"true",
"Enable NetBIOS name service discovery probes."))
p.AddParam(session.NewBoolParameter("net.probe.mdns",
"true",
"Enable mDNS discovery probes."))
p.AddParam(session.NewIntParameter("net.probe.throttle", p.AddParam(session.NewIntParameter("net.probe.throttle",
"10", "10",
"If greater than 0, probe packets will be throttled by this value in milliseconds.")) "If greater than 0, probe packets will be throttled by this value in milliseconds."))
@ -71,6 +85,10 @@ func (p *Prober) Configure() error {
var err error var err error
if err, p.throttle = p.IntParam("net.probe.throttle"); err != nil { if err, p.throttle = p.IntParam("net.probe.throttle"); err != nil {
return err return err
} else if err, p.probes.NBNS = p.BoolParam("net.probe.nbns"); err != nil {
return err
} else if err, p.probes.MDNS = p.BoolParam("net.probe.mdns"); err != nil {
return err
} else { } else {
log.Debug("Throttling packets of %d ms.", p.throttle) log.Debug("Throttling packets of %d ms.", p.throttle)
} }
@ -102,7 +120,9 @@ func (p *Prober) Start() error {
throttle := time.Duration(p.throttle) * time.Millisecond throttle := time.Duration(p.throttle) * time.Millisecond
for p.Running() { for p.Running() {
p.sendProbeMDNS(from, from_hw) if p.probes.MDNS {
p.sendProbeMDNS(from, from_hw)
}
for _, ip := range addresses { for _, ip := range addresses {
if !p.Running() { if !p.Running() {
@ -112,7 +132,9 @@ func (p *Prober) Start() error {
continue continue
} }
p.sendProbe(from, from_hw, ip) if p.probes.NBNS {
p.sendProbe(from, from_hw, ip)
}
time.Sleep(throttle) time.Sleep(throttle)
} }