misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2019-02-12 12:12:04 +01:00
commit 57983c6524
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
2 changed files with 95 additions and 91 deletions

View file

@ -273,3 +273,21 @@ func Dot11ParseDSSet(packet gopacket.Packet) (bool, int) {
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
}