diff --git a/modules/wifi_beacon_flood.go b/modules/wifi_beacon_flood.go index 42561b95..e38a5ef7 100644 --- a/modules/wifi_beacon_flood.go +++ b/modules/wifi_beacon_flood.go @@ -11,16 +11,32 @@ import ( "github.com/google/gopacket/layers" ) -func NewDot11Beacon(bssid net.HardwareAddr, ssid string, seq uint16) (error, []byte) { +type Dot11EncryptionType int + +const ( + Dot11Open Dot11EncryptionType = iota + Dot11Wep + Dot11WpaTKIP + Dot11WpaAES +) + +type Dot11BeaconConfig struct { + SSID string + BSSID net.HardwareAddr + Channel int + Encryption Dot11EncryptionType +} + +func NewDot11Beacon(conf Dot11BeaconConfig) (error, []byte) { // TODO: still very incomplete return packets.Serialize( &layers.RadioTap{}, &layers.Dot11{ Address1: network.BroadcastHw, - Address2: bssid, - Address3: bssid, + Address2: conf.BSSID, + Address3: conf.BSSID, Type: layers.Dot11TypeMgmtBeacon, - SequenceNumber: seq, // not sure this needs to be a specific value + SequenceNumber: 0, // not sure this needs to be a specific value }, &layers.Dot11MgmtBeacon{ Timestamp: uint64(time.Now().Second()), // not sure @@ -29,8 +45,8 @@ func NewDot11Beacon(bssid net.HardwareAddr, ssid string, seq uint16) (error, []b }, &layers.Dot11InformationElement{ ID: layers.Dot11InformationElementIDSSID, - Length: uint8(len(ssid) & 0xff), - Info: []byte(ssid), + Length: uint8(len(conf.SSID) & 0xff), + Info: []byte(conf.SSID), }, // TODO: Rates n stuff ... &layers.Dot11InformationElement{ @@ -50,7 +66,14 @@ func (w *WiFiModule) sendBeaconPacket(counter int) { w.writes.Add(1) defer w.writes.Done() - if err, pkt := NewDot11Beacon(w.Session.Interface.HW, "Prova", uint16(counter)); err != nil { + conf := Dot11BeaconConfig{ + SSID: "Prova", + BSSID: w.Session.Interface.HW, + Channel: 1, + Encryption: Dot11Open, + } + + if err, pkt := NewDot11Beacon(conf); err != nil { log.Error("Could not create beacon packet: %s", err) } else { w.injectPacket(pkt)