fix: when net.sniff is sniffing a mDNS hostname, it'll update the endpoint field

This commit is contained in:
evilsocket 2019-04-04 10:01:49 +02:00
commit 1f37381fde
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
2 changed files with 11 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import (
"strings"
"github.com/bettercap/bettercap/packets"
"github.com/bettercap/bettercap/session"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
@ -44,6 +45,14 @@ func mdnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
}
for hostname, ips := range m {
for _, ip := range ips {
if endpoint := session.I.Lan.GetByIp(ip); endpoint != nil {
endpoint.OnMeta(map[string]string{
"mdns:hostname": hostname,
})
}
}
NewSnifferEvent(
pkt.Metadata().Timestamp,
"mdns",