mirror of
https://github.com/bettercap/bettercap
synced 2025-08-21 05:53:20 -07:00
new: updated mac vendor lookup with IEEE datasets
This commit is contained in:
parent
0dc5f66e27
commit
5858743b6e
9 changed files with 104569 additions and 84588 deletions
|
@ -1,28 +1,21 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
var manuf = #MAP#
|
||||
|
||||
func ManufLookup(mac string) string {
|
||||
macHex := strings.Replace(mac, ":", "", -1)
|
||||
macInt := new(big.Int)
|
||||
macHex := strings.ToUpper(strings.Replace(mac, ":", "", -1))
|
||||
macLen := len(macHex)
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
for offset := macLen; offset >= 2; offset -= 2 {
|
||||
part := macHex[0:offset]
|
||||
if vendor, found := manuf[part]; found {
|
||||
return vendor
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue