2011-01-06 18:26:14 +00:00
|
|
|
module MsfTest
|
|
|
|
module MeterpreterSpecHelper
|
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
def self.included(base)
|
2011-01-06 18:26:14 +00:00
|
|
|
base.class_eval do
|
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
def generic_failure_strings
|
|
|
|
['fail', 'error', 'exception']
|
|
|
|
end
|
|
|
|
|
|
|
|
def generic_failure_exception_strings
|
|
|
|
['nserror.dll', 'tiki-error.php','tiki-error_simple.php','tiki-rss_error.php'] ##ugh, this is dependent on the target
|
|
|
|
end
|
2011-01-06 18:26:14 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
def hlp_run_command_check_output(name,command,success_strings=[],fail_strings=[], fail_exception_strings=[])
|
2011-01-06 18:26:14 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
fail_strings = fail_strings | generic_failure_strings
|
|
|
|
fail_exception_strings = fail_exception_strings | generic_failure_exception_strings
|
2011-01-06 20:48:56 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
temp_command_file = "#{@output_directory}/#{name}"
|
|
|
|
|
|
|
|
command_output = Rex::Ui::Text::Output::File.new(temp_command_file)
|
|
|
|
@session.init_ui(@input, command_output)
|
|
|
|
|
|
|
|
command_output.print_line("meterpreter_functional_test_start")
|
|
|
|
|
|
|
|
if @verbose
|
|
|
|
puts "Running Command: " + command
|
|
|
|
end
|
|
|
|
|
|
|
|
@session.run_cmd(command)
|
|
|
|
command_output.print_line("meterpreter_functional_test_end")
|
|
|
|
data = hlp_file_to_string(temp_command_file)
|
|
|
|
|
|
|
|
data.should contain_a_complete_test
|
|
|
|
data.should contain_all_successes
|
|
|
|
data.should contain_no_failures_except
|
|
|
|
end
|
|
|
|
|
|
|
|
def hlp_file_to_string(filename)
|
|
|
|
data = ""
|
|
|
|
f = File.open(filename, "r")
|
|
|
|
f.each_line do |line|
|
|
|
|
data += line
|
|
|
|
end
|
|
|
|
return data
|
|
|
|
end
|
|
|
|
|
|
|
|
def hlp_string_to_file(string, filepath)
|
|
|
|
# Create a new file and write to it
|
|
|
|
File.open(filepath, 'w') do |f2|
|
|
|
|
f2.puts string
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-01-06 18:26:14 +00:00
|
|
|
end
|
|
|
|
end
|