mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
fix: fixed a bug of the probe and recon algos which prevented targets from being removed once offline
This commit is contained in:
parent
fa2ada828b
commit
73f887087a
4 changed files with 12 additions and 32 deletions
|
@ -60,8 +60,6 @@ func (p *Prober) shouldProbe(ip net.IP) bool {
|
|||
return false
|
||||
} else if addr == p.Session.Gateway.IpAddress {
|
||||
return false
|
||||
} else if p.Session.Targets.Has(addr) == true {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -102,27 +102,21 @@ func (d *Discovery) checkShared(new net.ArpTable) {
|
|||
}
|
||||
|
||||
func (d *Discovery) runDiff() {
|
||||
var new net.ArpTable = make(net.ArpTable)
|
||||
// check for endpoints who disappeared
|
||||
var rem net.ArpTable = make(net.ArpTable)
|
||||
|
||||
if d.before != nil {
|
||||
new = net.ArpDiff(d.current, d.before)
|
||||
rem = net.ArpDiff(d.before, d.current)
|
||||
} else {
|
||||
new = d.current
|
||||
for mac, t := range d.Session.Targets.Targets {
|
||||
if _, found := d.current[mac]; found == false {
|
||||
rem[mac] = t.IpAddress
|
||||
}
|
||||
}
|
||||
|
||||
if len(new) > 0 || len(rem) > 0 {
|
||||
d.checkShared(new)
|
||||
for mac, ip := range rem {
|
||||
d.Session.Targets.Remove(ip, mac)
|
||||
}
|
||||
|
||||
// refresh target pool
|
||||
for ip, mac := range rem {
|
||||
d.Session.Targets.Remove(ip, mac)
|
||||
}
|
||||
|
||||
for ip, mac := range new {
|
||||
d.Session.Targets.AddIfNotExist(ip, mac)
|
||||
}
|
||||
// now check for new friends ^_^
|
||||
for ip, mac := range d.current {
|
||||
d.Session.Targets.AddIfNotExist(ip, mac)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
12
net/arp.go
12
net/arp.go
|
@ -13,18 +13,6 @@ var (
|
|||
arpTable = make(ArpTable)
|
||||
)
|
||||
|
||||
func ArpDiff(current, before ArpTable) ArpTable {
|
||||
diff := make(ArpTable)
|
||||
for ip, mac := range current {
|
||||
_, found := before[ip]
|
||||
if !found {
|
||||
diff[ip] = mac
|
||||
}
|
||||
}
|
||||
|
||||
return diff
|
||||
}
|
||||
|
||||
func ArpLookup(iface string, address string, refresh bool) (string, error) {
|
||||
// Refresh ARP table if first run or if a force refresh has been instructed.
|
||||
if ArpParsed() == false || refresh == true {
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/evilsocket/bettercap-ng/net"
|
||||
)
|
||||
|
||||
const TargetsDefaultTTL = 2
|
||||
const TargetsDefaultTTL = 10
|
||||
const TargetsAliasesFile = "~/bettercap.aliases"
|
||||
|
||||
type Targets struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue