mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
28 lines
536 B
Text
28 lines
536 B
Text
package network
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"math/big"
|
|
)
|
|
|
|
var manuf = #MAP#
|
|
|
|
func ManufLookup(mac string) string {
|
|
macHex := strings.Replace(mac, ":", "", -1)
|
|
macInt := new(big.Int)
|
|
|
|
if _, ok := macInt.SetString(macHex, 16); ok == false {
|
|
return ""
|
|
}
|
|
|
|
for mask := uint(0); mask < 48; mask++ {
|
|
shifted := new(big.Int).Rsh(macInt, mask)
|
|
key := fmt.Sprintf("%d.%s", mask, shifted)
|
|
if vendor, found := manuf[key]; found {
|
|
return vendor
|
|
}
|
|
}
|
|
|
|
return ""
|
|
}
|