From d9b7d243143e0f97facdbb1caf1416d69cdb368a Mon Sep 17 00:00:00 2001 From: evilsocket Date: Tue, 20 Feb 2018 12:38:37 +0100 Subject: [PATCH] misc: small fix or general refactoring i did not bother commenting --- caplets/airodump.cap | 3 +++ modules/net_probe.go | 6 ++++++ network/wifi.go | 26 ++++++++++++++------------ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/caplets/airodump.cap b/caplets/airodump.cap index 7a9bd1c5..c613d52a 100644 --- a/caplets/airodump.cap +++ b/caplets/airodump.cap @@ -1,3 +1,6 @@ +# let's add some api :D +include caplets/rest-api.cap + set $ {by}{fw}{env.iface.name}{reset} {bold}ยป {reset} set ticker.commands clear; wifi.show diff --git a/modules/net_probe.go b/modules/net_probe.go index 7f698cd8..911554d3 100644 --- a/modules/net_probe.go +++ b/modules/net_probe.go @@ -6,6 +6,7 @@ import ( "time" "github.com/evilsocket/bettercap-ng/log" + "github.com/evilsocket/bettercap-ng/network" "github.com/evilsocket/bettercap-ng/session" "github.com/malfunkt/iprange" @@ -80,6 +81,11 @@ func (p *Prober) Start() error { } return p.SetRunning(true, func() { + if p.Session.Interface.IpAddress == network.MonitorModeAddress { + log.Info("Interface is in monitor mode, skipping net.probe") + return + } + list, err := iprange.Parse(p.Session.Interface.CIDR()) if err != nil { log.Fatal("%s", err) diff --git a/network/wifi.go b/network/wifi.go index d6b23725..4ac69220 100644 --- a/network/wifi.go +++ b/network/wifi.go @@ -10,16 +10,18 @@ type StationLostCallback func(s *Station) type WiFi struct { sync.Mutex - iface *Endpoint - stations map[string]*Station - newCb StationNewCallback - lostCb StationLostCallback + + Stations map[string]*Station + + iface *Endpoint + newCb StationNewCallback + lostCb StationLostCallback } func NewWiFi(iface *Endpoint, newcb StationNewCallback, lostcb StationLostCallback) *WiFi { return &WiFi{ + Stations: make(map[string]*Station), iface: iface, - stations: make(map[string]*Station), newCb: newcb, lostCb: lostcb, } @@ -30,7 +32,7 @@ func (w *WiFi) List() (list []*Station) { defer w.Unlock() list = make([]*Station, 0) - for _, t := range w.stations { + for _, t := range w.Stations { list = append(list, t) } return @@ -40,8 +42,8 @@ func (w *WiFi) Remove(mac string) { w.Lock() defer w.Unlock() - if s, found := w.stations[mac]; found { - delete(w.stations, mac) + if s, found := w.Stations[mac]; found { + delete(w.Stations, mac) if w.lostCb != nil { w.lostCb(s) } @@ -53,14 +55,14 @@ func (w *WiFi) AddIfNew(ssid, mac string, isAp bool, channel int, rssi int8) *St defer w.Unlock() mac = NormalizeMac(mac) - if station, found := w.stations[mac]; found { + if station, found := w.Stations[mac]; found { station.LastSeen = time.Now() station.RSSI = rssi return station } newStation := NewStation(ssid, mac, isAp, channel, rssi) - w.stations[mac] = newStation + w.Stations[mac] = newStation if w.newCb != nil { w.newCb(newStation) @@ -74,11 +76,11 @@ func (w *WiFi) Get(mac string) (*Station, bool) { defer w.Unlock() mac = NormalizeMac(mac) - station, found := w.stations[mac] + station, found := w.Stations[mac] return station, found } func (w *WiFi) Clear() error { - w.stations = make(map[string]*Station) + w.Stations = make(map[string]*Station) return nil }