mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
new: mac.changer module
This commit is contained in:
parent
c18f5541bd
commit
0b4c4a7dce
3 changed files with 124 additions and 0 deletions
|
@ -1,7 +1,9 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -82,6 +84,7 @@ func (p ModuleParam) Validate(value string) (error, interface{}) {
|
|||
|
||||
const ParamIfaceAddress = "<interface address>"
|
||||
const ParamSubnet = "<entire subnet>"
|
||||
const ParamRandomMAC = "<random mac>"
|
||||
|
||||
func (p ModuleParam) Get(s *Session) (error, interface{}) {
|
||||
var v string
|
||||
|
@ -97,6 +100,10 @@ func (p ModuleParam) Get(s *Session) (error, interface{}) {
|
|||
v = s.Interface.IpAddress
|
||||
} else if v == ParamSubnet {
|
||||
v = s.Interface.CIDR()
|
||||
} else if v == ParamRandomMAC {
|
||||
hw := make([]byte, 6)
|
||||
rand.Read(hw)
|
||||
v = net.HardwareAddr(hw).String()
|
||||
}
|
||||
|
||||
err, obj = p.Validate(v)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue