Skip to content

Commit

Permalink
Merge pull request #994 from DimaGolomozy/fix-promisc-mode
Browse files Browse the repository at this point in the history
if its promiscuous mode, no need to filter on host as we want to capture traffic not related to this host
  • Loading branch information
buger committed Aug 16, 2021
2 parents 42d8990 + b50ea90 commit 4d82e2f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions capture/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
}

Expand Down

0 comments on commit 4d82e2f

Please sign in to comment.