mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
refact: renamed package net to network to avoid collision with golang net package.
This commit is contained in:
parent
21236c257e
commit
48d27f274a
28 changed files with 298 additions and 298 deletions
50
network/oui.go
Normal file
50
network/oui.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
)
|
||||
|
||||
var (
|
||||
oui = make(map[string]string)
|
||||
)
|
||||
|
||||
func OuiInit() {
|
||||
bytes, err := Asset("network/oui.dat")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
data := string(bytes)
|
||||
lines := strings.Split(data, "\n")
|
||||
|
||||
for _, line := range lines {
|
||||
line = core.Trim(line)
|
||||
if len(line) == 0 || line[0] == '#' {
|
||||
continue
|
||||
}
|
||||
|
||||
parts := strings.SplitN(line, " ", 2)
|
||||
if len(parts) != 2 {
|
||||
continue
|
||||
}
|
||||
|
||||
prefix := strings.ToLower(core.Trim(parts[0]))
|
||||
vendor := core.Trim(parts[1])
|
||||
|
||||
oui[prefix] = vendor
|
||||
}
|
||||
}
|
||||
|
||||
func OuiLookup(mac string) string {
|
||||
octects := strings.Split(mac, ":")
|
||||
if len(octects) > 3 {
|
||||
prefix := octects[0] + octects[1] + octects[2]
|
||||
|
||||
if vendor, found := oui[prefix]; found == true {
|
||||
return vendor
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue