Class ServiceDiscovery

java.lang.Object
org.nmap4j.core.scans.BaseScan
org.nmap4j.core.scans.ServiceDiscovery
All Implemented Interfaces:
IScan

public class ServiceDiscovery extends BaseScan
A ServiceDiscovery instance is used to scan a host or hosts to list all the services the host is running, using NMap's default port specification. The default port scan specification is to scan the top 1000 ports based on NMap's own research of what are the most common open ports. You can override this by providing your own port specification or instead select to --top-ports (Flag.TOP_PORTS) or the --port-ratio (Flag.PORT_RATIO) settings.

This class is a convenience class that simplifies setting up a scan. The simplest way to scan a host or set of hosts is as follows:

String[] includedHosts = { "192.168.1.1-255" } ;
ServiceDiscovery serviceDiscovery = new ServiceDiscovery( includedHosts, null ) ;
ExecutionResults results = serviceDiscovery.execute();

This example is the simplest way to scan a set of hosts. NMap will let you specify a range of hosts either as noted above or as a space delimited list.

  • Constructor Details

    • ServiceDiscovery

      public ServiceDiscovery(String[] includeHosts, String[] excludeHosts)