mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
fix: made wifi.deauth asynchronous
This commit is contained in:
parent
470d456ba8
commit
41084bec39
1 changed files with 22 additions and 20 deletions
|
@ -51,9 +51,6 @@ func (w *WiFiModule) startDeauth(to net.HardwareAddr) error {
|
||||||
defer w.handle.Close()
|
defer w.handle.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
w.writes.Add(1)
|
|
||||||
defer w.writes.Done()
|
|
||||||
|
|
||||||
type flow struct {
|
type flow struct {
|
||||||
Ap *network.AccessPoint
|
Ap *network.AccessPoint
|
||||||
Client *network.Station
|
Client *network.Station
|
||||||
|
@ -71,27 +68,32 @@ func (w *WiFiModule) startDeauth(to net.HardwareAddr) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(toDeauth) == 0 {
|
if len(toDeauth) == 0 {
|
||||||
return fmt.Errorf("%s is an unknown BSSID or doesn't have detected clients.", to.String())
|
return fmt.Errorf("%s is an unknown BSSID, is in the deauth skip list, or doesn't have detected clients.", to.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// since we need to change the wifi adapter channel for each
|
go func() {
|
||||||
// deauth packet, let's sort by channel so we do the minimum
|
w.writes.Add(1)
|
||||||
// amount of hops possible
|
defer w.writes.Done()
|
||||||
sort.Slice(toDeauth, func(i, j int) bool {
|
|
||||||
return toDeauth[i].Ap.Channel() < toDeauth[j].Ap.Channel()
|
|
||||||
})
|
|
||||||
|
|
||||||
// send the deauth frames
|
// since we need to change the wifi adapter channel for each
|
||||||
for _, deauth := range toDeauth {
|
// deauth packet, let's sort by channel so we do the minimum
|
||||||
client := deauth.Client
|
// amount of hops possible
|
||||||
ap := deauth.Ap
|
sort.Slice(toDeauth, func(i, j int) bool {
|
||||||
if w.Running() {
|
return toDeauth[i].Ap.Channel() < toDeauth[j].Ap.Channel()
|
||||||
log.Info("deauthing client %s from AP %s (channel %d)", client.String(), ap.ESSID(), ap.Channel())
|
})
|
||||||
w.onChannel(ap.Channel(), func() {
|
|
||||||
w.sendDeauthPacket(ap.HW, client.HW)
|
// send the deauth frames
|
||||||
})
|
for _, deauth := range toDeauth {
|
||||||
|
client := deauth.Client
|
||||||
|
ap := deauth.Ap
|
||||||
|
if w.Running() {
|
||||||
|
log.Info("deauthing client %s from AP %s (channel %d)", client.String(), ap.ESSID(), ap.Channel())
|
||||||
|
w.onChannel(ap.Channel(), func() {
|
||||||
|
w.sendDeauthPacket(ap.HW, client.HW)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue