fix: fixed a bug which caused APs encryption to be downgraded when incomplete dot11 frames are parsed

This commit is contained in:
evilsocket 2019-02-15 12:40:16 +01:00
commit 54a8888b13
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -1,8 +1,8 @@
package wifi package wifi
import ( import (
"bytes"
"fmt" "fmt"
"net" "net"
"strconv" "strconv"
"sync" "sync"
@ -18,6 +18,7 @@ import (
"github.com/google/gopacket/pcap" "github.com/google/gopacket/pcap"
"github.com/evilsocket/islazy/fs" "github.com/evilsocket/islazy/fs"
"github.com/evilsocket/islazy/ops"
"github.com/evilsocket/islazy/str" "github.com/evilsocket/islazy/str"
"github.com/evilsocket/islazy/tui" "github.com/evilsocket/islazy/tui"
) )
@ -381,19 +382,26 @@ func (mod *WiFiModule) Configure() error {
} }
func (mod *WiFiModule) updateInfo(dot11 *layers.Dot11, packet gopacket.Packet) { func (mod *WiFiModule) updateInfo(dot11 *layers.Dot11, packet gopacket.Packet) {
if ok, enc, cipher, auth := packets.Dot11ParseEncryption(packet, dot11); ok { // avoid parsing info from frames we're sending
bssid := dot11.Address3.String() staMac := ops.Ternary(dot11.Flags.FromDS(), dot11.Address1, dot11.Address2).(net.HardwareAddr)
if station, found := mod.Session.WiFi.Get(bssid); found { if !bytes.Equal(staMac, mod.Session.Interface.HW) {
station.Encryption = enc if ok, enc, cipher, auth := packets.Dot11ParseEncryption(packet, dot11); ok {
station.Cipher = cipher // Sometimes we get incomplete info about encryption, which
station.Authentication = auth // makes stations with encryption enabled switch to OPEN.
// Prevent this behaviour by not downgrading the encryption.
bssid := dot11.Address3.String()
if station, found := mod.Session.WiFi.Get(bssid); found && station.IsOpen() {
station.Encryption = enc
station.Cipher = cipher
station.Authentication = auth
}
} }
}
if ok, bssid, info := packets.Dot11ParseWPS(packet, dot11); ok { if ok, bssid, info := packets.Dot11ParseWPS(packet, dot11); ok {
if station, found := mod.Session.WiFi.Get(bssid.String()); found { if station, found := mod.Session.WiFi.Get(bssid.String()); found {
for name, value := range info { for name, value := range info {
station.WPS[name] = value station.WPS[name] = value
}
} }
} }
} }