mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 04:59:25 -07:00
fix: don't print wifi.client.probe we generate
This commit is contained in:
parent
906969f1b3
commit
662f5fb973
2 changed files with 33 additions and 28 deletions
|
@ -59,6 +59,7 @@ type WiFiModule struct {
|
||||||
apRunning bool
|
apRunning bool
|
||||||
showManuf bool
|
showManuf bool
|
||||||
apConfig packets.Dot11ApConfig
|
apConfig packets.Dot11ApConfig
|
||||||
|
probeMac net.HardwareAddr
|
||||||
writes *sync.WaitGroup
|
writes *sync.WaitGroup
|
||||||
reads *sync.WaitGroup
|
reads *sync.WaitGroup
|
||||||
chanLock *sync.Mutex
|
chanLock *sync.Mutex
|
||||||
|
@ -203,12 +204,11 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
probe := session.NewModuleHandler("wifi.probe BSSID ESSID",
|
probe := session.NewModuleHandler("wifi.probe BSSID ESSID",
|
||||||
`wifi\.probe\s+([a-fA-F0-9:]{11,})\s+([^\s].+)`,
|
`wifi\.probe\s+([a-fA-F0-9:]{11,})\s+([^\s].+)`,
|
||||||
"Sends a fake client probe with the given station BSSID, searching for ESSID.",
|
"Sends a fake client probe with the given station BSSID, searching for ESSID.",
|
||||||
func(args []string) error {
|
func(args []string) (err error) {
|
||||||
bssid, err := net.ParseMAC(args[0])
|
if mod.probeMac, err = net.ParseMAC(args[0]); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return mod.startProbing(bssid, args[1])
|
return mod.startProbing(mod.probeMac, args[1])
|
||||||
})
|
})
|
||||||
|
|
||||||
probe.Complete("wifi.probe", s.WiFiCompleterFull)
|
probe.Complete("wifi.probe", s.WiFiCompleterFull)
|
||||||
|
|
|
@ -50,30 +50,6 @@ func (mod *WiFiModule) stationPruner() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *WiFiModule) startProbing(staMac net.HardwareAddr, ssid string) error {
|
|
||||||
// if not already running, temporarily enable the pcap handle
|
|
||||||
// for packet injection
|
|
||||||
if !mod.Running() {
|
|
||||||
if err := mod.Configure(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer mod.handle.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
for seq := uint16(0); seq < 5 && mod.Running(); seq++ {
|
|
||||||
if err, pkt := packets.NewDot11ProbeRequest(staMac, seq, ssid, network.GetInterfaceChannel(mod.iface.Name())); err != nil {
|
|
||||||
mod.Error("could not create probe packet: %s", err)
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
mod.injectPacket(pkt)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mod.Info("sent probe frames")
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *WiFiModule) discoverAccessPoints(radiotap *layers.RadioTap, dot11 *layers.Dot11, packet gopacket.Packet) {
|
func (mod *WiFiModule) discoverAccessPoints(radiotap *layers.RadioTap, dot11 *layers.Dot11, packet gopacket.Packet) {
|
||||||
// search for Dot11InformationElementIDSSID
|
// search for Dot11InformationElementIDSSID
|
||||||
if ok, ssid := packets.Dot11ParseIDSSID(packet); ok {
|
if ok, ssid := packets.Dot11ParseIDSSID(packet); ok {
|
||||||
|
@ -110,6 +86,30 @@ func (mod *WiFiModule) discoverAccessPoints(radiotap *layers.RadioTap, dot11 *la
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mod *WiFiModule) startProbing(staMac net.HardwareAddr, ssid string) error {
|
||||||
|
// if not already running, temporarily enable the pcap handle
|
||||||
|
// for packet injection
|
||||||
|
if !mod.Running() {
|
||||||
|
if err := mod.Configure(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer mod.handle.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
for seq := uint16(0); seq < 5 && mod.Running(); seq++ {
|
||||||
|
if err, pkt := packets.NewDot11ProbeRequest(staMac, seq, ssid, network.GetInterfaceChannel(mod.iface.Name())); err != nil {
|
||||||
|
mod.Error("could not create probe packet: %s", err)
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
mod.injectPacket(pkt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod.Info("sent probe frames")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (mod *WiFiModule) discoverProbes(radiotap *layers.RadioTap, dot11 *layers.Dot11, packet gopacket.Packet) {
|
func (mod *WiFiModule) discoverProbes(radiotap *layers.RadioTap, dot11 *layers.Dot11, packet gopacket.Packet) {
|
||||||
if dot11.Type != layers.Dot11TypeMgmtProbeReq {
|
if dot11.Type != layers.Dot11TypeMgmtProbeReq {
|
||||||
return
|
return
|
||||||
|
@ -125,6 +125,11 @@ func (mod *WiFiModule) discoverProbes(radiotap *layers.RadioTap, dot11 *layers.D
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skip stuff we're sending
|
||||||
|
if bytes.Equal(mod.probeMac, dot11.Address2) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
clientSTA := network.NormalizeMac(dot11.Address2.String())
|
clientSTA := network.NormalizeMac(dot11.Address2.String())
|
||||||
if mod.filterProbeSTA != nil && !mod.filterProbeSTA.MatchString(clientSTA) {
|
if mod.filterProbeSTA != nil && !mod.filterProbeSTA.MatchString(clientSTA) {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue