mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
Use the MacChanger struct's originalMac field to determine if the module has already been configured
This goal of this commit is to provide a simple way to deal with the
original mac resotation issue I was facing where the MacChanger struct
was being overwritten if called twice/more than once. This should lock
up users from doing that but provide them a way around it ( not locking
them into an original mac address when I could want to change it
outside my bettercap session) with a consistent-ish experience until I
figure something else out. Or someone else does.
It’s also late and I need to be studying for my windows administration
class midterm.
It’s supposed to be an Advanced Windows Administration class. But it’s
not.
Anyways. I’m sure this commit isn’t perfect. But. What code is? 😂
This commit is contained in:
parent
f0e74685b2
commit
69d5cc574f
1 changed files with 8 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package modules
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"runtime"
|
||||
|
@ -64,6 +65,10 @@ func (mc *MacChanger) Author() string {
|
|||
func (mc *MacChanger) Configure() (err error) {
|
||||
var changeTo string
|
||||
|
||||
if mc.originalMac != nil {
|
||||
return errors.New("mac.changer has already been configured, you will need to turn it off to re-configure")
|
||||
}
|
||||
|
||||
if err, mc.iface = mc.StringParam("mac.changer.iface"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -119,6 +124,9 @@ func (mc *MacChanger) Stop() error {
|
|||
return err
|
||||
}
|
||||
|
||||
// the the module can now be reconfigured
|
||||
mc.originalMac = nil
|
||||
|
||||
return mc.SetRunning(false, func() {
|
||||
log.Info("Interface mac address restored to %s", core.Bold(mc.originalMac.String()))
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue