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
|
package modules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/evilsocket/bettercap-ng/core"
|
"github.com/evilsocket/bettercap-ng/core"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
|
@ -17,17 +19,29 @@ func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m := make(map[string][]string, 0)
|
||||||
for _, a := range dns.Answers {
|
for _, a := range dns.Answers {
|
||||||
if a.IP == nil {
|
if a.IP == nil {
|
||||||
continue
|
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",
|
SniffPrinter("[%s] %s %s > %s : %s is %s\n",
|
||||||
vTime(pkt.Metadata().Timestamp),
|
vTime(pkt.Metadata().Timestamp),
|
||||||
core.W(core.BG_DGRAY+core.FG_WHITE, "dns"),
|
core.W(core.BG_DGRAY+core.FG_WHITE, "dns"),
|
||||||
vIP(ip.SrcIP),
|
vIP(ip.SrcIP),
|
||||||
vIP(ip.DstIP),
|
vIP(ip.DstIP),
|
||||||
core.Yellow(string(a.Name)),
|
core.Yellow(hostname),
|
||||||
vIP(a.IP))
|
core.Dim(strings.Join(ips, ", ")),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue