mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
new: mac.changer module can now be used on any interface.
This commit is contained in:
parent
d5c030688a
commit
b789a48f46
2 changed files with 17 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue