From 90b720f1b68eaafbfeaf90dc07fddb4d02e675d5 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Thu, 8 Feb 2018 06:00:38 +0100 Subject: [PATCH] balls --- session/targets.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/session/targets.go b/session/targets.go index de7559fd..cff70a26 100644 --- a/session/targets.go +++ b/session/targets.go @@ -4,12 +4,13 @@ import ( "bufio" "fmt" "io/ioutil" + "net" "os" "strings" "sync" "github.com/evilsocket/bettercap-ng/core" - "github.com/evilsocket/bettercap-ng/net" + bnet "github.com/evilsocket/bettercap-ng/net" ) const TargetsDefaultTTL = 10 @@ -19,21 +20,21 @@ type Targets struct { sync.Mutex Session *Session `json:"-"` - Interface *net.Endpoint - Gateway *net.Endpoint - Targets map[string]*net.Endpoint + Interface *bnet.Endpoint + Gateway *bnet.Endpoint + Targets map[string]*bnet.Endpoint TTL map[string]uint Aliases map[string]string aliasesFileName string } -func NewTargets(s *Session, iface, gateway *net.Endpoint) *Targets { +func NewTargets(s *Session, iface, gateway *bnet.Endpoint) *Targets { t := &Targets{ Session: s, Interface: iface, Gateway: gateway, - Targets: make(map[string]*net.Endpoint), + Targets: make(map[string]*bnet.Endpoint), TTL: make(map[string]uint), Aliases: make(map[string]string), } @@ -48,11 +49,11 @@ func NewTargets(s *Session, iface, gateway *net.Endpoint) *Targets { return t } -func (tp *Targets) List() (list []*net.Endpoint) { +func (tp *Targets) List() (list []*bnet.Endpoint) { tp.Lock() defer tp.Unlock() - list = make([]*net.Endpoint, 0) + list = make([]*bnet.Endpoint, 0) for _, t := range tp.Targets { list = append(list, t) } @@ -137,7 +138,8 @@ func (tp *Targets) Remove(ip, mac string) { } func (tp *Targets) shouldIgnore(ip string) bool { - return (ip == tp.Interface.IpAddress || ip == tp.Gateway.IpAddress || ip == "255.255.255.255") + addr := net.ParseIP(ip) + return (ip == tp.Interface.IpAddress || ip == tp.Gateway.IpAddress || tp.Session.Interface.Net.Contains(addr) == false) } func (tp *Targets) Has(ip string) bool { @@ -153,7 +155,7 @@ func (tp *Targets) Has(ip string) bool { return false } -func (tp *Targets) AddIfNew(ip, mac string) *net.Endpoint { +func (tp *Targets) AddIfNew(ip, mac string) *bnet.Endpoint { tp.Lock() defer tp.Unlock() @@ -161,7 +163,7 @@ func (tp *Targets) AddIfNew(ip, mac string) *net.Endpoint { return nil } - mac = net.NormalizeMac(mac) + mac = bnet.NormalizeMac(mac) if t, found := tp.Targets[mac]; found { if tp.TTL[mac] < TargetsDefaultTTL { tp.TTL[mac]++ @@ -169,8 +171,8 @@ func (tp *Targets) AddIfNew(ip, mac string) *net.Endpoint { return t } - e := net.NewEndpoint(ip, mac) - e.ResolvedCallback = func(e *net.Endpoint) { + e := bnet.NewEndpoint(ip, mac) + e.ResolvedCallback = func(e *bnet.Endpoint) { tp.Session.Events.Add("endpoint.resolved", e) }