new: mac.changer module can now be used on any interface.

This commit is contained in:
evilsocket 2018-02-05 16:59:21 +01:00
commit b789a48f46
2 changed files with 17 additions and 4 deletions

View file

@ -14,6 +14,7 @@ import (
type MacChanger struct {
session.SessionModule
iface string
originalMac net.HardwareAddr
fakeMac net.HardwareAddr
}
@ -23,6 +24,11 @@ func NewMacChanger(s *session.Session) *MacChanger {
SessionModule: session.NewSessionModule("mac.changer", s),
}
mc.AddParam(session.NewStringParameter("mac.changer.iface",
session.ParamIfaceName,
"",
"Name of the interface to use."))
mc.AddParam(session.NewStringParameter("mac.changer.address",
session.ParamRandomMAC,
"[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}",
@ -58,6 +64,10 @@ func (mc *MacChanger) Author() string {
func (mc *MacChanger) Configure() (err error) {
var changeTo string
if err, mv.iface = mc.StringParam("mac.changer.iface"); err != nil {
return err
}
if err, changeTo = mc.StringParam("mac.changer.address"); err != nil {
return err
}
@ -77,11 +87,11 @@ func (mc *MacChanger) setMac(mac net.HardwareAddr) error {
args := []string{}
if strings.Contains(os, "bsd") || os == "darwin" {
args = []string{mc.Session.Interface.Name(), "ether", mac.String()}
args = []string{mc.iface, "ether", mac.String()}
} else if os == "linux" {
args = []string{mc.Session.Interface.Name(), "hw", "ether", mac.String()}
args = []string{mc.iface, "hw", "ether", mac.String()}
} else {
return fmt.Errorf("OS %s not supported by mac.changer module.", os)
return fmt.Errorf("OS %s is not supported by mac.changer module.", os)
}
_, err := core.Exec("ifconfig", args)

View file

@ -82,6 +82,7 @@ func (p ModuleParam) Validate(value string) (error, interface{}) {
return fmt.Errorf("Unhandled module parameter type %d.", p.Type), nil
}
const ParamIfaceName = "<interface name>"
const ParamIfaceAddress = "<interface address>"
const ParamSubnet = "<entire subnet>"
const ParamRandomMAC = "<random mac>"
@ -96,7 +97,9 @@ func (p ModuleParam) Get(s *Session) (error, interface{}) {
v = ""
}
if v == ParamIfaceAddress {
if v == ParamIfaceName {
v = s.Interface.Name()
} else if v == ParamIfaceAddress {
v = s.Interface.IpAddress
} else if v == ParamSubnet {
v = s.Interface.CIDR()