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]),
|
|
|
|
OptString.new('InitialAutoRunScript', [false, "An initial script to run on session created (before AutoRunScript)", '']),
|
2010-03-10 22:02:27 +00:00
|
|
|
OptString.new('AutoRunScript', [false, "A script to automatically on session creation.", '']),
|
|
|
|
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)
|
|
|
|
super
|
|
|
|
|
2010-02-23 20:56:44 +00:00
|
|
|
# Configure input/output to match the payload
|
2010-04-20 03:59:27 +00:00
|
|
|
#session.init_ui(self.user_input, self.user_output)
|
2010-02-23 20:56:44 +00:00
|
|
|
|
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
|
|
|
|