mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
fix: wifi.AccessPoint and wifi.Station now export the Channel field via JSON
This commit is contained in:
parent
4ae1ffd171
commit
78c341c2b3
5 changed files with 13 additions and 16 deletions
|
@ -106,7 +106,7 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
return err
|
return err
|
||||||
} else if ap, found := mod.Session.WiFi.Get(bssid.String()); found {
|
} else if ap, found := mod.Session.WiFi.Get(bssid.String()); found {
|
||||||
mod.ap = ap
|
mod.ap = ap
|
||||||
mod.stickChan = ap.Channel()
|
mod.stickChan = ap.Channel
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("Could not find station with BSSID %s", args[0])
|
return fmt.Errorf("Could not find station with BSSID %s", args[0])
|
||||||
|
|
|
@ -97,7 +97,7 @@ func (mod *WiFiModule) startAssoc(to net.HardwareAddr) error {
|
||||||
// association request, let's sort by channel so we do the minimum
|
// association request, let's sort by channel so we do the minimum
|
||||||
// amount of hops possible
|
// amount of hops possible
|
||||||
sort.Slice(toAssoc, func(i, j int) bool {
|
sort.Slice(toAssoc, func(i, j int) bool {
|
||||||
return toAssoc[i].Channel() < toAssoc[j].Channel()
|
return toAssoc[i].Channel < toAssoc[j].Channel
|
||||||
})
|
})
|
||||||
|
|
||||||
// send the association request frames
|
// send the association request frames
|
||||||
|
@ -111,9 +111,9 @@ func (mod *WiFiModule) startAssoc(to net.HardwareAddr) error {
|
||||||
if ap.IsOpen() && !mod.doAssocOpen() {
|
if ap.IsOpen() && !mod.doAssocOpen() {
|
||||||
mod.Debug("skipping association for open network %s (wifi.assoc.open is false)", ap.ESSID())
|
mod.Debug("skipping association for open network %s (wifi.assoc.open is false)", ap.ESSID())
|
||||||
} else {
|
} else {
|
||||||
logger("sending association request to AP %s (channel:%d encryption:%s)", ap.ESSID(), ap.Channel(), ap.Encryption)
|
logger("sending association request to AP %s (channel:%d encryption:%s)", ap.ESSID(), ap.Channel, ap.Encryption)
|
||||||
|
|
||||||
mod.onChannel(ap.Channel(), func() {
|
mod.onChannel(ap.Channel, func() {
|
||||||
mod.sendAssocPacket(ap)
|
mod.sendAssocPacket(ap)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ func (mod *WiFiModule) startDeauth(to net.HardwareAddr) error {
|
||||||
// deauth packet, let's sort by channel so we do the minimum
|
// deauth packet, let's sort by channel so we do the minimum
|
||||||
// amount of hops possible
|
// amount of hops possible
|
||||||
sort.Slice(toDeauth, func(i, j int) bool {
|
sort.Slice(toDeauth, func(i, j int) bool {
|
||||||
return toDeauth[i].Ap.Channel() < toDeauth[j].Ap.Channel()
|
return toDeauth[i].Ap.Channel < toDeauth[j].Ap.Channel
|
||||||
})
|
})
|
||||||
|
|
||||||
// send the deauth frames
|
// send the deauth frames
|
||||||
|
@ -137,9 +137,9 @@ func (mod *WiFiModule) startDeauth(to net.HardwareAddr) error {
|
||||||
if ap.IsOpen() && !mod.doDeauthOpen() {
|
if ap.IsOpen() && !mod.doDeauthOpen() {
|
||||||
mod.Debug("skipping deauth for open network %s (wifi.deauth.open is false)", ap.ESSID())
|
mod.Debug("skipping deauth for open network %s (wifi.deauth.open is false)", ap.ESSID())
|
||||||
} else {
|
} else {
|
||||||
logger("deauthing client %s from AP %s (channel:%d encryption:%s)", client.String(), ap.ESSID(), ap.Channel(), ap.Encryption)
|
logger("deauthing client %s from AP %s (channel:%d encryption:%s)", client.String(), ap.ESSID(), ap.Channel, ap.Encryption)
|
||||||
|
|
||||||
mod.onChannel(ap.Channel(), func() {
|
mod.onChannel(ap.Channel, func() {
|
||||||
mod.sendDeauthPacket(ap.HW, client.HW)
|
mod.sendDeauthPacket(ap.HW, client.HW)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ func (mod *WiFiModule) getRow(station *network.Station) ([]string, bool) {
|
||||||
rssi,
|
rssi,
|
||||||
bssid,
|
bssid,
|
||||||
tui.Dim(station.Vendor),
|
tui.Dim(station.Vendor),
|
||||||
strconv.Itoa(station.Channel()),
|
strconv.Itoa(station.Channel),
|
||||||
sent,
|
sent,
|
||||||
recvd,
|
recvd,
|
||||||
seen,
|
seen,
|
||||||
|
@ -95,7 +95,7 @@ func (mod *WiFiModule) getRow(station *network.Station) ([]string, bool) {
|
||||||
return []string{
|
return []string{
|
||||||
rssi,
|
rssi,
|
||||||
bssid,
|
bssid,
|
||||||
strconv.Itoa(station.Channel()),
|
strconv.Itoa(station.Channel),
|
||||||
sent,
|
sent,
|
||||||
recvd,
|
recvd,
|
||||||
seen,
|
seen,
|
||||||
|
@ -137,7 +137,7 @@ func (mod *WiFiModule) getRow(station *network.Station) ([]string, bool) {
|
||||||
ssid,
|
ssid,
|
||||||
encryption,
|
encryption,
|
||||||
wps,
|
wps,
|
||||||
strconv.Itoa(station.Channel()),
|
strconv.Itoa(station.Channel),
|
||||||
clients,
|
clients,
|
||||||
sent,
|
sent,
|
||||||
recvd,
|
recvd,
|
||||||
|
@ -150,7 +150,7 @@ func (mod *WiFiModule) getRow(station *network.Station) ([]string, bool) {
|
||||||
ssid,
|
ssid,
|
||||||
encryption,
|
encryption,
|
||||||
wps,
|
wps,
|
||||||
strconv.Itoa(station.Channel()),
|
strconv.Itoa(station.Channel),
|
||||||
clients,
|
clients,
|
||||||
sent,
|
sent,
|
||||||
recvd,
|
recvd,
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
type Station struct {
|
type Station struct {
|
||||||
*Endpoint
|
*Endpoint
|
||||||
Frequency int `json:"frequency"`
|
Frequency int `json:"frequency"`
|
||||||
|
Channel int `json:"channel"`
|
||||||
RSSI int8 `json:"rssi"`
|
RSSI int8 `json:"rssi"`
|
||||||
Sent uint64 `json:"sent"`
|
Sent uint64 `json:"sent"`
|
||||||
Received uint64 `json:"received"`
|
Received uint64 `json:"received"`
|
||||||
|
@ -19,7 +20,6 @@ type Station struct {
|
||||||
|
|
||||||
func cleanESSID(essid string) string {
|
func cleanESSID(essid string) string {
|
||||||
res := ""
|
res := ""
|
||||||
|
|
||||||
for _, c := range essid {
|
for _, c := range essid {
|
||||||
if strconv.IsPrint(c) {
|
if strconv.IsPrint(c) {
|
||||||
res += string(c)
|
res += string(c)
|
||||||
|
@ -34,6 +34,7 @@ func NewStation(essid, bssid string, frequency int, rssi int8) *Station {
|
||||||
return &Station{
|
return &Station{
|
||||||
Endpoint: NewEndpointNoResolve(MonitorModeAddress, bssid, cleanESSID(essid), 0),
|
Endpoint: NewEndpointNoResolve(MonitorModeAddress, bssid, cleanESSID(essid), 0),
|
||||||
Frequency: frequency,
|
Frequency: frequency,
|
||||||
|
Channel: Dot11Freq2Chan(frequency),
|
||||||
RSSI: rssi,
|
RSSI: rssi,
|
||||||
WPS: make(map[string]string),
|
WPS: make(map[string]string),
|
||||||
Handshake: NewHandshake(),
|
Handshake: NewHandshake(),
|
||||||
|
@ -48,10 +49,6 @@ func (s *Station) ESSID() string {
|
||||||
return s.Hostname
|
return s.Hostname
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Station) Channel() int {
|
|
||||||
return Dot11Freq2Chan(s.Frequency)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Station) HasWPS() bool {
|
func (s *Station) HasWPS() bool {
|
||||||
return len(s.WPS) > 0
|
return len(s.WPS) > 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue