2010-02-22 21:05:08 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
module Msf
|
|
|
|
module Sessions
|
|
|
|
module MeterpreterOptions
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(info)
|
|
|
|
|
|
|
|
register_advanced_options(
|
|
|
|
[
|
|
|
|
OptBool.new('AutoLoadStdapi', [true, "Automatically load the Stdapi extension", true]),
|
2010-08-03 16:07:48 +00:00
|
|
|
OptString.new('InitialAutoRunScript', [false, "An initial script to run on session creation (before AutoRunScript)", '']),
|
|
|
|
OptString.new('AutoRunScript', [false, "A script to run automatically on session creation.", '']),
|
2010-03-10 22:02:27 +00:00
|
|
|
OptBool.new('AutoSystemInfo', [true, "Automatically capture system information on initialization.", true]),
|
2010-02-22 21:05:08 +00:00
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Once a session is created, automatically load the stdapi extension if the
|
|
|
|
# advanced option is set to true.
|
|
|
|
#
|
|
|
|
def on_session(session)
|
2010-04-20 07:01:46 +00:00
|
|
|
super
|
2010-02-23 20:56:44 +00:00
|
|
|
|
2010-05-20 23:47:49 +00:00
|
|
|
session.init_ui(self.user_input, self.user_output)
|
|
|
|
|
2010-02-22 21:05:08 +00:00
|
|
|
if (datastore['AutoLoadStdapi'] == true)
|
|
|
|
session.load_stdapi
|
2010-03-16 19:17:21 +00:00
|
|
|
mod = framework.modules.create(session.via_exploit)
|
|
|
|
if (mod and mod.privileged?)
|
2010-02-22 21:05:08 +00:00
|
|
|
session.load_priv
|
|
|
|
end
|
2010-03-10 22:02:27 +00:00
|
|
|
|
|
|
|
if datastore['AutoSystemInfo']
|
|
|
|
session.load_session_info
|
|
|
|
end
|
2010-02-22 21:05:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if (datastore['InitialAutoRunScript'].empty? == false)
|
|
|
|
args = datastore['InitialAutoRunScript'].split
|
|
|
|
print_status("Session ID #{session.sid} (#{session.tunnel_to_s}) processing InitialAutoRunScript '#{datastore['InitialAutoRunScript']}'")
|
2010-02-23 20:16:45 +00:00
|
|
|
session.execute_script(args.shift, args)
|
2010-02-22 21:05:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if (datastore['AutoRunScript'].empty? == false)
|
|
|
|
args = datastore['AutoRunScript'].split
|
|
|
|
print_status("Session ID #{session.sid} (#{session.tunnel_to_s}) processing AutoRunScript '#{datastore['AutoRunScript']}'")
|
2010-02-23 20:16:45 +00:00
|
|
|
session.execute_script(args.shift, args)
|
2010-02-22 21:05:08 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-02-23 20:16:45 +00:00
|
|
|
|