mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 04:52:10 -07:00
fix: workaround for PCAP_SET_RFMON issue (fixes #819, https://github.com/the-tcpdump-group/libpcap/issues/1041, https://github.com/the-tcpdump-group/libpcap/issues/1033)
This commit is contained in:
parent
06623ddfb9
commit
b12ba7947b
4 changed files with 30 additions and 4 deletions
|
@ -21,7 +21,6 @@ import (
|
||||||
"github.com/evilsocket/islazy/fs"
|
"github.com/evilsocket/islazy/fs"
|
||||||
"github.com/evilsocket/islazy/ops"
|
"github.com/evilsocket/islazy/ops"
|
||||||
"github.com/evilsocket/islazy/str"
|
"github.com/evilsocket/islazy/str"
|
||||||
"github.com/evilsocket/islazy/tui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type WiFiModule struct {
|
type WiFiModule struct {
|
||||||
|
@ -581,9 +580,12 @@ func (mod *WiFiModule) Configure() error {
|
||||||
// second fatal error, just bail
|
// second fatal error, just bail
|
||||||
return fmt.Errorf("error while activating handle: %s", err)
|
return fmt.Errorf("error while activating handle: %s", err)
|
||||||
} else {
|
} else {
|
||||||
// first fatal error, try again without setting the interface in monitor mode
|
// first fatal error, forcing monitor mode
|
||||||
mod.Warning("error while activating handle: %s, %s", err, tui.Bold("interface might already be monitoring. retrying!"))
|
// https://github.com/bettercap/bettercap/issues/819
|
||||||
opts.Monitor = false
|
opts.Monitor = false;
|
||||||
|
if err := network.ForceMonitorMode(ifName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,10 @@ func getInterfaceName(iface net.Interface) string {
|
||||||
return iface.Name
|
return iface.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ForceMonitorMode(iface string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func SetInterfaceChannel(iface string, channel int) error {
|
func SetInterfaceChannel(iface string, channel int) error {
|
||||||
cIface := C.CString(iface)
|
cIface := C.CString(iface)
|
||||||
defer C.free(unsafe.Pointer(cIface))
|
defer C.free(unsafe.Pointer(cIface))
|
||||||
|
|
|
@ -16,6 +16,22 @@ func getInterfaceName(iface net.Interface) string {
|
||||||
return iface.Name
|
return iface.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See https://github.com/bettercap/bettercap/issues/819
|
||||||
|
func ForceMonitorMode(iface string) error {
|
||||||
|
_, _ = core.Exec("ip", []string{"link", "set", iface, "down"})
|
||||||
|
|
||||||
|
out, err := core.Exec("iw", []string{"dev", iface, "set", "type", "monitor"})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("iw: out=%s err=%s", out, err)
|
||||||
|
} else if out != "" {
|
||||||
|
return fmt.Errorf("Unexpected output while setting interface %s into monitor mode: %s", iface, out)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _ = core.Exec("ip", []string{"link", "set", iface, "up"})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func SetInterfaceChannel(iface string, channel int) error {
|
func SetInterfaceChannel(iface string, channel int) error {
|
||||||
curr := GetInterfaceChannel(iface)
|
curr := GetInterfaceChannel(iface)
|
||||||
// the interface is already on this channel
|
// the interface is already on this channel
|
||||||
|
|
|
@ -53,3 +53,7 @@ func GetSupportedFrequencies(iface string) ([]int, error) {
|
||||||
freqs := make([]int, 0)
|
freqs := make([]int, 0)
|
||||||
return freqs, fmt.Errorf("Windows does not support WiFi channel hopping.")
|
return freqs, fmt.Errorf("Windows does not support WiFi channel hopping.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ForceMonitorMode(iface string) error {
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue