mirror of
https://github.com/bettercap/bettercap
synced 2025-07-15 09:33:40 -07:00
fix: normalize mac address before parsing it (ref #10)
This commit is contained in:
parent
417a288b42
commit
b331ca81a2
1 changed files with 12 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/evilsocket/bettercap-ng/core"
|
"github.com/evilsocket/bettercap-ng/core"
|
||||||
|
@ -34,8 +35,19 @@ func ip2int(ip net.IP) uint32 {
|
||||||
return binary.BigEndian.Uint32(ip)
|
return binary.BigEndian.Uint32(ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func normalizeMac(mac string) string {
|
||||||
|
parts := strings.Split(mac, ":")
|
||||||
|
for i, p := range parts {
|
||||||
|
if len(p) < 2 {
|
||||||
|
parts[i] = "0" + p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return strings.Join(parts, ":")
|
||||||
|
}
|
||||||
|
|
||||||
func NewEndpointNoResolve(ip, mac, name string, bits uint32) *Endpoint {
|
func NewEndpointNoResolve(ip, mac, name string, bits uint32) *Endpoint {
|
||||||
addr := net.ParseIP(ip)
|
addr := net.ParseIP(ip)
|
||||||
|
mac = normalizeMac(mac)
|
||||||
hw, _ := net.ParseMAC(mac)
|
hw, _ := net.ParseMAC(mac)
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue