mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 04:59:25 -07:00
new: wifi.client.probe.ap.filter and wifi.client.probe.sta.filter actions to filter wifi client probes
This commit is contained in:
parent
5ff8e3e4fa
commit
caba6e1952
2 changed files with 44 additions and 4 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -51,6 +52,8 @@ type WiFiModule struct {
|
||||||
assocSkip []net.HardwareAddr
|
assocSkip []net.HardwareAddr
|
||||||
assocSilent bool
|
assocSilent bool
|
||||||
assocOpen bool
|
assocOpen bool
|
||||||
|
filterProbeSTA *regexp.Regexp
|
||||||
|
filterProbeAP *regexp.Regexp
|
||||||
apRunning bool
|
apRunning bool
|
||||||
showManuf bool
|
showManuf bool
|
||||||
apConfig packets.Dot11ApConfig
|
apConfig packets.Dot11ApConfig
|
||||||
|
@ -138,6 +141,33 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
return err
|
return err
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
mod.AddHandler(session.NewModuleHandler("wifi.client.probe.sta.filter FILTER", "wifi.client.probe.sta.filter (.+)",
|
||||||
|
"Use this regular expression on the station address to filter client probes, 'clear' to reset the filter.",
|
||||||
|
func(args []string) (err error) {
|
||||||
|
filter := args[0]
|
||||||
|
if filter == "clear" {
|
||||||
|
mod.filterProbeSTA = nil
|
||||||
|
return
|
||||||
|
} else if mod.filterProbeSTA, err = regexp.Compile(filter); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}))
|
||||||
|
|
||||||
|
mod.AddHandler(session.NewModuleHandler("wifi.client.probe.ap.filter FILTER", "wifi.client.probe.ap.filter (.+)",
|
||||||
|
"Use this regular expression on the access point name to filter client probes, 'clear' to reset the filter.",
|
||||||
|
func(args []string) (err error) {
|
||||||
|
filter := args[0]
|
||||||
|
if filter == "clear" {
|
||||||
|
mod.filterProbeAP = nil
|
||||||
|
return
|
||||||
|
} else if mod.filterProbeAP, err = regexp.Compile(filter); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}))
|
||||||
|
|
||||||
minRSSI := session.NewIntParameter("wifi.rssi.min",
|
minRSSI := session.NewIntParameter("wifi.rssi.min",
|
||||||
"-200",
|
"-200",
|
||||||
"Minimum WiFi signal strength in dBm.")
|
"Minimum WiFi signal strength in dBm.")
|
||||||
|
|
|
@ -100,6 +100,11 @@ func (mod *WiFiModule) discoverProbes(radiotap *layers.RadioTap, dot11 *layers.D
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clientSTA := network.NormalizeMac(dot11.Address2.String())
|
||||||
|
if mod.filterProbeSTA != nil && !mod.filterProbeSTA.MatchString(clientSTA) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
tot := len(req.Contents)
|
tot := len(req.Contents)
|
||||||
if tot < 3 {
|
if tot < 3 {
|
||||||
return
|
return
|
||||||
|
@ -114,11 +119,16 @@ func (mod *WiFiModule) discoverProbes(radiotap *layers.RadioTap, dot11 *layers.D
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apSSID := string(req.Contents[2 : 2+size])
|
||||||
|
if mod.filterProbeAP != nil && !mod.filterProbeAP.MatchString(apSSID) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
mod.Session.Events.Add("wifi.client.probe", ProbeEvent{
|
mod.Session.Events.Add("wifi.client.probe", ProbeEvent{
|
||||||
FromAddr: dot11.Address2.String(),
|
FromAddr: clientSTA,
|
||||||
FromVendor: network.ManufLookup(dot11.Address2.String()),
|
FromVendor: network.ManufLookup(clientSTA),
|
||||||
FromAlias: mod.Session.Lan.GetAlias(dot11.Address2.String()),
|
FromAlias: mod.Session.Lan.GetAlias(clientSTA),
|
||||||
SSID: string(req.Contents[2 : 2+size]),
|
SSID: apSSID,
|
||||||
RSSI: radiotap.DBMAntennaSignal,
|
RSSI: radiotap.DBMAntennaSignal,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue