| 82 | } |
| 83 | |
| 84 | func (mod *MacChanger) setMac(mac net.HardwareAddr) error { |
| 85 | core.Exec("ifconfig", []string{mod.iface, "down"}) |
| 86 | defer func() { |
| 87 | core.Exec("ifconfig", []string{mod.iface, "up"}) |
| 88 | }() |
| 89 | |
| 90 | var args []string |
| 91 | |
| 92 | os := runtime.GOOS |
| 93 | if strings.Contains(os, "bsd") || os == "darwin" { |
| 94 | args = []string{mod.iface, "ether", mac.String()} |
| 95 | } else if os == "linux" || os == "android" { |
| 96 | args = []string{mod.iface, "hw", "ether", mac.String()} |
| 97 | } else { |
| 98 | return fmt.Errorf("%s is not supported by this module", os) |
| 99 | } |
| 100 | |
| 101 | out, err := core.Exec("ifconfig", args) |
| 102 | if err == nil { |
| 103 | mod.Session.Interface.HW = mac |
| 104 | } else { |
| 105 | mod.Warning("%v: %s", err, out) |
| 106 | } |
| 107 | |
| 108 | return err |
| 109 | } |
| 110 | |
| 111 | func (mod *MacChanger) Start() error { |
| 112 | if mod.Running() { |