fix: fixes a bug which caused net.sniff not to print output if net.sniff.local is not true (fixes #138)

This commit is contained in:
evilsocket 2018-03-06 22:18:41 +01:00
commit 24310b5cad
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -1,7 +1,6 @@
package modules package modules
import ( import (
"bytes"
"fmt" "fmt"
"net" "net"
"time" "time"
@ -107,11 +106,10 @@ func same(a, b net.HardwareAddr) bool {
} }
func (s Sniffer) isLocalPacket(packet gopacket.Packet) bool { func (s Sniffer) isLocalPacket(packet gopacket.Packet) bool {
eth := packet.Layer(layers.LayerTypeEthernet) ipl := packet.Layer(layers.LayerTypeIPv4)
if eth != nil { if ipl != nil {
eth, _ := eth.(*layers.Ethernet) ip, _ := ipl.(*layers.IPv4)
ifHw := s.Session.Interface.HW if ip.SrcIP.Equal(s.Session.Interface.IP) || ip.DstIP.Equal(s.Session.Interface.IP) {
if bytes.Compare(eth.SrcMAC, ifHw) == 0 || bytes.Compare(eth.DstMAC, ifHw) == 0 {
return true return true
} }
} }