mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
fix: normalizing dumb windows mac addresses (I HATE YOU MS)
This commit is contained in:
parent
d532163fd6
commit
52d7ccf3cd
2 changed files with 16 additions and 11 deletions
16
net/net.go
16
net/net.go
|
@ -49,6 +49,22 @@ func getInterfaceName(iface net.Interface) string {
|
|||
return iface.Name
|
||||
}
|
||||
|
||||
func NormalizeMac(mac string) string {
|
||||
var parts []string
|
||||
if strings.ContainsRune(mac, '-') {
|
||||
parts = strings.Split(mac, "-")
|
||||
} else {
|
||||
parts = strings.Split(mac, ":")
|
||||
}
|
||||
|
||||
for i, p := range parts {
|
||||
if len(p) < 2 {
|
||||
parts[i] = "0" + p
|
||||
}
|
||||
}
|
||||
return strings.Join(parts, ":")
|
||||
}
|
||||
|
||||
func FindInterface(name string) (*Endpoint, error) {
|
||||
ifaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue