new: parsing WPS RF bands

This commit is contained in:
evilsocket 2019-01-27 16:45:15 +01:00
commit be055f5e41
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -53,7 +53,7 @@ var (
0x1011: wpsAttr{Name: "Device Name", Type: wpsStr}, 0x1011: wpsAttr{Name: "Device Name", Type: wpsStr},
0x1053: wpsAttr{Name: "Selected Registrar Config Methods", Func: dot11ParseWPSConfigMethods}, 0x1053: wpsAttr{Name: "Selected Registrar Config Methods", Func: dot11ParseWPSConfigMethods},
0x1008: wpsAttr{Name: "Config Methods", Func: dot11ParseWPSConfigMethods}, 0x1008: wpsAttr{Name: "Config Methods", Func: dot11ParseWPSConfigMethods},
0x103C: wpsAttr{Name: "RF Bands"}, 0x103C: wpsAttr{Name: "RF Bands", Func: dott11ParseWPSBands},
0x1045: wpsAttr{Name: "SSID", Type: wpsStr}, 0x1045: wpsAttr{Name: "SSID", Type: wpsStr},
0x102D: wpsAttr{Name: "OS Version", Type: wpsStr}, 0x102D: wpsAttr{Name: "OS Version", Type: wpsStr},
0x1049: wpsAttr{Name: "Vendor Extension"}, 0x1049: wpsAttr{Name: "Vendor Extension"},
@ -70,8 +70,32 @@ var (
0x0080: "Push Button", 0x0080: "Push Button",
0x0100: "Keypad", 0x0100: "Keypad",
} }
wpsBands = map[uint8]string{
0x01: "2.4Ghz",
0x02: "5.0Ghz",
}
) )
func dott11ParseWPSBands(data []byte) string {
if len(data) == 1 {
mask := uint8(data[0])
bands := []string{}
for bit, band := range wpsBands {
if mask&bit != 0 {
bands = append(bands, band)
}
}
if len(bands) > 0 {
return strings.Join(bands, ", ")
}
}
return hex.EncodeToString(data)
}
func dot11ParseWPSConfigMethods(data []byte) string { func dot11ParseWPSConfigMethods(data []byte) string {
if len(data) == 2 { if len(data) == 2 {
mask := binary.BigEndian.Uint16(data) mask := binary.BigEndian.Uint16(data)