mirror of
https://github.com/bettercap/bettercap
synced 2025-07-05 20:42:09 -07:00
fix: bring interface down for mac.changer module
This commit is contained in:
parent
08da91ed5c
commit
d8e11287c6
1 changed files with 9 additions and 2 deletions
|
@ -82,6 +82,11 @@ func (mod *MacChanger) Configure() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *MacChanger) setMac(mac net.HardwareAddr) error {
|
func (mod *MacChanger) setMac(mac net.HardwareAddr) error {
|
||||||
|
core.Exec("ifconfig", []string{mod.iface, "down"})
|
||||||
|
defer func() {
|
||||||
|
core.Exec("ifconfig", []string{mod.iface, "up"})
|
||||||
|
}()
|
||||||
|
|
||||||
var args []string
|
var args []string
|
||||||
|
|
||||||
os := runtime.GOOS
|
os := runtime.GOOS
|
||||||
|
@ -90,12 +95,14 @@ func (mod *MacChanger) setMac(mac net.HardwareAddr) error {
|
||||||
} else if os == "linux" || os == "android" {
|
} else if os == "linux" || os == "android" {
|
||||||
args = []string{mod.iface, "hw", "ether", mac.String()}
|
args = []string{mod.iface, "hw", "ether", mac.String()}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("OS %s is not supported by mac.changer module.", os)
|
return fmt.Errorf("%s is not supported by this module", os)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := core.Exec("ifconfig", args)
|
out, err := core.Exec("ifconfig", args)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
mod.Session.Interface.HW = mac
|
mod.Session.Interface.HW = mac
|
||||||
|
} else {
|
||||||
|
mod.Warning("%v: %s", err, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue