new: started implementing RSN PMKID parsing support (ref #436)

This commit is contained in:
evilsocket 2019-02-07 15:15:15 +01:00
commit 0ec645afd3
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
4 changed files with 39 additions and 3 deletions

View file

@ -1,8 +1,10 @@
package network
import (
"github.com/google/gopacket"
"sync"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
type Handshake struct {
@ -34,6 +36,29 @@ func (h *Handshake) SetBeacon(pkt gopacket.Packet) {
}
}
func (h *Handshake) AddAndGetPMKID(pkt gopacket.Packet) []byte {
h.AddFrame(0, pkt)
prevWasKey := false
for _, layer := range pkt.Layers() {
if layer.LayerType() == layers.LayerTypeEAPOLKey {
prevWasKey = true
continue
}
if prevWasKey && layer.LayerType() == layers.LayerTypeDot11InformationElement {
info := layer.(*layers.Dot11InformationElement)
if info.ID == layers.Dot11InformationElementIDVendor && info.Length == 20 {
return info.Info
}
}
prevWasKey = false
}
return nil
}
func (h *Handshake) AddFrame(n int, pkt gopacket.Packet) {
h.Lock()
defer h.Unlock()