mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
252645dd4e
commit
57983c6524
2 changed files with 95 additions and 91 deletions
|
@ -2,7 +2,6 @@ package wifi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"net"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
|
@ -148,19 +147,7 @@ func allZeros(s []byte) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WiFiModule) discoverHandshakes(radiotap *layers.RadioTap, dot11 *layers.Dot11, packet gopacket.Packet) {
|
func (w *WiFiModule) discoverHandshakes(radiotap *layers.RadioTap, dot11 *layers.Dot11, packet gopacket.Packet) {
|
||||||
// ref. https://wlan1nde.wordpress.com/2014/10/27/4-way-handshake/
|
if ok, key, apMac, staMac := packets.Dot11ParseEAPOL(packet, dot11); ok {
|
||||||
if keyLayer := packet.Layer(layers.LayerTypeEAPOLKey); keyLayer != nil {
|
|
||||||
if key := keyLayer.(*layers.EAPOLKey); key.KeyType == layers.EAPOLKeyTypePairwise {
|
|
||||||
staMac := net.HardwareAddr{}
|
|
||||||
apMac := net.HardwareAddr{}
|
|
||||||
if dot11.Flags.FromDS() {
|
|
||||||
staMac = dot11.Address1
|
|
||||||
apMac = dot11.Address2
|
|
||||||
} else if dot11.Flags.ToDS() {
|
|
||||||
staMac = dot11.Address2
|
|
||||||
apMac = dot11.Address1
|
|
||||||
}
|
|
||||||
|
|
||||||
// first, locate the AP in our list by its BSSID
|
// first, locate the AP in our list by its BSSID
|
||||||
ap, found := w.Session.WiFi.Get(apMac.String())
|
ap, found := w.Session.WiFi.Get(apMac.String())
|
||||||
if !found {
|
if !found {
|
||||||
|
@ -245,4 +232,3 @@ func (w *WiFiModule) discoverHandshakes(radiotap *layers.RadioTap, dot11 *layers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -273,3 +273,21 @@ func Dot11ParseDSSet(packet gopacket.Packet) (bool, int) {
|
||||||
|
|
||||||
return found, channel
|
return found, channel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Dot11ParseEAPOL(packet gopacket.Packet, dot11 *layers.Dot11) (ok bool, key *layers.EAPOLKey, apMac net.HardwareAddr, staMac net.HardwareAddr) {
|
||||||
|
ok = false
|
||||||
|
// ref. https://wlan1nde.wordpress.com/2014/10/27/4-way-handshake/
|
||||||
|
if keyLayer := packet.Layer(layers.LayerTypeEAPOLKey); keyLayer != nil {
|
||||||
|
if key = keyLayer.(*layers.EAPOLKey); key.KeyType == layers.EAPOLKeyTypePairwise {
|
||||||
|
ok = true
|
||||||
|
if dot11.Flags.FromDS() {
|
||||||
|
staMac = dot11.Address1
|
||||||
|
apMac = dot11.Address2
|
||||||
|
} else if dot11.Flags.ToDS() {
|
||||||
|
staMac = dot11.Address2
|
||||||
|
apMac = dot11.Address1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue