Simone Margaritelli 2024-08-08 13:40:45 +02:00
commit b12ba7947b
4 changed files with 30 additions and 4 deletions

View file

@ -16,6 +16,22 @@ func getInterfaceName(iface net.Interface) string {
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 {
curr := GetInterfaceChannel(iface)
// the interface is already on this channel