mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
check if nil before the interface conversion
This commit is contained in:
parent
ab9e86abd1
commit
b03b7c8b56
1 changed files with 10 additions and 6 deletions
|
@ -234,14 +234,18 @@ func (s *DNSSpoofer) shouldSpoof(domain string) bool {
|
|||
}
|
||||
|
||||
func (s *DNSSpoofer) onPacket(pkt gopacket.Packet) {
|
||||
eth := pkt.Layer(layers.LayerTypeEthernet).(*layers.Ethernet)
|
||||
udp := pkt.Layer(layers.LayerTypeUDP).(*layers.UDP)
|
||||
|
||||
if eth == nil || udp == nil {
|
||||
typeEth := pkt.Layer(layers.LayerTypeEthernet)
|
||||
typeUDP := pkt.Layer(layers.LayerTypeUDP)
|
||||
if typeEth == nil || typeUDP == nil {
|
||||
return
|
||||
} else if s.All == true || bytes.Compare(eth.DstMAC, s.Session.Interface.HW) == 0 {
|
||||
}
|
||||
|
||||
eth := typeEth.(*layers.Ethernet)
|
||||
|
||||
if s.All || bytes.Compare(eth.DstMAC, s.Session.Interface.HW) == 0 {
|
||||
dns, parsed := pkt.Layer(layers.LayerTypeDNS).(*layers.DNS)
|
||||
if parsed == true && dns.OpCode == layers.DNSOpCodeQuery && len(dns.Questions) > 0 && len(dns.Answers) == 0 {
|
||||
if parsed && dns.OpCode == layers.DNSOpCodeQuery && len(dns.Questions) > 0 && len(dns.Answers) == 0 {
|
||||
udp := typeUDP.(*layers.UDP)
|
||||
for _, q := range dns.Questions {
|
||||
qName := string(q.Name)
|
||||
if s.shouldSpoof(qName) == true {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue