From 59441898023446708a7f205348ea019791a7e129 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Thu, 21 Feb 2019 14:20:28 +0100 Subject: [PATCH] new: new wifi.show.manufacturer parameter to show APs manufacturers (fixes #456) --- modules/wifi/wifi.go | 6 +++ modules/wifi/wifi_show.go | 84 +++++++++++++++++++++++++++++---------- 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/modules/wifi/wifi.go b/modules/wifi/wifi.go index 2f9c00b7..d5a388ed 100644 --- a/modules/wifi/wifi.go +++ b/modules/wifi/wifi.go @@ -48,6 +48,7 @@ type WiFiModule struct { assocOpen bool shakesFile string apRunning bool + showManuf bool apConfig packets.Dot11ApConfig writes *sync.WaitGroup reads *sync.WaitGroup @@ -72,6 +73,7 @@ func NewWiFiModule(s *session.Session) *WiFiModule { assocSkip: []net.HardwareAddr{}, assocSilent: false, assocOpen: false, + showManuf: false, writes: &sync.WaitGroup{}, reads: &sync.WaitGroup{}, chanLock: &sync.Mutex{}, @@ -245,6 +247,10 @@ func NewWiFiModule(s *session.Session) *WiFiModule { mod.selector = utils.ViewSelectorFor(&mod.SessionModule, "wifi.show", []string{"rssi", "bssid", "essid", "channel", "encryption", "clients", "seen", "sent", "rcvd"}, "rssi asc") + mod.AddParam(session.NewBoolParameter("wifi.show.manufacturer", + "false", + "If true, wifi.show will also show the devices manufacturers.")) + mod.AddHandler(session.NewModuleHandler("wifi.recon.channel", `wifi\.recon\.channel[\s]+([0-9]+(?:[, ]+[0-9]+)*|clear)`, "WiFi channels (comma separated) or 'clear' for channel hopping.", func(args []string) (err error) { diff --git a/modules/wifi/wifi_show.go b/modules/wifi/wifi_show.go index a29f6539..bde27a88 100644 --- a/modules/wifi/wifi_show.go +++ b/modules/wifi/wifi_show.go @@ -81,14 +81,26 @@ func (mod *WiFiModule) getRow(station *network.Station) ([]string, bool) { } if mod.isApSelected() { - return []string{ - rssi, - bssid, - strconv.Itoa(station.Channel()), - sent, - recvd, - seen, - }, include + if mod.showManuf { + return []string{ + rssi, + bssid, + tui.Dim(station.Vendor), + strconv.Itoa(station.Channel()), + sent, + recvd, + seen, + }, include + } else { + return []string{ + rssi, + bssid, + strconv.Itoa(station.Channel()), + sent, + recvd, + seen, + }, include + } } else { // this is ugly, but necessary in order to have this // method handle both access point and clients @@ -117,18 +129,34 @@ func (mod *WiFiModule) getRow(station *network.Station) ([]string, bool) { wps = tui.Dim(tui.Yellow(wps)) } - return []string{ - rssi, - bssid, - ssid, - encryption, - wps, - strconv.Itoa(station.Channel()), - clients, - sent, - recvd, - seen, - }, include + if mod.showManuf { + return []string{ + rssi, + bssid, + tui.Dim(station.Vendor), + ssid, + encryption, + wps, + strconv.Itoa(station.Channel()), + clients, + sent, + recvd, + seen, + }, include + } else { + return []string{ + rssi, + bssid, + ssid, + encryption, + wps, + strconv.Itoa(station.Channel()), + clients, + sent, + recvd, + seen, + }, include + } } } @@ -225,9 +253,17 @@ func (mod *WiFiModule) colNames(nrows int) []string { columns := []string(nil) if !mod.isApSelected() { - columns = []string{"RSSI", "BSSID", "SSID", "Encryption", "WPS", "Ch", "Clients", "Sent", "Recvd", "Seen"} + if mod.showManuf { + columns = []string{"RSSI", "BSSID", "Manufacturer", "SSID", "Encryption", "WPS", "Ch", "Clients", "Sent", "Recvd", "Seen"} + } else { + columns = []string{"RSSI", "BSSID", "SSID", "Encryption", "WPS", "Ch", "Clients", "Sent", "Recvd", "Seen"} + } } else if nrows > 0 { - columns = []string{"RSSI", "BSSID", "Ch", "Sent", "Recvd", "Seen"} + if mod.showManuf { + columns = []string{"RSSI", "BSSID", "Manufacturer", "Ch", "Sent", "Recvd", "Seen"} + } else { + columns = []string{"RSSI", "BSSID", "Ch", "Sent", "Recvd", "Seen"} + } fmt.Printf("\n%s clients:\n", mod.ap.HwAddress) } else { fmt.Printf("\nNo authenticated clients detected for %s.\n", mod.ap.HwAddress) @@ -287,6 +323,10 @@ func (mod *WiFiModule) Show() (err error) { return } + if err, mod.showManuf = mod.BoolParam("wifi.show.manufacturer"); err != nil { + return err + } + rows := make([][]string, 0) for _, s := range stations { if row, include := mod.getRow(s); include {