Add some simple meterpreter API tests

unstable
James Lee 2012-03-01 16:30:37 -07:00
parent 4f2fd918e4
commit 9bac806cdb
2 changed files with 78 additions and 0 deletions

27
test/lib/module_test.rb Normal file
View File

@ -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

View File

@ -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