updated meterpreter specs
git-svn-id: file:///home/svn/framework3/trunk@11491 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
152c380a13
commit
252832c1e1
|
@ -0,0 +1,85 @@
|
||||||
|
$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib'))
|
||||||
|
$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'test', 'lib'))
|
||||||
|
|
||||||
|
require 'fileutils'
|
||||||
|
require 'msftest'
|
||||||
|
require 'msf/base'
|
||||||
|
require 'meterpreter_spec_helper'
|
||||||
|
require 'meterpreter_specs'
|
||||||
|
|
||||||
|
module MsfTest
|
||||||
|
|
||||||
|
describe "JavaMeterpreter" do
|
||||||
|
|
||||||
|
# This include brings in all the spec helper methods
|
||||||
|
include MsfTest::MeterpreterSpecHelper
|
||||||
|
|
||||||
|
# This include brings in all the specs that are generic across the
|
||||||
|
# meterpreter platforms
|
||||||
|
include MsfTest::MeterpreterSpecs
|
||||||
|
|
||||||
|
before :all do
|
||||||
|
@verbose = true
|
||||||
|
|
||||||
|
@meterpreter_type = "java"
|
||||||
|
|
||||||
|
## Set up an outupt directory
|
||||||
|
@output_directory = "test_output_#{@meterpreter_type}"
|
||||||
|
|
||||||
|
if File.directory? @output_directory
|
||||||
|
FileUtils.rm_rf(@output_directory)
|
||||||
|
end
|
||||||
|
|
||||||
|
Dir.mkdir(@output_directory)
|
||||||
|
@default_file = "#{@output_directory}/default"
|
||||||
|
|
||||||
|
create_session_java
|
||||||
|
end
|
||||||
|
|
||||||
|
before :each do
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
after :each do
|
||||||
|
@session.init_ui(@input, @output)
|
||||||
|
|
||||||
|
## Clean Up
|
||||||
|
#FileUtils.rm_rf(@output_directory)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def create_session_java
|
||||||
|
|
||||||
|
## Setup for win32
|
||||||
|
@framework = Msf::Simple::Framework.create
|
||||||
|
|
||||||
|
test_modules_path = File.join(File.dirname(__FILE__), '..', '..', 'modules')
|
||||||
|
@framework.modules.add_module_path(test_modules_path)
|
||||||
|
|
||||||
|
@exploit_name = 'test/java_tester'
|
||||||
|
@payload_name = 'java/meterpreter/bind_tcp'
|
||||||
|
@input = Rex::Ui::Text::Input::Stdio.new
|
||||||
|
@output = Rex::Ui::Text::Output::File.new(@default_file)
|
||||||
|
|
||||||
|
# Initialize the exploit instance
|
||||||
|
exploit = @framework.exploits.create(@exploit_name)
|
||||||
|
|
||||||
|
## Fire it off against a known-vulnerable host
|
||||||
|
@session = exploit.exploit_simple(
|
||||||
|
'Options' => {},
|
||||||
|
'Payload' => @payload_name,
|
||||||
|
'LocalInput' => @input,
|
||||||
|
'LocalOutput' => @output)
|
||||||
|
|
||||||
|
puts @session.inspect
|
||||||
|
|
||||||
|
## If a session came back, try to interact with it.
|
||||||
|
if @session
|
||||||
|
@session.load_stdapi
|
||||||
|
else
|
||||||
|
raise Exception "Couldn't get a session!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -4,9 +4,19 @@ module MeterpreterSpecHelper
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.class_eval do
|
base.class_eval do
|
||||||
|
|
||||||
|
def generic_failure_strings
|
||||||
|
['fail', 'error', 'exception']
|
||||||
|
end
|
||||||
|
|
||||||
|
def generic_failure_exception_strings
|
||||||
|
['nserror.dll'] ##ugh, this is dependent on the target
|
||||||
|
end
|
||||||
|
|
||||||
def hlp_run_command_check_output(name,command,success_strings=[],fail_strings=[], fail_exception_strings=[])
|
def hlp_run_command_check_output(name,command,success_strings=[],fail_strings=[], fail_exception_strings=[])
|
||||||
|
|
||||||
|
fail_strings = fail_strings | generic_failure_strings
|
||||||
|
fail_exception_strings = fail_exception_strings | generic_failure_exception_strings
|
||||||
|
|
||||||
temp_command_file = "#{@output_directory}/#{name}"
|
temp_command_file = "#{@output_directory}/#{name}"
|
||||||
|
|
||||||
command_output = Rex::Ui::Text::Output::File.new(temp_command_file)
|
command_output = Rex::Ui::Text::Output::File.new(temp_command_file)
|
||||||
|
@ -23,7 +33,7 @@ module MeterpreterSpecHelper
|
||||||
data = hlp_file_to_string(temp_command_file)
|
data = hlp_file_to_string(temp_command_file)
|
||||||
|
|
||||||
## Ugh, this is ghetto.
|
## Ugh, this is ghetto.
|
||||||
x = MsfTestCaseHelper.new
|
x = MsfTestCaseHelper.new(@debug)
|
||||||
x.complete?(data,"meterpreter_functional_test_start","meterpreter_functional_test_end").should be_true
|
x.complete?(data,"meterpreter_functional_test_start","meterpreter_functional_test_end").should be_true
|
||||||
x.all_successes_exist?(data, success_strings).should be_true
|
x.all_successes_exist?(data, success_strings).should be_true
|
||||||
x.no_failures_exist?(data, fail_strings, fail_exception_strings ).should be_true
|
x.no_failures_exist?(data, fail_strings, fail_exception_strings ).should be_true
|
||||||
|
|
|
@ -4,38 +4,7 @@ module MeterpreterSpecs
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.class_eval do
|
base.class_eval do
|
||||||
|
|
||||||
it "should not error when running help" do
|
it "should not error when running each command" do
|
||||||
success_strings = [ 'Core Commands',
|
|
||||||
'Stdapi: File system Commands',
|
|
||||||
'Stdapi: Networking Commands',
|
|
||||||
'Stdapi: System Commands',
|
|
||||||
'Stdapi: User interface Commands',
|
|
||||||
'Priv: Elevate Commands',
|
|
||||||
'Priv: Password database Commands',
|
|
||||||
'Priv: Timestomp Commands' ]
|
|
||||||
|
|
||||||
hlp_run_command_check_output("help","help", success_strings)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should not error when running the help shortcut" do
|
|
||||||
success_strings = [ 'Core Commands',
|
|
||||||
'Stdapi: File system Commands',
|
|
||||||
'Stdapi: Networking Commands',
|
|
||||||
'Stdapi: System Commands',
|
|
||||||
'Stdapi: User interface Commands',
|
|
||||||
'Priv: Elevate Commands',
|
|
||||||
'Priv: Password database Commands',
|
|
||||||
'Priv: Timestomp Commands' ]
|
|
||||||
|
|
||||||
hlp_run_command_check_output("help_shortcut","?", success_strings)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should not error when taking a screenshot" do
|
|
||||||
success_strings = [ 'Screenshot saved to' ]
|
|
||||||
hlp_run_command_check_output("screenshot","screenshot", success_strings)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should not error when running each command" do
|
|
||||||
commands = [ "?",
|
commands = [ "?",
|
||||||
"background",
|
"background",
|
||||||
"bgkill",
|
"bgkill",
|
||||||
|
@ -103,10 +72,37 @@ module MeterpreterSpecs
|
||||||
|
|
||||||
## Run each command, check for execeptions
|
## Run each command, check for execeptions
|
||||||
commands.each do |command|
|
commands.each do |command|
|
||||||
hlp_run_command_check_output("#{command}_basic",command)
|
hlp_run_command_check_output("basic_#{command}",command)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should not error when running help" do
|
||||||
|
success_strings = [ 'Core Commands',
|
||||||
|
'Stdapi: File system Commands',
|
||||||
|
'Stdapi: Networking Commands',
|
||||||
|
'Stdapi: System Commands',
|
||||||
|
'Stdapi: User interface Commands']
|
||||||
|
|
||||||
|
hlp_run_command_check_output("help","help", success_strings)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not error when running the help shortcut" do
|
||||||
|
success_strings = [ 'Core Commands',
|
||||||
|
'Stdapi: File system Commands',
|
||||||
|
'Stdapi: Networking Commands',
|
||||||
|
'Stdapi: System Commands',
|
||||||
|
'Stdapi: User interface Commands' ]
|
||||||
|
|
||||||
|
hlp_run_command_check_output("help_shortcut","?", success_strings)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not error when taking a screenshot" do
|
||||||
|
success_strings = [ 'Screenshot saved to' ]
|
||||||
|
hlp_run_command_check_output("screenshot","screenshot", success_strings)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
it "should not error when checking for background channels" do
|
it "should not error when checking for background channels" do
|
||||||
success_strings = [ 'No active channels.' ]
|
success_strings = [ 'No active channels.' ]
|
||||||
hlp_run_command_check_output("channel_list_empty","channel -l", success_strings)
|
hlp_run_command_check_output("channel_list_empty","channel -l", success_strings)
|
||||||
|
|
|
@ -25,6 +25,17 @@ module WindowsMeterpreterSpecs
|
||||||
## clean up
|
## clean up
|
||||||
FileUtils.rm(filename)
|
FileUtils.rm(filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
it "should show the priv commands when running help" do
|
||||||
|
|
||||||
|
success_strings = ['Priv: Elevate Commands',
|
||||||
|
'Priv: Password database Commands',
|
||||||
|
'Priv: Timestomp Commands' ]
|
||||||
|
|
||||||
|
hlp_run_command_check_output("help_shortcut","help", success_strings)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue