Package org.nmap4j.core.scans
Class BaseScan
java.lang.Object
org.nmap4j.core.scans.BaseScan
- All Implemented Interfaces:
IScan
- Direct Known Subclasses:
HostDiscovery,ServiceDiscovery
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.nmap4j.core.scans.IScan
IScan.OutputType, IScan.TimingFlag -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified flag to the underlying ArgumentProperties object.voidaddPort(int port) Adds a single port to the scan spec; adds the implied -p flag.voidaddPorts(int[] ports) Allows you to add ports in a block; this can also be called repetitively.voidexcludeHost(String host) Add a single host to the list of excluded hosts.voidexcludeHosts(String[] hosts) Add the array of hosts to the list of hosts that are excluded.voidExecute a scan asynchronously; you must pass in a callback in order for this to work.Executes a scan and blocks while scan runs.This provides access to the member variable for the ArgumentProperties.This provides access to the member variable for the NMapProperties.voidincludeHost(String host) Add a single host to the list of hosts.voidincludeHosts(String[] hosts) Add the the hosts from the array.voidremoveExcludeHost(String host) Remove one host from the list of excluded hosts.voidremoveExcludeHosts(String[] hosts) Remove the list of hosts from the list of hosts that should be excluded from a scan.voidremoveFlag(Flag flag) Removes the specified flag from the underlying ArgumentProperties object.voidremoveIncludeHost(String host) Removes the specified host from the list of included hosts.voidremoveIncludeHosts(String[] hosts) Removes all the hosts in the array from the list of included hosts.voidsetNMapPath(String path) Specifies the path in which to look for the nmap binaries and share directory.voidsetOutputType(IScan.OutputType ot, String fName) Sets the output type flag accordingly and also sets the filename.voidAllows for a controlled way to vet a scan configuration.voidSets the scan timing flag.
-
Field Details
-
argProps
-
nmapProps
-
-
Constructor Details
-
BaseScan
public BaseScan() -
BaseScan
-
-
Method Details
-
excludeHost
Description copied from interface:IScanAdd a single host to the list of excluded hosts. Additive.- Specified by:
excludeHostin interfaceIScan
-
excludeHosts
Description copied from interface:IScanAdd the array of hosts to the list of hosts that are excluded. Additive.- Specified by:
excludeHostsin interfaceIScan
-
includeHost
Description copied from interface:IScanAdd a single host to the list of hosts. Additive.- Specified by:
includeHostin interfaceIScan
-
includeHosts
Description copied from interface:IScanAdd the the hosts from the array. Additive.- Specified by:
includeHostsin interfaceIScan
-
addPort
public void addPort(int port) Description copied from interface:IScanAdds a single port to the scan spec; adds the implied -p flag. You can call this method repetitively to add ports. -
addPorts
public void addPorts(int[] ports) Description copied from interface:IScanAllows you to add ports in a block; this can also be called repetitively. -
executeAsynchronousScan
public void executeAsynchronousScan(IScanCallback isc) throws ParameterValidationFailureException, NMapExecutionException Description copied from interface:IScanExecute a scan asynchronously; you must pass in a callback in order for this to work.- Specified by:
executeAsynchronousScanin interfaceIScan- Throws:
ParameterValidationFailureExceptionNMapExecutionException
-
executeScan
public ExecutionResults executeScan() throws ParameterValidationFailureException, NMapExecutionException, NMapInitializationExceptionDescription copied from interface:IScanExecutes a scan and blocks while scan runs. If your scan is long running consider using the executeAsynchronousExecute() method.- Specified by:
executeScanin interfaceIScan- Returns:
- Throws:
NMapInitializationExceptionParameterValidationFailureExceptionNMapExecutionException
-
removeExcludeHost
Description copied from interface:IScanRemove one host from the list of excluded hosts.- Specified by:
removeExcludeHostin interfaceIScan
-
removeExcludeHosts
Description copied from interface:IScanRemove the list of hosts from the list of hosts that should be excluded from a scan.- Specified by:
removeExcludeHostsin interfaceIScan
-
removeIncludeHost
Description copied from interface:IScanRemoves the specified host from the list of included hosts.- Specified by:
removeIncludeHostin interfaceIScan
-
removeIncludeHosts
Description copied from interface:IScanRemoves 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:
removeIncludeHostsin interfaceIScan
-
setOutputType
Description copied from interface:IScanSets 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:
setOutputTypein interfaceIScan
-
setScanValidator
Description copied from interface:IScanAllows 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:
setScanValidatorin interfaceIScan
-
setTiming
Description copied from interface:IScanSets the scan timing flag. -
setNMapPath
Description copied from interface:IScanSpecifies 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:
setNMapPathin interfaceIScan
-
addFlag
Description copied from interface:IScanAdds the specified flag to the underlying ArgumentProperties object. -
removeFlag
Description copied from interface:IScanRemoves the specified flag from the underlying ArgumentProperties object.- Specified by:
removeFlagin interfaceIScan
-
getArgumentProperties
Description copied from interface:IScanThis provides access to the member variable for the ArgumentProperties.- Specified by:
getArgumentPropertiesin interfaceIScan- Returns:
-
getNMapProperties
Description copied from interface:IScanThis provides access to the member variable for the NMapProperties.- Specified by:
getNMapPropertiesin interfaceIScan- Returns:
-