mirror of
https://github.com/bettercap/bettercap
synced 2025-08-13 02:06:57 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
be82e83787
commit
ac9520b2fe
1 changed files with 22 additions and 22 deletions
|
@ -27,19 +27,19 @@ import (
|
||||||
type WiFiRecon struct {
|
type WiFiRecon struct {
|
||||||
session.SessionModule
|
session.SessionModule
|
||||||
|
|
||||||
wifi *WiFi
|
wifi *WiFi
|
||||||
stats *WiFiStats
|
stats *WiFiStats
|
||||||
handle *pcap.Handle
|
handle *pcap.Handle
|
||||||
cliTarget net.HardwareAddr
|
client net.HardwareAddr
|
||||||
apTarget net.HardwareAddr
|
accessPoint net.HardwareAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWiFiRecon(s *session.Session) *WiFiRecon {
|
func NewWiFiRecon(s *session.Session) *WiFiRecon {
|
||||||
w := &WiFiRecon{
|
w := &WiFiRecon{
|
||||||
SessionModule: session.NewSessionModule("wifi.recon", s),
|
SessionModule: session.NewSessionModule("wifi.recon", s),
|
||||||
stats: NewWiFiStats(),
|
stats: NewWiFiStats(),
|
||||||
cliTarget: make([]byte, 0),
|
client: make([]byte, 0),
|
||||||
apTarget: make([]byte, 0),
|
accessPoint: make([]byte, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
w.AddHandler(session.NewModuleHandler("wifi.recon on", "",
|
w.AddHandler(session.NewModuleHandler("wifi.recon on", "",
|
||||||
|
@ -64,14 +64,14 @@ func NewWiFiRecon(s *session.Session) *WiFiRecon {
|
||||||
"Set client to deauth (single target).",
|
"Set client to deauth (single target).",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
var err error
|
var err error
|
||||||
w.cliTarget, err = net.ParseMAC(args[0])
|
w.client, err = net.ParseMAC(args[0])
|
||||||
return err
|
return err
|
||||||
}))
|
}))
|
||||||
|
|
||||||
w.AddHandler(session.NewModuleHandler("wifi.recon clear client", "",
|
w.AddHandler(session.NewModuleHandler("wifi.recon clear client", "",
|
||||||
"Remove client to deauth.",
|
"Remove client to deauth.",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
w.cliTarget = make([]byte, 0)
|
w.client = make([]byte, 0)
|
||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ func NewWiFiRecon(s *session.Session) *WiFiRecon {
|
||||||
if w.wifi != nil {
|
if w.wifi != nil {
|
||||||
w.wifi.Clear()
|
w.wifi.Clear()
|
||||||
}
|
}
|
||||||
w.apTarget, err = net.ParseMAC(args[0])
|
w.accessPoint, err = net.ParseMAC(args[0])
|
||||||
return err
|
return err
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ func NewWiFiRecon(s *session.Session) *WiFiRecon {
|
||||||
if w.wifi != nil {
|
if w.wifi != nil {
|
||||||
w.wifi.Clear()
|
w.wifi.Clear()
|
||||||
}
|
}
|
||||||
w.apTarget = make([]byte, 0)
|
w.accessPoint = make([]byte, 0)
|
||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -238,16 +238,16 @@ func (w *WiFiRecon) sendDeauthPacket(ap net.HardwareAddr, client net.HardwareAdd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WiFiRecon) startDeauth() error {
|
func (w *WiFiRecon) startDeauth() error {
|
||||||
isTargetingAP := len(w.apTarget) > 0
|
isTargetingAP := len(w.accessPoint) > 0
|
||||||
if isTargetingAP {
|
if isTargetingAP {
|
||||||
isTargetingCLI := len(w.cliTarget) > 0
|
isTargetingCLI := len(w.client) > 0
|
||||||
if isTargetingCLI {
|
if isTargetingCLI {
|
||||||
// deauth a specific client
|
// deauth a specific client
|
||||||
w.sendDeauthPacket(w.apTarget, w.cliTarget)
|
w.sendDeauthPacket(w.accessPoint, w.client)
|
||||||
} else {
|
} else {
|
||||||
// deauth all AP's clients
|
// deauth all AP's clients
|
||||||
for _, station := range w.wifi.Stations {
|
for _, station := range w.wifi.Stations {
|
||||||
w.sendDeauthPacket(w.apTarget, station.HW)
|
w.sendDeauthPacket(w.accessPoint, station.HW)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -321,10 +321,8 @@ func (w *WiFiRecon) discoverClients(bs net.HardwareAddr, packet gopacket.Packet)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WiFiRecon) Configure() error {
|
func (w *WiFiRecon) Configure() error {
|
||||||
var err error
|
ihandle, err := pcap.NewInactiveHandle(w.Session.Interface.Name())
|
||||||
var ihandle *pcap.InactiveHandle
|
if err != nil {
|
||||||
|
|
||||||
if ihandle, err = pcap.NewInactiveHandle(w.Session.Interface.Name()); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer ihandle.CleanUp()
|
defer ihandle.CleanUp()
|
||||||
|
@ -395,10 +393,12 @@ func (w *WiFiRecon) Start() error {
|
||||||
|
|
||||||
w.updateStats(packet)
|
w.updateStats(packet)
|
||||||
|
|
||||||
if len(w.apTarget) > 0 {
|
if len(w.accessPoint) == 0 {
|
||||||
w.discoverClients(w.apTarget, packet)
|
// no access point bssid selected, keep scanning for other aps
|
||||||
} else {
|
|
||||||
w.discoverAccessPoints(packet)
|
w.discoverAccessPoints(packet)
|
||||||
|
} else {
|
||||||
|
// discover stations connected to the selected access point bssid
|
||||||
|
w.discoverClients(w.accessPoint, packet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue