mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
fix: fixed a bug in DNS sniffer which prevented it to report all query responses
This commit is contained in:
parent
5eecd0bcce
commit
0d7eb43ee5
1 changed files with 24 additions and 11 deletions
|
@ -1,10 +1,9 @@
|
||||||
package modules
|
package modules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/evilsocket/islazy/tui"
|
"github.com/evilsocket/islazy/tui"
|
||||||
)
|
)
|
||||||
|
@ -20,7 +19,14 @@ func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
m := make(map[string][]string)
|
m := make(map[string][]string)
|
||||||
for _, a := range dns.Answers {
|
answers := [][]layers.DNSResourceRecord{
|
||||||
|
dns.Answers,
|
||||||
|
dns.Authorities,
|
||||||
|
dns.Additionals,
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, list := range answers {
|
||||||
|
for _, a := range list {
|
||||||
if a.IP == nil {
|
if a.IP == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -32,6 +38,13 @@ func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
|
|
||||||
m[hostname] = append(m[hostname], vIP(a.IP))
|
m[hostname] = append(m[hostname], vIP(a.IP))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(m) == 0 && dns.ResponseCode != layers.DNSResponseCodeNoErr {
|
||||||
|
for _, a := range dns.Questions {
|
||||||
|
m[string(a.Name)] = []string{tui.Red(dns.ResponseCode.String())}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for hostname, ips := range m {
|
for hostname, ips := range m {
|
||||||
NewSnifferEvent(
|
NewSnifferEvent(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue