mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
fix: fixed a bug in wifi.recon.channel
This commit is contained in:
parent
621f03c946
commit
605361daa2
1 changed files with 17 additions and 18 deletions
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -18,6 +17,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/str"
|
||||||
"github.com/evilsocket/islazy/tui"
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -177,29 +177,28 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
|
|
||||||
w.AddHandler(session.NewModuleHandler("wifi.recon.channel", `wifi\.recon\.channel[\s]+([0-9]+(?:[, ]+[0-9]+)*|clear)`,
|
w.AddHandler(session.NewModuleHandler("wifi.recon.channel", `wifi\.recon\.channel[\s]+([0-9]+(?:[, ]+[0-9]+)*|clear)`,
|
||||||
"WiFi channels (comma separated) or 'clear' for channel hopping.",
|
"WiFi channels (comma separated) or 'clear' for channel hopping.",
|
||||||
func(args []string) error {
|
func(args []string) (err error) {
|
||||||
newfrequencies := w.frequencies[:0]
|
freqs := []int{}
|
||||||
|
|
||||||
if len(args) > 0 && args[0] != "clear" {
|
if args[0] != "clear" {
|
||||||
channels := strings.Split(args[0], ",")
|
log.Info("setting hopping channels to %s", args[0])
|
||||||
for _, c := range channels {
|
for _, s := range str.Comma(args[0]) {
|
||||||
trimmed := strings.Trim(c, " ")
|
if ch, err := strconv.Atoi(s); err != nil {
|
||||||
channel, err := strconv.Atoi(trimmed)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
newfrequencies = append(newfrequencies, network.Dot11Chan2Freq(channel))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// No channels setted, retrieve frequencies supported by the card
|
|
||||||
if frequencies, err := network.GetSupportedFrequencies(w.Session.Interface.Name()); err != nil {
|
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
newfrequencies = frequencies
|
freqs = append(freqs, network.Dot11Chan2Freq(ch))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w.frequencies = newfrequencies
|
if len(freqs) == 0 {
|
||||||
|
log.Info("resetting hopping channels")
|
||||||
|
if freqs, err = network.GetSupportedFrequencies(w.Session.Interface.Name()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
w.frequencies = freqs
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue