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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the specified flag to the underlying ArgumentProperties object.void
addPort
(int port) Adds a single port to the scan spec; adds the implied -p flag.void
addPorts
(int[] ports) Allows you to add ports in a block; this can also be called repetitively.void
excludeHost
(String host) Add a single host to the list of excluded hosts.void
excludeHosts
(String[] hosts) Add the array of hosts to the list of hosts that are excluded.void
Execute 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.void
includeHost
(String host) Add a single host to the list of hosts.void
includeHosts
(String[] hosts) Add the the hosts from the array.void
removeExcludeHost
(String host) Remove one host from the list of excluded hosts.void
removeExcludeHosts
(String[] hosts) Remove the list of hosts from the list of hosts that should be excluded from a scan.void
removeFlag
(Flag flag) Removes the specified flag from the underlying ArgumentProperties object.void
removeIncludeHost
(String host) Removes the specified host from the list of included hosts.void
removeIncludeHosts
(String[] hosts) Removes all the hosts in the array from the list of included hosts.void
setNMapPath
(String path) Specifies the path in which to look for the nmap binaries and share directory.void
setOutputType
(IScan.OutputType ot, String fName) Sets the output type flag accordingly and also sets the filename.void
Allows for a controlled way to vet a scan configuration.void
Sets the scan timing flag.
-
Field Details
-
argProps
-
nmapProps
-
-
Constructor Details
-
BaseScan
public BaseScan() -
BaseScan
-
-
Method Details
-
excludeHost
Description copied from interface:IScan
Add a single host to the list of excluded hosts. Additive.- Specified by:
excludeHost
in interfaceIScan
-
excludeHosts
Description copied from interface:IScan
Add the array of hosts to the list of hosts that are excluded. Additive.- Specified by:
excludeHosts
in interfaceIScan
-
includeHost
Description copied from interface:IScan
Add a single host to the list of hosts. Additive.- Specified by:
includeHost
in interfaceIScan
-
includeHosts
Description copied from interface:IScan
Add the the hosts from the array. Additive.- Specified by:
includeHosts
in interfaceIScan
-
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. -
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. -
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 interfaceIScan
- Throws:
ParameterValidationFailureException
NMapExecutionException
-
executeScan
public ExecutionResults executeScan() throws ParameterValidationFailureException, NMapExecutionException, NMapInitializationExceptionDescription 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 interfaceIScan
- Returns:
- Throws:
NMapInitializationException
ParameterValidationFailureException
NMapExecutionException
-
removeExcludeHost
Description copied from interface:IScan
Remove one host from the list of excluded hosts.- Specified by:
removeExcludeHost
in interfaceIScan
-
removeExcludeHosts
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 interfaceIScan
-
removeIncludeHost
Description copied from interface:IScan
Removes the specified host from the list of included hosts.- Specified by:
removeIncludeHost
in interfaceIScan
-
removeIncludeHosts
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 interfaceIScan
-
setOutputType
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 interfaceIScan
-
setScanValidator
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 interfaceIScan
-
setTiming
Description copied from interface:IScan
Sets the scan timing flag. -
setNMapPath
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 interfaceIScan
-
addFlag
Description copied from interface:IScan
Adds the specified flag to the underlying ArgumentProperties object. -
removeFlag
Description copied from interface:IScan
Removes the specified flag from the underlying ArgumentProperties object.- Specified by:
removeFlag
in interfaceIScan
-
getArgumentProperties
Description copied from interface:IScan
This provides access to the member variable for the ArgumentProperties.- Specified by:
getArgumentProperties
in interfaceIScan
- Returns:
-
getNMapProperties
Description copied from interface:IScan
This provides access to the member variable for the NMapProperties.- Specified by:
getNMapProperties
in interfaceIScan
- Returns:
-