Skip to content

Commit

Permalink
fix -exclude-ports for -passive (#1004)
Browse files Browse the repository at this point in the history
* fix `-exclude-ports` for `-passive`

* use excludePorts func

* building port struct

---------

Co-authored-by: mzack <marco.rivoli.nvh@gmail.com>
  • Loading branch information
dogancanbakir and Mzack9999 committed Mar 21, 2024
1 parent a0dad5c commit a0814ee
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions v2/pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,22 @@ func (r *Runner) RunEnumeration(pctx context.Context) error {
return
}

var passivePorts []*port.Port
for _, p := range data.Ports {
pp := &port.Port{Port: p, Protocol: protocol.TCP}
passivePorts = append(passivePorts, pp)
}

filteredPorts, err := excludePorts(r.options, passivePorts)
if err != nil {
gologger.Warning().Msgf("Couldn't exclude ports for %s: %s\n", ip, err)
return
}
for _, p := range filteredPorts {
if r.scanner.OnReceive != nil {
r.scanner.OnReceive(&result.HostResult{IP: ip, Ports: []*port.Port{pp}})
r.scanner.OnReceive(&result.HostResult{IP: ip, Ports: []*port.Port{p}})
}
r.scanner.ScanResults.AddPort(ip, pp)
r.scanner.ScanResults.AddPort(ip, p)
}
}(ip)
}
Expand Down

0 comments on commit a0814ee

Please sign in to comment.