From 5e728ded2d3d06bcbba1fa2526f3896f15bd624b Mon Sep 17 00:00:00 2001 From: evilsocket Date: Thu, 25 Jan 2018 14:21:00 +0100 Subject: [PATCH] fix: check if both ethernet and udp layer are succesfully decoded before parsing dns request --- modules/dns_spoof.go | 5 +++-- net/oui_compiled.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/dns_spoof.go b/modules/dns_spoof.go index 4a14a9a8..394dd461 100644 --- a/modules/dns_spoof.go +++ b/modules/dns_spoof.go @@ -232,8 +232,9 @@ func (s *DNSSpoofer) onPacket(pkt gopacket.Packet) { eth := pkt.Layer(layers.LayerTypeEthernet).(*layers.Ethernet) udp := pkt.Layer(layers.LayerTypeUDP).(*layers.UDP) - // DNS request for us? - if s.All == true || bytes.Compare(eth.DstMAC, s.Session.Interface.HW) == 0 { + if eth == nil || udp == nil { + return + } else if s.All == true || 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 { for _, q := range dns.Questions { diff --git a/net/oui_compiled.go b/net/oui_compiled.go index f151b0a2..5f4beb1c 100644 --- a/net/oui_compiled.go +++ b/net/oui_compiled.go @@ -83,7 +83,7 @@ func netOuiDat() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "net/oui.dat", size: 585353, mode: os.FileMode(420), modTime: time.Unix(1516884015, 0)} + info := bindataFileInfo{name: "net/oui.dat", size: 585353, mode: os.FileMode(420), modTime: time.Unix(1515886539, 0)} a := &asset{bytes: bytes, info: info} return a, nil }