new: implemented channel hopping for wifi.recon module ( ref #53 )

This commit is contained in:
evilsocket 2018-02-17 02:41:10 +01:00
parent e1e2e33f57
commit a66f5fabbb
4 changed files with 87 additions and 2 deletions

View file

@ -3,8 +3,12 @@ package network
import (
"net"
"regexp"
"github.com/evilsocket/bettercap-ng/core"
)
const airPortPath = "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"
var IPv4RouteParser = regexp.MustCompile("^([a-z]+)+\\s+(\\d+\\.+\\d+.\\d.+\\d)+\\s+([a-zA-z]+)+\\s+(\\d+)+\\s+(\\d+)+\\s+([a-zA-Z]+\\d+)$")
var IPv4RouteTokens = 7
var IPv4RouteCmd = "netstat"
@ -26,3 +30,13 @@ func IPv4RouteIsGateway(ifname string, tokens []string, f func(gateway string) (
func getInterfaceName(iface net.Interface) string {
return iface.Name
}
func SetInterfaceChannel(iface string, channel int) error {
out, err := core.Exec(airPortPath, []string{iface, "--channel", fmt.Sprintf("%d", channel)})
if err != nil {
return err
} else if out != "" {
return fmt.Errorf("Unexpected output while setting interface %s to channel %d: %s", iface, channel, out)
}
return nil
}