utilities
index
/home/jim/Files/TekDefense/TekDefense-Automater-Private/utilities.py

The utilities.py module handles all utility functions that Automater
requires.
 
Class(es):
Parser -- Class to handle standard argparse functions with
a class-based structure.
IPWrapper -- Class to provide IP Address formatting and parsing.
 
Function(s):
No global exportable functions are defined.
 
Exception(s):
No exceptions exported.

 
Modules
       
argparse
os
re

 
Classes
       
__builtin__.object
IPWrapper
Parser

 
class IPWrapper(__builtin__.object)
    IPWrapper provides Class Methods to enable checks
against strings to determine if the string is an IP Address
or an IP Address in CIDR or dash notation.
 
Public Method(s):
(Class Method) isIPorIPList
(Class Method) getTarget
 
Instance variable(s):
No instance variables.
 
  Class methods defined here:
getTarget(self, target) from __builtin__.type
Determines whether the target provided is an IP Address or
an IP Address in CIDR or dash notation. Then creates a list
that can be utilized as targets by the program.
Returns a list of string IP Addresses that can be used as targets.
 
Argument(s):
target -- string target provided as the first argument to the program.
 
Return value(s):
Iterator of string(s) representing IP Addresses.
 
Restriction(s):
This Method is tagged as a Class Method
isIPorIPList(self, target) from __builtin__.type
Checks if an input string is an IP Address or if it is
an IP Address in CIDR or dash notation.
Returns True if IP Address or CIDR/dash. Returns False if not.
 
Argument(s):
target -- string target provided as the first argument to the program.
 
Return value(s):
Boolean.
 
Restriction(s):
This Method is tagged as a Class Method

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Parser(__builtin__.object)
    Parser represents an argparse object representing the
program's input parameters.
 
Public Method(s):
hasHTMLOutFile
(Property) HTMLOutFile
hasTextOutFile
(Property) TextOutFile
hasCSVOutSet
(Property) CSVOutFile
(Property) Delay
hasProxy
(Property) Proxy
print_help
hasTarget
hasNoTarget
(Property) Target
hasInputFile
(Property) Source
hasSource
hasPost
(Property) InputFile
(Property) UserAgent
 
Instance variable(s):
_parser
args
 
  Methods defined here:
__init__(self, desc)
Class constructor. Adds the argparse info into the instance variables.
 
Argument(s):
desc -- ArgumentParser description.
 
Return value(s):
Nothing is returned from this Method.
hasCSVOutSet(self)
Checks to determine if user requested an output file delimited by commas.
Returns True if user requested file output, False if not.
 
Argument(s):
No arguments are required.
 
Return value(s):
Boolean.
 
Restriction(s):
The Method has no restrictions.
hasHTMLOutFile(self)
Checks to determine if user requested an output file formatted in HTML.
Returns True if user requested HTML output, False if not.
 
Argument(s):
No arguments are required.
 
Return value(s):
Boolean.
 
Restriction(s):
The Method has no restrictions.
hasInputFile(self)
Checks to determine if input file is the target of the program.
Returns True if a target is an input file, False if not.
 
Argument(s):
No arguments are required.
 
Return value(s):
Boolean.
 
Restriction(s):
The Method has no restrictions.
hasNoTarget(self)
Checks to determine if a target was provided to the program.
Returns False if a target was provided, True if not.
 
Argument(s):
No arguments are required.
 
Return value(s):
Boolean.
 
Restriction(s):
The Method has no restrictions.
hasPost(self)
Checks to determine if --p parameter was provided to the program.
Returns True if --p was provided, False if not.
 
Argument(s):
No arguments are required.
 
Return value(s):
Boolean.
 
Restriction(s):
The Method has no restrictions.
hasProxy(self)
Checks to determine if user requested a proxy.
Returns True if user requested a proxy, False if not.
 
Argument(s):
No arguments are required.
 
Return value(s):
Boolean.
 
Restriction(s):
The Method has no restrictions.
hasSource(self)
Checks to determine if -s parameter and source name
was provided to the program.
Returns True if source name was provided, False if not.
 
Argument(s):
No arguments are required.
 
Return value(s):
Boolean.
 
Restriction(s):
The Method has no restrictions.
hasTarget(self)
Checks to determine if a target was provided to the program.
Returns True if a target was provided, False if not.
 
Argument(s):
No arguments are required.
 
Return value(s):
Boolean.
 
Restriction(s):
The Method has no restrictions.
hasTextOutFile(self)
Checks to determine if user requested an output text file.
Returns True if user requested text file output, False if not.
 
Argument(s):
No arguments are required.
 
Return value(s):
Boolean.
 
Restriction(s):
The Method has no restrictions.
print_help(self)
Returns standard help information to determine usage for program.
 
Argument(s):
No arguments are required.
 
Return value(s):
string -- Standard argparse help information to show program usage.
 
Restriction(s):
This Method has no restrictions.

Data descriptors defined here:
CSVOutFile
Checks if there is a comma delimited output requested.
Returns string name of comma delimited output file if requested
or None if not requested.
 
Argument(s):
No arguments are required.
 
Return value(s):
string -- Name of an comma delimited file to write to system.
None -- if comma delimited output was not requested.
 
Restriction(s):
This Method is tagged as a Property.
Delay
Returns delay set by input parameters to the program.
 
Argument(s):
No arguments are required.
 
Return value(s):
string -- String containing integer to tell program how long to delay
between each site query. Default delay is 2 seconds.
 
Restriction(s):
This Method is tagged as a Property.
HTMLOutFile
Checks if there is an HTML output requested.
Returns string name of HTML output file if requested
or None if not requested.
 
Argument(s):
No arguments are required.
 
Return value(s):
string -- Name of an output file to write to system.
None -- if web output was not requested.
 
Restriction(s):
This Method is tagged as a Property.
InputFile
Checks to determine if an input file string representation of
a target was provided as a parameter to the program.
Returns string name of file or None if file name is not provided
 
Argument(s):
No arguments are required.
 
Return value(s):
string -- String file name based on target filename parameter to program.
None -- If the target is not a filename.
 
Restriction(s):
This Method is tagged as a Property.
Proxy
Returns proxy set by input parameters to the program.
 
Argument(s):
No arguments are required.
 
Return value(s):
string -- String containing proxy server in format server:port,
default is none
 
Restriction(s):
This Method is tagged as a Property.
Source
Checks to determine if a source parameter was provided to the program.
Returns string name of source or None if a source is not provided
 
Argument(s):
No arguments are required.
 
Return value(s):
string -- String source name based on source parameter to program.
None -- If the -s parameter is not used.
 
Restriction(s):
This Method is tagged as a Property.
Target
Checks to determine the target info provided to the program.
Returns string name of target or string name of file
or None if a target is not provided.
 
Argument(s):
No arguments are required.
 
Return value(s):
string -- String target info or filename based on target parameter to program.
 
Restriction(s):
This Method is tagged as a Property.
TextOutFile
Checks if there is a text output requested.
Returns string name of text output file if requested
or None if not requested.
 
Argument(s):
No arguments are required.
 
Return value(s):
string -- Name of an output file to write to system.
None -- if output file was not requested.
 
Restriction(s):
This Method is tagged as a Property.
UserAgent
Returns useragent setting invoked by user at command line or the default
user agent provided by the program.
 
Argument(s):
No arguments are required.
 
Return value(s):
string -- Name utilized as the useragent for the program.
 
Restriction(s):
This Method is tagged as a Property.
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)