From b50ea90cdbb8c6893f9a6012484bc8b378bfb33e Mon Sep 17 00:00:00 2001 From: dimagolomozy Date: Mon, 16 Aug 2021 18:21:32 +0300 Subject: [PATCH] if its promiscuous mode, no need to filter on host as we want to capture traffic not related to host --- capture/capture.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/capture/capture.go b/capture/capture.go index c9dfec84b..c26087aea 100644 --- a/capture/capture.go +++ b/capture/capture.go @@ -218,7 +218,7 @@ func (l *Listener) Filter(ifi pcap.Interface) (filter string) { filter = portsFilter(l.Transport, "dst", l.ports) - if len(hosts) != 0 { + if len(hosts) != 0 && !l.Promiscuous { filter = fmt.Sprintf("((%s) and (%s))", filter, hostsFilter("dst", hosts)) } else { filter = fmt.Sprintf("(%s)", filter) @@ -227,7 +227,7 @@ func (l *Listener) Filter(ifi pcap.Interface) (filter string) { if l.trackResponse { responseFilter := portsFilter(l.Transport, "src", l.ports) - if len(hosts) != 0 { + if len(hosts) != 0 && !l.Promiscuous { responseFilter = fmt.Sprintf("((%s) and (%s))", responseFilter, hostsFilter("src", hosts)) } else { responseFilter = fmt.Sprintf("(%s)", responseFilter) @@ -236,8 +236,6 @@ func (l *Listener) Filter(ifi pcap.Interface) (filter string) { filter = fmt.Sprintf("%s or %s", filter, responseFilter) } - // filter = fmt.Sprintf("((((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)) and (%s)", filter) - return }