From b48c75a7fccf52c8460b947830aa705796679ad3 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Fri, 16 Feb 2018 13:48:55 +0100 Subject: [PATCH] misc: small fix or general refactoring i did not bother commenting --- modules/wlan_recon.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/wlan_recon.go b/modules/wlan_recon.go index bdd04662..ee935a7c 100644 --- a/modules/wlan_recon.go +++ b/modules/wlan_recon.go @@ -256,20 +256,22 @@ func (w *WDiscovery) sendDeauthPacket(ap net.HardwareAddr, client net.HardwareAd } func (w *WDiscovery) startDeauth() error { - switch { - case len(w.apTarget) > 0 && len(w.cliTarget) > 0: - w.sendDeauthPacket(w.apTarget, w.cliTarget) + isTargetingAP := len(w.apTarget) > 0 + isTargetingCLI := len(w.cliTarget) > 0 - case len(w.apTarget) > 0: - for _, t := range w.Stations.Stations { - w.sendDeauthPacket(w.apTarget, t.Endpoint.HW) + if isTargetingAP { + if isTargetingCLI { + // deauth a specific client + w.sendDeauthPacket(w.apTarget, w.cliTarget) + } else { + // deauth all AP's clients + for _, t := range w.Stations.Stations { + w.sendDeauthPacket(w.apTarget, t.Endpoint.HW) + } } - - default: - return errors.New("Base station is not set.") + return nil } - - return nil + return errors.New("No base station or client set.") } func (w *WDiscovery) discoverAccessPoints(packet gopacket.Packet) {