Prerequisites section in the issue.mac.changer will fail to reset back to the old mac address if accidentally called twice ( maybe more? ).
sudo bettercap
bettercap v2.0.0 (type 'help' for a list of commands)
10.0.0.0/24 > 10.0.0.37 禄 mac.changer on
10.0.0.0/24 > 10.0.0.37 禄 [23:21:49] [sys.log] [inf] Interface mac address set to d1:59:38:f4:a1:f5
10.0.0.0/24 > 10.0.0.37 禄 mac.changer off
[23:21:52] [sys.log] [inf] Interface mac address restored to 98:7b:f3:1e:a0:5e
10.0.0.0/24 > 10.0.0.37 禄 mac.changer off
[23:21:55] [sys.log] [err] Module is not running.
10.0.0.0/24 > 10.0.0.37 禄 mac.changer on
[23:22:00] [sys.log] [inf] Interface mac address set to e6:e0:76:22:2f:b6
10.0.0.0/24 > 10.0.0.37 禄 mac.changer on
[23:22:03] [sys.log] [err] Module is already running.
10.0.0.0/24 > 10.0.0.37 禄 mac.changer off
[23:22:05] [sys.log] [inf] Interface mac address restored to e6:e0:76:22:2f:b6
10.0.0.0/24 > 10.0.0.37 禄 mac.changer off
[23:22:10] [sys.log] [err] Module is not runni
I turn on the mac.changer module for the first time:
mac.changer onmac.changer on againmac.changer offExpected behavior: I would expect the second mac.changer on to error out and not cause the subsequent mac.changer off to fail to reset the mac address properly.
Actual behavior: The mac address changed in the first on was _probably_ written to a variable or something, even in the event of the error. So when the module was turned off, the mac address wasn't able to restore properly.
I think I found the source of the bug?
So, whenever the module is ran, return mc.Start() will Configure() the MacChanger struct, effectively overwriting the "original mac" with whatever the current one is.
I'm working on a fix to this now / I'm sure @evilsocket or @Matrix86 could easily beat me to it. 馃檹
馃 This might not be perfect or anything -- but I think it'd basically solve the problem in a way without creating another function like isConfigured() or something -- which I did consider. But I think this is pretty simple. Maybe I need to sleep on it / open to whatever of course!
https://github.com/picatz/bettercap-ng/commit/69d5cc574f9947bb3b2b1408fe7613eb75e8bc76
Yay, congrats for the PR :D
Did a quick refactor :)