diff --git a/test/lib/module_test.rb b/test/lib/module_test.rb new file mode 100644 index 0000000000..5d95d9a945 --- /dev/null +++ b/test/lib/module_test.rb @@ -0,0 +1,27 @@ + + + +module Msf::ModuleTest + attr_accessor :error + + def it(msg="", &block) + begin + result = block.call + unless result + print_error("FAILED: #{msg}") + print_error("FAILED: #{error}") if error + @error = nil + return + end + rescue ::Exception => e + print_error("FAILED: #{msg}") + print_error("Exception: #{e.class} : #{e}") + return + end + + print_good("#{msg}") + end +end + + + diff --git a/test/modules/post/test/meterpreter.rb b/test/modules/post/test/meterpreter.rb new file mode 100644 index 0000000000..834229f3d0 --- /dev/null +++ b/test/modules/post/test/meterpreter.rb @@ -0,0 +1,51 @@ + +require 'msf/core' +require 'rex' + +$:.push "test/lib" unless $:.include? "test/lib" +#require 'module_test' +load 'test/lib/module_test.rb' + + +class Metasploit3 < Msf::Post + + include Msf::ModuleTest + + def initialize(info={}) + super( update_info( info, + 'Name' => 'Testing ', + 'Description' => %q{ This module will test windows services methods within a shell}, + 'License' => MSF_LICENSE, + 'Author' => [ 'egypt'], + 'Version' => '$Revision: 11663 $', + 'Platform' => [ 'windows', 'linux' ], + 'SessionTypes' => [ 'meterpreter' ] + )) + + end + + def run + blab = datastore['VERBOSE'] + print_status("Running against session #{datastore["SESSION"]}") + print_status("Session type is #{session.type}") + + it "should return a user id" do + uid = session.sys.config.getuid + true + end + + it "should return a sysinfo Hash" do + sysinfo = session.sys.config.sysinfo + true + end + + it "should return network interfaces" do + ifaces = session.net.config.get_interfaces + + ifaces and ifaces.length > 0 + end + + print_status("Testing complete.") + end + +end