Class NMapProperties

java.lang.Object
org.nmap4j.core.nmap.NMapProperties

public class NMapProperties extends Object
This class is used to manage the path to nmap. This class attempts to look for the environmental variable NMAP_HOME. If that is not set it is expected that the user set this location via this class.

Essentially the path needs to be to the location where the "bin" dir that contains the nmap binary is. Usually, when dealing with most nmap installs, this will also be location where the "share" dir is located. It's ideal to identify both of these of dirs as this allows you to specify the right share dir for a binary. Otherwise there is a risk that nmap will pick up a default in the system and this may introduce inconsistencies.

If you are planning to use the system property NMAP_HOME to set your NMap path, use the no arg constructor. Otherwise use the constructor with the String. If you want flexibility, set the path, use the no arg constructor and then use the setPath(String) method.

  • Constructor Details

    • NMapProperties

      public NMapProperties()
      Constructs an instance of NMapProperties and looks in the environment properties for NMAP_HOME. If it is not found, the path is initialized to null and the API assumes that you will set it manually. See setPath().
    • NMapProperties

      public NMapProperties(String path)
      Contructs and instance of NMapProperties using the path passed.
      Parameters:
      path -
  • Method Details

    • getPath

      public String getPath()
      Returns the current path.
      Returns:
    • setPath

      public void setPath(String pathToBinDir)
      Sets the path the bin dir where nmap can be found. This is also the path to the share dir which contains important files for nmap.

      For example, if the nmap bin dir is in /usr/local/share/bin/nmap the path you would set into this method is /usr/local/share .

      Parameters:
      pathToBinDir - - /the/path/to/nmapbindir.
    • getBinDir

      public String getBinDir()
      Returns the expected location of the share dir relative to the path set or passed in at construction time. The value returned by this method is equivalent to that path variable + filesystem dependent separator + bin .
      Returns:
    • getShareDir

      public String getShareDir()
      Returns the expected location of the share dir relative to the path set or passed in at construction time. The value returned by this method is equivalent to the path variable + filesystem dependent separator + share.
      Returns:
    • getFullyFormattedCommand

      public String getFullyFormattedCommand()
      This returns the full path to the nmap version to be executed.
      Returns: