mirror of
https://github.com/bettercap/bettercap
synced 2025-07-12 16:13:48 -07:00
refact: got rid of go-bindata using a simple py script (fixes #51)
This commit is contained in:
parent
48d27f274a
commit
fd28eadc60
6 changed files with 22980 additions and 273 deletions
3
Makefile
3
Makefile
|
@ -13,7 +13,7 @@ build: resources
|
|||
resources: oui
|
||||
|
||||
oui:
|
||||
@$(GOPATH)/bin/go-bindata -o network/oui_compiled.go -pkg network network/oui.dat
|
||||
@./network/make_oui.py
|
||||
|
||||
vet:
|
||||
@go vet ./...
|
||||
|
@ -25,7 +25,6 @@ lint:
|
|||
@golint ./...
|
||||
|
||||
deps:
|
||||
@go get -u github.com/jteeuwen/go-bindata/...
|
||||
@go get ./...
|
||||
|
||||
clean:
|
||||
|
|
36
network/make_oui.py
Executable file
36
network/make_oui.py
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/python
|
||||
import os
|
||||
|
||||
base = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
with open(os.path.join(base, 'oui.go.template')) as fp:
|
||||
template = fp.read()
|
||||
|
||||
with open(os.path.join(base, 'oui.dat')) as fp:
|
||||
lines = [l.strip() for l in fp.readlines()]
|
||||
|
||||
m = {}
|
||||
for line in lines:
|
||||
if line == "" or line[0] == '#':
|
||||
continue
|
||||
|
||||
parts = line.split(' ', 1)
|
||||
if len(parts) != 2:
|
||||
continue
|
||||
|
||||
prefix = parts[0].strip().lower()
|
||||
vendor = parts[1].strip()
|
||||
|
||||
m[prefix] = vendor
|
||||
|
||||
code = "map[string]string {\n"
|
||||
|
||||
for prefix, vendor in m.iteritems():
|
||||
code += " \"%s\": \"%s\",\n" % ( prefix, vendor )
|
||||
|
||||
code += "}\n"
|
||||
|
||||
code = template.replace('#MAP#', code)
|
||||
|
||||
with open(os.path.join(base, 'oui.go'), 'w+t') as fp:
|
||||
fp.write(code)
|
22955
network/oui.go
22955
network/oui.go
File diff suppressed because it is too large
Load diff
18
network/oui.go.template
Normal file
18
network/oui.go.template
Normal file
|
@ -0,0 +1,18 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var oui = #MAP#
|
||||
|
||||
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 ""
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -306,8 +306,6 @@ func (s *Session) Start() error {
|
|||
return s.Modules[i].Name() < s.Modules[j].Name()
|
||||
})
|
||||
|
||||
network.OuiInit()
|
||||
|
||||
if s.Interface, err = network.FindInterface(*s.Options.InterfaceName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue