new: implemented wifi.hop.period parameter (closes #75).

This commit is contained in:
evilsocket 2018-02-24 19:46:22 +01:00
commit d9bcf8195b

View file

@ -29,6 +29,7 @@ type WiFiRecon struct {
handle *pcap.Handle handle *pcap.Handle
channel int channel int
hopPeriod time.Duration
frequencies []int frequencies []int
ap *network.AccessPoint ap *network.AccessPoint
stickChan int stickChan int
@ -39,6 +40,7 @@ func NewWiFiRecon(s *session.Session) *WiFiRecon {
SessionModule: session.NewSessionModule("wifi.recon", s), SessionModule: session.NewSessionModule("wifi.recon", s),
channel: 0, channel: 0,
stickChan: 0, stickChan: 0,
hopPeriod: 250 * time.Millisecond,
ap: nil, ap: nil,
} }
@ -96,6 +98,10 @@ func NewWiFiRecon(s *session.Session) *WiFiRecon {
"", "",
"WiFi channel or empty for channel hopping.")) "WiFi channel or empty for channel hopping."))
w.AddParam(session.NewIntParameter("wifi.hop.period",
"250",
"If channel hopping is enabled (empty wifi.recon.channel), this is the time in millseconds the algorithm will hop on every channel (it'll be doubled if both 2.4 and 5.0 bands are available."))
return w return w
} }
@ -263,6 +269,8 @@ func (w *WiFiRecon) Show(by string) error {
} }
func (w *WiFiRecon) Configure() error { func (w *WiFiRecon) Configure() error {
var hopPeriod int
ihandle, err := pcap.NewInactiveHandle(w.Session.Interface.Name()) ihandle, err := pcap.NewInactiveHandle(w.Session.Interface.Name())
if err != nil { if err != nil {
return err return err
@ -277,7 +285,15 @@ func (w *WiFiRecon) Configure() error {
return err return err
} else if w.handle, err = ihandle.Activate(); err != nil { } else if w.handle, err = ihandle.Activate(); err != nil {
return err return err
} else if err, w.channel = w.IntParam("wifi.recon.channel"); err == nil { }
if err, hopPeriod = w.IntParam("wifi.hop.period"); err != nil {
return err
}
w.hopPeriod = time.Duration(hopPeriod) * time.Millisecond
if err, w.channel = w.IntParam("wifi.recon.channel"); err == nil {
if err = network.SetInterfaceChannel(w.Session.Interface.Name(), w.channel); err != nil { if err = network.SetInterfaceChannel(w.Session.Interface.Name(), w.channel); err != nil {
return err return err
} }
@ -433,7 +449,7 @@ func (w *WiFiRecon) updateStats(dot11 *layers.Dot11, packet gopacket.Packet) {
func (w *WiFiRecon) channelHopper() { func (w *WiFiRecon) channelHopper() {
log.Info("Channel hopper started.") log.Info("Channel hopper started.")
for w.Running() == true { for w.Running() == true {
delay := 250 * time.Millisecond delay := w.hopPeriod
// if we have both 2.4 and 5ghz capabilities, we have // if we have both 2.4 and 5ghz capabilities, we have
// more channels, therefore we need to increase the time // more channels, therefore we need to increase the time
// we hop on each one otherwise me lose information // we hop on each one otherwise me lose information