text = '*** WARNING *** The SAP support data is not in the correct format'
print text
print ''
fileHandle.write ( text+'\n\n' )
else:
text = '*** WARNING *** The SAP support data was not in the correct place'
print text
print ''
fileHandle.write ( text+'\n\n' )
#
# Command Line Options
#
parser = OptionParser()
parser.add_option("-t", "--target", action="store", dest="target", metavar="TARGET", help="Target IP address or hostname (required)")
parser.add_option("-o", "--outputfile", action="store", dest="outputfile", metavar="OUTPUTFILE", default="temp", help="Output file to write data to (defaults to dlsw_<target>.txt)")
parser.add_option("-p", "--port", action="store", dest="port", type="int", default="2065", help="Port number to connect to and listen on (defaults to 2065)")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Display more verbose informtaion")
parser.add_option("-V", "--version", action="store", dest="version", default=1, type="choice", choices=["1","2"], help="Version to try 1 or 2 (defaults to version 2)")
parser.add_option("-c", action="store_true", dest="complete", default=False, help="Attempt to complete the Capabilities Exchange (defaults to no)")
# Get the command line options
(options, args) = parser.parse_args()
# Assign the rest of the inputs
port = options.port
version = options.version
verbose = options.verbose
complete = options.complete
# Mandate the use of a target
parser.check_required("-t")
if options.target:
target = options.target
if verbose == True:
print 'TARGET:', target
else:
sys.exit(0)
if port >= 0 and port < 65536:
pass
else:
print 'Error, port number must be between 0 and 65535'
sys.exit(0)
# REVIEW THE USE OF THIS
if options.outputfile != "temp":
outputfile = options.outputfile
filewrite = 1
else:
outputfile = 'dlsw_'+target+'.txt'
filewrite = 0
# Open logfile for writing
if filewrite == 1:
# SANITISE INPUT
# Open the log file for writing
try:
fileHandle = open ( outputfile, 'a' )
if verbose == True:
print 'Output will be written to logfile', outputfile