mirror of
https://github.com/bettercap/bettercap
synced 2025-08-21 05:53:20 -07:00
fix: better dns logging
This commit is contained in:
parent
63f389643d
commit
5bc00fb126
1 changed files with 16 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
|||
package modules
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/evilsocket/bettercap-ng/core"
|
||||
|
||||
"github.com/google/gopacket"
|
||||
|
@ -17,17 +19,29 @@ func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
m := make(map[string][]string, 0)
|
||||
for _, a := range dns.Answers {
|
||||
if a.IP == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
hostname := string(a.Name)
|
||||
if _, found := m[hostname]; found == false {
|
||||
m[hostname] = make([]string, 0)
|
||||
}
|
||||
|
||||
m[hostname] = append(m[hostname], vIP(a.IP))
|
||||
}
|
||||
|
||||
for hostname, ips := range m {
|
||||
SniffPrinter("[%s] %s %s > %s : %s is %s\n",
|
||||
vTime(pkt.Metadata().Timestamp),
|
||||
core.W(core.BG_DGRAY+core.FG_WHITE, "dns"),
|
||||
vIP(ip.SrcIP),
|
||||
vIP(ip.DstIP),
|
||||
core.Yellow(string(a.Name)),
|
||||
vIP(a.IP))
|
||||
core.Yellow(hostname),
|
||||
core.Dim(strings.Join(ips, ", ")),
|
||||
)
|
||||
}
|
||||
|
||||
return true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue