verinec.importer.analysis.scanner
Class HostScanWorker

java.lang.Object
  extended by java.lang.Thread
      extended by verinec.importer.analysis.AAnalyserTask
          extended by verinec.importer.analysis.scanner.HostScanWorker
All Implemented Interfaces:
Runnable

public class HostScanWorker
extends AAnalyserTask

This thread scans all the ports of a specified host using nmap. Nmap is told to dump scan result into a file in java.io.tmpdir The file is then parsed??? todo: test whether portscanning works correctly It requires the nmap executable in folder (from current working directory) bin/nmap/nmap.exe on windows resp. bin/nmap.bin for Linux on linux.

Author:
david.buchmann at unifr.ch, patrick.aebischer at unifr.ch, martial.seifriz at unifr.ch

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
(package private)  HostCommRenderer hostRenderer
          Host Identifier of the host to scan, container for results.
private  boolean interrupted
          Whether the worker should stop.
protected static String LOGFILE_PREFIX
          Prefix for the log file name.
protected  Logger logger
          For logging.
protected static String NMAP_LINUX
          nmap.bin
protected static File NMAP_PATH
          Path where nmap is installed.
protected static String NMAP_WINDOWS
          nmap.exe
protected  ProgramExec nmapCall
          To execute nmap.
protected  int os
          Operating system to use.
protected static String PARAMETERS
          The parameters for nmap
protected  StartScan startScan
          The scanner to get hosts from.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
HostScanWorker(int os, HostCommRenderer hr)
          Prepare the worker for a single scan.
HostScanWorker(StartScan scan, int os)
          Create the worker thread to scan hosts using nmap.
 
Method Summary
 void abortOperation()
          Abort scanning as soon as possible.
 void run()
          Start to scan the ports of hosts.
 void scan(HostCommRenderer hostRenderer)
          This method will parse the file created by nmap and fill the information into the hostRenderer.
 
Methods inherited from class verinec.importer.analysis.AAnalyserTask
getStarter, printMessage, setStarter
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NMAP_PATH

protected static final File NMAP_PATH
Path where nmap is installed. fixme: hard coded path Importer/bin/nmap, at least relative to verinec installation


NMAP_WINDOWS

protected static final String NMAP_WINDOWS
nmap.exe

See Also:
Constant Field Values

NMAP_LINUX

protected static final String NMAP_LINUX
nmap.bin

See Also:
Constant Field Values

PARAMETERS

protected static final String PARAMETERS
The parameters for nmap

See Also:
Constant Field Values

LOGFILE_PREFIX

protected static final String LOGFILE_PREFIX
Prefix for the log file name.

See Also:
Constant Field Values

os

protected int os
Operating system to use.


nmapCall

protected ProgramExec nmapCall
To execute nmap.


logger

protected Logger logger
For logging.


startScan

protected StartScan startScan
The scanner to get hosts from.


hostRenderer

HostCommRenderer hostRenderer
Host Identifier of the host to scan, container for results. If this is not null, thread will just use that and exit. Otherwise it polls startScan.


interrupted

private boolean interrupted
Whether the worker should stop.

Constructor Detail

HostScanWorker

public HostScanWorker(StartScan scan,
                      int os)
Create the worker thread to scan hosts using nmap. When the thread is started, it polls the StartScan instance for hosts to scan. As we use nmap to scan the host, the operating system family also needs to be specified. The results of the scan are added to the HostCommRenderers.

Parameters:
scan - The containing class to retreive host names to scan.
os - Operating System, one of the constants defined in this class.

HostScanWorker

public HostScanWorker(int os,
                      HostCommRenderer hr)
Prepare the worker for a single scan.

Parameters:
os - Operating System, one of the constants defined in this class.
hr - The information about the host to scan.
Method Detail

run

public void run()
Start to scan the ports of hosts.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

scan

public void scan(HostCommRenderer hostRenderer)
          throws VerinecException
This method will parse the file created by nmap and fill the information into the hostRenderer.

Parameters:
hostRenderer - The container for information about the host.
Throws:
VerinecException - if running nmap or interpreting the scan output fails

abortOperation

public void abortOperation()
Abort scanning as soon as possible.

Specified by:
abortOperation in class AAnalyserTask

Copyright © 2005 Verinec, DIUF