Skip to content

Commit

Permalink
fix: do not add unhandled dns types to dns spoofing packets (closes #843
Browse files Browse the repository at this point in the history
)
  • Loading branch information
evilsocket committed Mar 23, 2021
1 parent d63122b commit 4f5f89b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions modules/dns_spoof/dns_spoof.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ func DnsReply(s *session.Session, TTL uint32, pkt gopacket.Packet, peth *layers.

answers := make([]layers.DNSResourceRecord, 0)
for _, q := range req.Questions {
// do not include types we can't handle and that are not needed
// for successful spoofing anyway
// ref: https://github.com/bettercap/bettercap/issues/843
if q.Type.String() == "Unknown" {
continue
}

answers = append(answers,
layers.DNSResourceRecord{
Name: []byte(q.Name),
Expand Down Expand Up @@ -231,7 +238,7 @@ func DnsReply(s *session.Session, TTL uint32, pkt gopacket.Packet, peth *layers.

err, raw = packets.Serialize(&eth, &ip6, &udp, &dns)
if err != nil {
log.Error("error serializing packet: %s.", err)
log.Error("error serializing ipv6 packet: %s.", err)
return "", ""
}
} else {
Expand All @@ -252,7 +259,7 @@ func DnsReply(s *session.Session, TTL uint32, pkt gopacket.Packet, peth *layers.

err, raw = packets.Serialize(&eth, &ip4, &udp, &dns)
if err != nil {
log.Error("error serializing packet: %s.", err)
log.Error("error serializing ipv4 packet: %s.", err)
return "", ""
}
}
Expand Down

0 comments on commit 4f5f89b

Please sign in to comment.