Class BaseScan

java.lang.Object
org.nmap4j.core.scans.BaseScan
All Implemented Interfaces:
IScan
Direct Known Subclasses:
HostDiscovery, ServiceDiscovery

public class BaseScan extends Object implements IScan
This is the base class for all convenience scan classes. The children of this class make it easy for users not familiar with NMap to create scans without having to understand very much about NMap.

The BaseScan object is the easiest way to build a custom scan specification. If you are familiar with NMap and want to have more control over how scans are executed, then this is the class to use.

See the Javadocs for IScan for details on each method.

  • Field Details

  • Constructor Details

    • BaseScan

      public BaseScan()
    • BaseScan

      public BaseScan(String nmapPath)
  • Method Details

    • excludeHost

      public void excludeHost(String host)
      Description copied from interface: IScan
      Add a single host to the list of excluded hosts. Additive.
      Specified by:
      excludeHost in interface IScan
    • excludeHosts

      public void excludeHosts(String[] hosts)
      Description copied from interface: IScan
      Add the array of hosts to the list of hosts that are excluded. Additive.
      Specified by:
      excludeHosts in interface IScan
    • includeHost

      public void includeHost(String host)
      Description copied from interface: IScan
      Add a single host to the list of hosts. Additive.
      Specified by:
      includeHost in interface IScan
    • includeHosts

      public void includeHosts(String[] hosts)
      Description copied from interface: IScan
      Add the the hosts from the array. Additive.
      Specified by:
      includeHosts in interface IScan
    • addPort

      public void addPort(int port)
      Description copied from interface: IScan
      Adds a single port to the scan spec; adds the implied -p flag. You can call this method repetitively to add ports.
      Specified by:
      addPort in interface IScan
    • addPorts

      public void addPorts(int[] ports)
      Description copied from interface: IScan
      Allows you to add ports in a block; this can also be called repetitively.
      Specified by:
      addPorts in interface IScan
    • executeAsynchronousScan

      public void executeAsynchronousScan(IScanCallback isc) throws ParameterValidationFailureException, NMapExecutionException
      Description copied from interface: IScan
      Execute a scan asynchronously; you must pass in a callback in order for this to work.
      Specified by:
      executeAsynchronousScan in interface IScan
      Throws:
      ParameterValidationFailureException
      NMapExecutionException
    • executeScan

      Description copied from interface: IScan
      Executes a scan and blocks while scan runs. If your scan is long running consider using the executeAsynchronousExecute() method.
      Specified by:
      executeScan in interface IScan
      Returns:
      Throws:
      NMapInitializationException
      ParameterValidationFailureException
      NMapExecutionException
    • removeExcludeHost

      public void removeExcludeHost(String host)
      Description copied from interface: IScan
      Remove one host from the list of excluded hosts.
      Specified by:
      removeExcludeHost in interface IScan
    • removeExcludeHosts

      public void removeExcludeHosts(String[] hosts)
      Description copied from interface: IScan
      Remove the list of hosts from the list of hosts that should be excluded from a scan.
      Specified by:
      removeExcludeHosts in interface IScan
    • removeIncludeHost

      public void removeIncludeHost(String host)
      Description copied from interface: IScan
      Removes the specified host from the list of included hosts.
      Specified by:
      removeIncludeHost in interface IScan
    • removeIncludeHosts

      public void removeIncludeHosts(String[] hosts)
      Description copied from interface: IScan
      Removes all the hosts in the array from the list of included hosts. Should not throw any exceptions if a host in the array is not in the current list.
      Specified by:
      removeIncludeHosts in interface IScan
    • setOutputType

      public void setOutputType(IScan.OutputType ot, String fName)
      Description copied from interface: IScan
      Sets the output type flag accordingly and also sets the filename. This method should be used to override the default behavior, writing XML to the std out.
      Specified by:
      setOutputType in interface IScan
    • setScanValidator

      public void setScanValidator(IScanValidator isv)
      Description copied from interface: IScan
      Allows for a controlled way to vet a scan configuration. Allows API users to verify the right combination of flags, the right values for things like ports or hosts (for example, allows users to prevent hosts from being scanned, etc).
      Specified by:
      setScanValidator in interface IScan
    • setTiming

      public void setTiming(IScan.TimingFlag tf)
      Description copied from interface: IScan
      Sets the scan timing flag.
      Specified by:
      setTiming in interface IScan
    • setNMapPath

      public void setNMapPath(String path)
      Description copied from interface: IScan
      Specifies the path in which to look for the nmap binaries and share directory. If this is not set, the API will try to use the environmental variable NMAP_HOME.
      Specified by:
      setNMapPath in interface IScan
    • addFlag

      public void addFlag(Flag flag)
      Description copied from interface: IScan
      Adds the specified flag to the underlying ArgumentProperties object.
      Specified by:
      addFlag in interface IScan
    • removeFlag

      public void removeFlag(Flag flag)
      Description copied from interface: IScan
      Removes the specified flag from the underlying ArgumentProperties object.
      Specified by:
      removeFlag in interface IScan
    • getArgumentProperties

      public ArgumentProperties getArgumentProperties()
      Description copied from interface: IScan
      This provides access to the member variable for the ArgumentProperties.
      Specified by:
      getArgumentProperties in interface IScan
      Returns:
    • getNMapProperties

      public NMapProperties getNMapProperties()
      Description copied from interface: IScan
      This provides access to the member variable for the NMapProperties.
      Specified by:
      getNMapProperties in interface IScan
      Returns: