mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
5314e9ff50
commit
d775dd3b3c
1 changed files with 22 additions and 21 deletions
|
@ -285,6 +285,10 @@ func (w *WiFiRecon) sendDeauthPacket(ap net.HardwareAddr, client net.HardwareAdd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WiFiRecon) startDeauth() error {
|
func (w *WiFiRecon) startDeauth() error {
|
||||||
|
// at least we need to know what ap we're talking about
|
||||||
|
if w.isApSelected() == false {
|
||||||
|
return errors.New("No access point selected, use 'wifi.recon set bs BSSID' to select one.")
|
||||||
|
}
|
||||||
// if not already running, temporarily enable the pcap handle
|
// if not already running, temporarily enable the pcap handle
|
||||||
// for packet injection
|
// for packet injection
|
||||||
if w.Running() == false {
|
if w.Running() == false {
|
||||||
|
@ -294,18 +298,17 @@ func (w *WiFiRecon) startDeauth() error {
|
||||||
defer w.handle.Close()
|
defer w.handle.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.isApSelected() {
|
|
||||||
if w.isClientSelected() {
|
|
||||||
// deauth a specific client
|
// deauth a specific client
|
||||||
|
if w.isClientSelected() {
|
||||||
w.sendDeauthPacket(w.accessPoint, w.client)
|
w.sendDeauthPacket(w.accessPoint, w.client)
|
||||||
log.Info("Deauth packets sent for client station %s.", w.client.String())
|
log.Info("Deauth packets sent for client station %s.", w.client.String())
|
||||||
} else {
|
} else {
|
||||||
n := len(w.wifi.Stations)
|
// deauth every authenticated client
|
||||||
// deauth all AP's clients
|
|
||||||
for _, station := range w.wifi.Stations {
|
for _, station := range w.wifi.Stations {
|
||||||
w.sendDeauthPacket(w.accessPoint, station.HW)
|
w.sendDeauthPacket(w.accessPoint, station.HW)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n := len(w.wifi.Stations)
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
log.Warning("No associated clients detected yet, deauth packets not sent.")
|
log.Warning("No associated clients detected yet, deauth packets not sent.")
|
||||||
} else if n == 1 {
|
} else if n == 1 {
|
||||||
|
@ -314,10 +317,8 @@ func (w *WiFiRecon) startDeauth() error {
|
||||||
log.Info("Deauth packets sent for %d client stations.", n)
|
log.Info("Deauth packets sent for %d client stations.", n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return errors.New("No base station or client set.")
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WiFiRecon) discoverAccessPoints(radiotap *layers.RadioTap, dot11 *layers.Dot11, packet gopacket.Packet) {
|
func (w *WiFiRecon) discoverAccessPoints(radiotap *layers.RadioTap, dot11 *layers.Dot11, packet gopacket.Packet) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue