mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
new: centralized logging and implemented DELETE /api/events route, closes #5
This commit is contained in:
parent
269d7d845b
commit
f1f146d3d7
21 changed files with 144 additions and 184 deletions
|
@ -6,15 +6,12 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/op/go-logging"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
)
|
||||
|
||||
type ArpTable map[string]string
|
||||
|
||||
var (
|
||||
log = logging.MustGetLogger("mitm")
|
||||
arp_parsed = false
|
||||
arp_lock = &sync.Mutex{}
|
||||
arp_table = make(ArpTable)
|
||||
|
|
|
@ -50,7 +50,6 @@ func NewEndpoint(ip, mac string) *Endpoint {
|
|||
if names, err := net.LookupAddr(e.IpAddress); err == nil {
|
||||
e.Hostname = names[0]
|
||||
if e.ResolvedCallback != nil {
|
||||
// log.Debugf("Endpoint %s is now known as %s\n", e.IpAddress, core.Green(e.Hostname))
|
||||
e.ResolvedCallback(e)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,18 +76,15 @@ func FindGateway(iface *Endpoint) (*Endpoint, error) {
|
|||
|
||||
if ifname == iface.Name() && flags == "UG" {
|
||||
gateway := m[2]
|
||||
// log.Debugf("Gateway ip is %s", gateway)
|
||||
if gateway == iface.IpAddress {
|
||||
// log.Debug("Gateway == Interface")
|
||||
return iface, nil
|
||||
} else {
|
||||
// we have the address, now we need its mac
|
||||
mac, err := ArpLookup(iface.Name(), gateway, false)
|
||||
if err == nil {
|
||||
// log.Debugf("Gateway mac is %s", mac)
|
||||
return NewEndpoint(gateway, mac), nil
|
||||
} else {
|
||||
log.Error(err)
|
||||
fmt.Printf("%s\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
10
net/oui.go
10
net/oui.go
|
@ -17,7 +17,7 @@ func OuiInit() {
|
|||
data := string(bytes)
|
||||
lines := strings.Split(data, "\n")
|
||||
|
||||
for lineno, line := range lines {
|
||||
for _, line := range lines {
|
||||
line = strings.Trim(line, " \n\r\t")
|
||||
if len(line) == 0 || line[0] == '#' {
|
||||
continue
|
||||
|
@ -25,7 +25,6 @@ func OuiInit() {
|
|||
|
||||
parts := strings.SplitN(line, " ", 2)
|
||||
if len(parts) != 2 {
|
||||
log.Warningf("Skipping line %d '%s'\n", lineno+1, line)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -34,8 +33,6 @@ func OuiInit() {
|
|||
|
||||
oui[prefix] = vendor
|
||||
}
|
||||
|
||||
log.Debugf("Loaded %d vendors signatures.\n", len(oui))
|
||||
}
|
||||
|
||||
func OuiLookup(mac string) string {
|
||||
|
@ -46,9 +43,6 @@ func OuiLookup(mac string) string {
|
|||
if vendor, found := oui[prefix]; found == true {
|
||||
return vendor
|
||||
}
|
||||
} else {
|
||||
log.Warningf("Unexpected mac '%s' in net.OuiLookup\n", mac)
|
||||
}
|
||||
|
||||
return "???"
|
||||
return ""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue