mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
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:
parent
514370e1c2
commit
24310b5cad
1 changed files with 4 additions and 6 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue