diff --git a/modules/wifi_recon.go b/modules/wifi_recon.go index f8eb5b5d..7a7e4b68 100644 --- a/modules/wifi_recon.go +++ b/modules/wifi_recon.go @@ -168,7 +168,6 @@ func mhz2chan(freq int) int { if freq <= 2484 { return ((freq - 2412) / 5) + 1 } - return 0 } @@ -263,7 +262,7 @@ func (w *WiFiRecon) Configure() error { func (w *WiFiRecon) sendDeauthPacket(ap net.HardwareAddr, client net.HardwareAddr) { for seq := uint16(0); seq < 64; seq++ { - if err, pkt := packets.NewDot11Deauth(ap, client, ap, layers.Dot11TypeMgmtDeauthentication, layers.Dot11ReasonClass2FromNonAuth, seq); err != nil { + if err, pkt := packets.NewDot11Deauth(ap, client, ap, seq); err != nil { log.Error("Could not create deauth packet: %s", err) continue } else if err := w.handle.WritePacketData(pkt); err != nil { @@ -273,7 +272,7 @@ func (w *WiFiRecon) sendDeauthPacket(ap net.HardwareAddr, client net.HardwareAdd time.Sleep(2 * time.Millisecond) } - if err, pkt := packets.NewDot11Deauth(client, ap, ap, layers.Dot11TypeMgmtDeauthentication, layers.Dot11ReasonClass2FromNonAuth, seq); err != nil { + if err, pkt := packets.NewDot11Deauth(client, ap, ap, seq); err != nil { log.Error("Could not create deauth packet: %s", err) continue } else if err := w.handle.WritePacketData(pkt); err != nil { diff --git a/packets/dot11.go b/packets/dot11.go index 3b8e773f..f173d4f3 100644 --- a/packets/dot11.go +++ b/packets/dot11.go @@ -7,25 +7,19 @@ import ( "github.com/google/gopacket/layers" ) -func NewDot11Deauth(a1 net.HardwareAddr, a2 net.HardwareAddr, a3 net.HardwareAddr, t layers.Dot11Type, reason layers.Dot11Reason, seq uint16) (error, []byte) { - var ( - deauth layers.Dot11MgmtDeauthentication - dot11Layer layers.Dot11 - radioTapLayer layers.RadioTap - ) - - deauth.Reason = reason - - dot11Layer.Address1 = a1 - dot11Layer.Address2 = a2 - dot11Layer.Address3 = a3 - dot11Layer.Type = t - dot11Layer.SequenceNumber = seq - +func NewDot11Deauth(a1 net.HardwareAddr, a2 net.HardwareAddr, a3 net.HardwareAddr, seq uint16) (error, []byte) { return Serialize( - &radioTapLayer, - &dot11Layer, - &deauth, + &layers.RadioTap{}, + &layers.Dot11{ + Address1: a1, + Address2: a2, + Address3: a3, + Type: layers.Dot11TypeMgmtDeauthentication, + SequenceNumber: seq, + }, + &layers.Dot11MgmtDeauthentication{ + Reason: layers.Dot11ReasonClass2FromNonAuth, + }, ) }