com.securitycentric.metacoretex.lib
Class AbstractProbe

java.lang.Object
  extended bycom.securitycentric.metacoretex.lib.AbstractProbe
All Implemented Interfaces:
Probe, java.lang.Runnable
Direct Known Subclasses:
AbstractAuthProbe, AbstractCommandProbe, AbstractDatabaseProbe, AbstractVersionProbe

public abstract class AbstractProbe
extends java.lang.Object
implements Probe

This is the base abstract probe from which all probes are extended. This implementation takes care of almost all of the necissary data management functions so developers can focus on the probe code alone. To extend this probe, you may do as little as implement the probe() method, but be sure to set up all the necissary information when your class is instanciated!

Author:
visigoth

Field Summary
 java.lang.String copyright
          the copyright string for this probe
 java.util.Vector depVect
          Vector of KB keys (Strings) this probe depends on
 boolean enabled
          probes may be disabled by user input, store it in the probe.
 java.lang.String familyStr
          the name of the family for this probe which is used in GUI rendering
 java.lang.String helpStr
          the help String for this probe
 java.lang.String nameStr
          the human readable name of this probe
 java.util.Properties options
          The Properties object which holds user configurable options.
 ProbeException pException
          an exception to throw if things go bad.
 int probeId
          this probe's ID
 java.util.Hashtable provHash
          key->value pairs of kbentry->description
 boolean reportable
          does this probe have anything to report?
 java.lang.String repStr
          The Report string
 boolean safe
          keep track of weather or not this probe is safe.
 int severity
          this probes current severity
 Target target
          The target which this probe will poke.
 int timeout
          this probes timeout in miliseconds (setting to 42666 uses global default)
 java.lang.String unspec
          a string to use for junk that developers didn't initialize.
 Version version
          the Version object for the version of this probe
 
Constructor Summary
AbstractProbe()
           
 
Method Summary
 void addDepends(java.lang.String name)
          Add the key to the list of KB objects which this probe uses (KB objects provided by other probes).
 void addOption(java.lang.String opt, java.lang.String value)
          Add a user-configurable option with a default value.
 void addProvides(java.lang.String name, java.lang.String descr)
          Add a KB key to the list of keys provided by this probe.
 void addReport(java.lang.String reptAddStr)
          Add the specified string and a newline to the report.
 java.util.Vector depends()
          Return a vector of the KB keys this probe requires to run.
 java.util.Properties dumpOptions()
          This method provides the probe handling subsystems with a way to get a reference to the Properties objec which stores the configuration options for this probe.
 java.lang.String getCopyright()
          Get the copyright string for this probe.
 ProbeException getException()
          Return a copy of a ProbeException which may have occured during the course of the probe() method.
 java.lang.String getFamily()
          Get the String name of the family of probes to which this probe belongs.
 java.lang.String getHelp()
          Get a reference to the help string for the current probe.
 java.lang.String getHost()
          Get the name/ip for the current Target as a String.
 java.lang.String getName()
          Get the human readable name for this probe
 java.lang.String getOption(java.lang.String opt)
          Get the String representing the user configured option.
 java.util.Vector getOptionKeys()
          Return a vector of all the option KEYS
 int getProbeId()
          Get the ID of this probe.
 java.lang.String getReport()
          Get the String of the report for the probe.
 int getSeverity()
          Get the integer value for the severity of this probe: 0 - Data Gathering - Could be good or bad, Requires analysis 1 - Low Risk 2 - Medium Risk 3 - High Risk
 Target getTarget()
          Get a reference to the Target object for this probe.
 int getTimeout()
          Get the timeout in milliseconds that this probe should use when running.
 java.lang.String getVersion()
          Get a String representation of the version of this probe
 boolean hasSafe()
          Find out if this probe has a "safe" attack or not
 boolean isEnabled()
          Checks to see if this probe is currently enabled (will fire on launch)
 boolean isReportable()
          Test weather or not this probe has anything to report.
 java.lang.Object kbGet(java.lang.String key)
          Get the Object referenced at the specified KB key
 boolean kbHas(java.lang.String key)
          Test to see if the KB contains the specified key.
 void kbPut(java.lang.String key, java.lang.Object obj)
          Put an Object into the Target's KB for later use by other probes.
 void probeSafe()
          This method represents the "safe" option for the probe.
 java.util.Hashtable provides()
          Return a Hashtable of the KB keys this probe provides sets and their descriptions.
 void replaceOptions(java.util.Properties prop)
          This method is used by the scan configuration loader to override the default configuration options for the probe.
 void run()
          implement the runnable interface for threading junk
 void setCopyright(java.lang.String copyright)
          Set the copyright information for this probe.
 void setEnabled(boolean bol)
          Set the enabled flag on this probe.
 void setFamily(java.lang.String newFam)
          Use the setFamily() method to set the family (more importantly the tab in the UI) for this probe.
 void setHelp(java.lang.String help)
          Set the String value returened by the getHelp() method (used by the UI)
 void setName(java.lang.String myname)
          REQUIRED: Set the human readable name for this probe.
 void setProbeId(int x)
          Set the ID of this probe.
 void setReport(java.lang.String newRpt)
          Set the report String for this probe.
 void setReportable(boolean x)
          Set the reportable status of this report.
 void setSeverity(int x)
          Set the severity rating for this probe's report.
 void setTarget(Target targ)
          Set the Target this probe will attack on invocation of the probe() method.
 void setTimeout(int timeout)
          Set the timeout in milliseconds that this probe should use when running.
 void setVersion(java.lang.String ver)
          Set the version string for this probe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.securitycentric.metacoretex.interfaces.Probe
probe
 

Field Detail

probeId

public int probeId
this probe's ID


severity

public int severity
this probes current severity


timeout

public int timeout
this probes timeout in miliseconds (setting to 42666 uses global default)


options

public java.util.Properties options
The Properties object which holds user configurable options.


target

public Target target
The target which this probe will poke.


pException

public ProbeException pException
an exception to throw if things go bad.


repStr

public java.lang.String repStr
The Report string


nameStr

public java.lang.String nameStr
the human readable name of this probe


version

public Version version
the Version object for the version of this probe


unspec

public java.lang.String unspec
a string to use for junk that developers didn't initialize.


copyright

public java.lang.String copyright
the copyright string for this probe


helpStr

public java.lang.String helpStr
the help String for this probe


enabled

public boolean enabled
probes may be disabled by user input, store it in the probe.


safe

public boolean safe
keep track of weather or not this probe is safe.


reportable

public boolean reportable
does this probe have anything to report?


depVect

public java.util.Vector depVect
Vector of KB keys (Strings) this probe depends on


provHash

public java.util.Hashtable provHash
key->value pairs of kbentry->description


familyStr

public java.lang.String familyStr
the name of the family for this probe which is used in GUI rendering

Constructor Detail

AbstractProbe

public AbstractProbe()
Method Detail

run

public void run()
implement the runnable interface for threading junk

Specified by:
run in interface java.lang.Runnable

getProbeId

public int getProbeId()
Get the ID of this probe.

Specified by:
getProbeId in interface Probe
Returns:
int the probe's ID

setProbeId

public void setProbeId(int x)
Set the ID of this probe. Probe ID's should be unique, as the loader will overwrite instances of probes with the same IDs.

Specified by:
setProbeId in interface Probe
Parameters:
x - int ID to set for this probe.

getFamily

public java.lang.String getFamily()
Get the String name of the family of probes to which this probe belongs.

Specified by:
getFamily in interface Probe
Returns:
String family name

setFamily

public void setFamily(java.lang.String newFam)
Description copied from interface: Probe
Use the setFamily() method to set the family (more importantly the tab in the UI) for this probe. Family names are used for ONLY the GUI rendering..

Specified by:
setFamily in interface Probe
Parameters:
newFam - String name of the new probe family

getName

public java.lang.String getName()
Get the human readable name for this probe

Specified by:
getName in interface Probe
Returns:
String human readable name for this probe

setName

public void setName(java.lang.String myname)
REQUIRED: Set the human readable name for this probe.

Specified by:
setName in interface Probe
Parameters:
myname - String name for this probe.

hasSafe

public boolean hasSafe()
Find out if this probe has a "safe" attack or not

Specified by:
hasSafe in interface Probe
Returns:
boolean true if this probe has a "safe" probe option, false if not.

getReport

public java.lang.String getReport()
Get the String of the report for the probe.

Specified by:
getReport in interface Probe
Returns:
String the current reportable value for this probe.

setReport

public void setReport(java.lang.String newRpt)
Set the report String for this probe. This function will throw out all previously set information for this report string.

Specified by:
setReport in interface Probe
Parameters:
newRpt - String The new reportable value for this probe.

addReport

public void addReport(java.lang.String reptAddStr)
Add the specified string and a newline to the report.

Specified by:
addReport in interface Probe
Parameters:
reptAddStr - String to add to the report

getTarget

public Target getTarget()
Get a reference to the Target object for this probe.

Specified by:
getTarget in interface Probe
Returns:
Target this probe is assigned to.

setTarget

public void setTarget(Target targ)
Set the Target this probe will attack on invocation of the probe() method.

Specified by:
setTarget in interface Probe
Parameters:
targ - com.securitycentric.metacoretex.lib.Target This probe's target.

isEnabled

public boolean isEnabled()
Checks to see if this probe is currently enabled (will fire on launch)

Specified by:
isEnabled in interface Probe
Returns:
boolean true if enabled. false if not

setEnabled

public void setEnabled(boolean bol)
Set the enabled flag on this probe.

Specified by:
setEnabled in interface Probe
Parameters:
bol - boolean true for enabled, false for not

probeSafe

public void probeSafe()
               throws ProbeException
This method represents the "safe" option for the probe. For most probes, this method will just call probe() (if they are naturally safe probes)

Specified by:
probeSafe in interface Probe
Throws:
ProbeException - This exception is thrown if the probe is unable to process. ex. network outage. SQL failure etc.

depends

public java.util.Vector depends()
Description copied from interface: Probe
Return a vector of the KB keys this probe requires to run.

Specified by:
depends in interface Probe
Returns:
Vector of the KB keys this probe depends upon

provides

public java.util.Hashtable provides()
Description copied from interface: Probe
Return a Hashtable of the KB keys this probe provides sets and their descriptions. This is mostly used by the dependency resolver which orders the probe for firing

Specified by:
provides in interface Probe
Returns:
Hashtable of the KB's this probe provides

getOptionKeys

public java.util.Vector getOptionKeys()
Return a vector of all the option KEYS

Specified by:
getOptionKeys in interface Probe
Returns:
Vector of the keys (names) of the configuration options for this probe.

addProvides

public void addProvides(java.lang.String name,
                        java.lang.String descr)
Add a KB key to the list of keys provided by this probe.

Specified by:
addProvides in interface Probe
Parameters:
name - String Name for the KB key provided by this probe
descr - String Description of the Object (include type) which this probe puts in the KB.

addDepends

public void addDepends(java.lang.String name)
Add the key to the list of KB objects which this probe uses (KB objects provided by other probes).

Specified by:
addDepends in interface Probe
Parameters:
name - String The KB key which is used by this probe.

addOption

public void addOption(java.lang.String opt,
                      java.lang.String value)
Add a user-configurable option with a default value.

Specified by:
addOption in interface Probe
Parameters:
opt - String Name of the option
value - String Default value for this option

getOption

public java.lang.String getOption(java.lang.String opt)
Get the String representing the user configured option. Usually called by a probe at probe-time to get user input.

Specified by:
getOption in interface Probe
Parameters:
opt - String The option name specified in an earlier call to addOption()
Returns:
String The value specified by the user before launch

getVersion

public java.lang.String getVersion()
Get a String representation of the version of this probe

Specified by:
getVersion in interface Probe
Returns:
String The version of this probe.

setVersion

public void setVersion(java.lang.String ver)
Set the version string for this probe

Specified by:
setVersion in interface Probe
Parameters:
ver - String A version string like: "1.34.3_5" etc.

dumpOptions

public java.util.Properties dumpOptions()
Description copied from interface: Probe
This method provides the probe handling subsystems with a way to get a reference to the Properties objec which stores the configuration options for this probe.

Specified by:
dumpOptions in interface Probe
Returns:
Properties object of the configuration options for this probe

replaceOptions

public void replaceOptions(java.util.Properties prop)
Description copied from interface: Probe
This method is used by the scan configuration loader to override the default configuration options for the probe.

Specified by:
replaceOptions in interface Probe
Parameters:
prop - New Properties object for this probe to use.

kbPut

public void kbPut(java.lang.String key,
                  java.lang.Object obj)
Put an Object into the Target's KB for later use by other probes.

Specified by:
kbPut in interface Probe
Parameters:
key - String The key for the KB object. Usually this is the same as the key specified in a call to addProvides() during instantiation.
obj - Object The Object in insert into the KB. Can be anything you want.

kbGet

public java.lang.Object kbGet(java.lang.String key)
Get the Object referenced at the specified KB key

Specified by:
kbGet in interface Probe
Parameters:
key - String The key which identifies the Object in the KB
Returns:
Object The Object at that key in the KB

kbHas

public boolean kbHas(java.lang.String key)
Test to see if the KB contains the specified key. Usefull for checking if your probe's dependancies have been met, and avoiding calls to check if your kbGet() call returned null.

Specified by:
kbHas in interface Probe
Parameters:
key - String The key to test for in the KB
Returns:
boolean true if the KB has the key, false if not

getHost

public java.lang.String getHost()
Get the name/ip for the current Target as a String. Used by probe's to get the target host for poking.

Specified by:
getHost in interface Probe
Returns:
String The name or string IP of the Target this probe is assigned.

getSeverity

public int getSeverity()
Get the integer value for the severity of this probe: 0 - Data Gathering - Could be good or bad, Requires analysis 1 - Low Risk 2 - Medium Risk 3 - High Risk

Specified by:
getSeverity in interface Probe
Returns:
int The sevrity of this probe.

setSeverity

public void setSeverity(int x)
Set the severity rating for this probe's report. This may be called during the probe() method, to set the severity based on results received.

Specified by:
setSeverity in interface Probe
Parameters:
x - int The severity

isReportable

public boolean isReportable()
Test weather or not this probe has anything to report.

Specified by:
isReportable in interface Probe
Returns:
boolean Does this probe have a report?

setReportable

public void setReportable(boolean x)
Set the reportable status of this report. Probes should call this with a true value once they are reasonably certain they have information to report.

Specified by:
setReportable in interface Probe
Parameters:
x - boolean

getException

public ProbeException getException()
Return a copy of a ProbeException which may have occured during the course of the probe() method. Used by the attacker threads, and likely internal.

Specified by:
getException in interface Probe

getHelp

public java.lang.String getHelp()
Get a reference to the help string for the current probe.

Specified by:
getHelp in interface Probe
Returns:
String The help string for this probe.

setCopyright

public void setCopyright(java.lang.String copyright)
Set the copyright information for this probe. Used to display information in Help->about probes.

Specified by:
setCopyright in interface Probe
Parameters:
copyright - String The copyright info like : (c) 2003, visigoth blah blah blah

getCopyright

public java.lang.String getCopyright()
Get the copyright string for this probe.

Specified by:
getCopyright in interface Probe
Returns:
String copyright string

setHelp

public void setHelp(java.lang.String help)
Set the String value returened by the getHelp() method (used by the UI)

Specified by:
setHelp in interface Probe
Parameters:
help - String help/config information

getTimeout

public int getTimeout()
Description copied from interface: Probe
Get the timeout in milliseconds that this probe should use when running.

Specified by:
getTimeout in interface Probe

setTimeout

public void setTimeout(int timeout)
Description copied from interface: Probe
Set the timeout in milliseconds that this probe should use when running. Leave this value alone unless you know what you are doing!

Specified by:
setTimeout in interface Probe