mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
fix: when net.sniff is sniffing a mDNS hostname, it'll update the endpoint field
This commit is contained in:
parent
126cb7febf
commit
1f37381fde
2 changed files with 11 additions and 0 deletions
|
@ -29,6 +29,8 @@ func NewSniffer(s *session.Session) *Sniffer {
|
||||||
Stats: nil,
|
Stats: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod.SessionModule.Requires("net.recon")
|
||||||
|
|
||||||
mod.AddParam(session.NewBoolParameter("net.sniff.verbose",
|
mod.AddParam(session.NewBoolParameter("net.sniff.verbose",
|
||||||
"false",
|
"false",
|
||||||
"If true, every captured and parsed packet will be sent to the events.stream for displaying, otherwise only the ones parsed at the application layer (sni, http, etc)."))
|
"If true, every captured and parsed packet will be sent to the events.stream for displaying, otherwise only the ones parsed at the application layer (sni, http, etc)."))
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
||||||
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"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 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(
|
NewSnifferEvent(
|
||||||
pkt.Metadata().Timestamp,
|
pkt.Metadata().Timestamp,
|
||||||
"mdns",
|
"mdns",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue