mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
fix: sorting WPS fields by name for wifi.show.wps command
This commit is contained in:
parent
85f713f610
commit
4e82a4356a
1 changed files with 12 additions and 5 deletions
|
@ -296,18 +296,18 @@ func (w *WiFiModule) Show() (err error) {
|
|||
}
|
||||
|
||||
func (w *WiFiModule) ShowWPS(bssid string) (err error) {
|
||||
toShow := []*network.AccessPoint{}
|
||||
toShow := []*network.Station{}
|
||||
|
||||
if bssid == network.BroadcastMac {
|
||||
for _, station := range w.Session.WiFi.List() {
|
||||
if station.HasWPS() {
|
||||
toShow = append(toShow, station)
|
||||
toShow = append(toShow, station.Station)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if station, found := w.Session.WiFi.Get(bssid); found {
|
||||
if station.HasWPS() {
|
||||
toShow = append(toShow, station)
|
||||
toShow = append(toShow, station.Station)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -316,6 +316,7 @@ func (w *WiFiModule) ShowWPS(bssid string) (err error) {
|
|||
return fmt.Errorf("no WPS enabled access points matched the criteria")
|
||||
}
|
||||
|
||||
sort.Sort(ByBssidSorter(toShow))
|
||||
for _, station := range toShow {
|
||||
ssid := station.ESSID()
|
||||
if ssid == "<hidden>" {
|
||||
|
@ -324,8 +325,14 @@ func (w *WiFiModule) ShowWPS(bssid string) (err error) {
|
|||
|
||||
fmt.Println()
|
||||
fmt.Printf("* %s (%s ch:%d):\n", tui.Bold(ssid), tui.Dim(station.BSSID()), station.Channel())
|
||||
for name, value := range station.WPS {
|
||||
fmt.Printf(" %s: %s\n", name, tui.Yellow(value))
|
||||
keys := []string{}
|
||||
for name, _ := range station.WPS {
|
||||
keys = append(keys, name)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for _, name := range keys {
|
||||
fmt.Printf(" %s: %s\n", name, tui.Yellow(station.WPS[name]))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue