Skip to content

Commit

Permalink
Merge pull request projectdiscovery#208 from projectdiscovery/126-bug…
Browse files Browse the repository at this point in the history
…fix-nmap-cli

Skipping nmap if no open ports were found
  • Loading branch information
ehsandeep authored Sep 7, 2021
2 parents d4e80e1 + e2433f2 commit 6016ab9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion v2/pkg/runner/nmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ func (r *Runner) handleNmap() {
ports = append(ports, fmt.Sprintf("%d", p))
}

// if we have no open ports we avoid running nmap
if len(ports) == 0 {
gologger.Info().Msgf("Skipping nmap scan as no open ports were found")
return
}

portsStr := strings.Join(ports, ",")
ipsStr := strings.Join(ips, ",")

Expand All @@ -48,7 +54,7 @@ func (r *Runner) handleNmap() {
cmd.Stdout = os.Stdout
err := cmd.Run()
if err != nil {
gologger.Error().Msgf("Could not get network interfaces: %s\n", err)
gologger.Error().Msgf("Could not run nmap command: %s\n", err)
return
}
} else {
Expand Down

0 comments on commit 6016ab9

Please sign in to comment.