2010-02-22 21:05:08 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
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)
|
2010-09-20 04:58:25 +00:00
|
|
|
|
2010-02-22 21:05:08 +00:00
|
|
|
session.load_stdapi
|
2010-10-08 19:36:34 +00:00
|
|
|
|
2010-03-10 22:02:27 +00:00
|
|
|
if datastore['AutoSystemInfo']
|
|
|
|
session.load_session_info
|
|
|
|
end
|
2010-10-08 19:36:34 +00:00
|
|
|
|
2010-10-29 04:14:22 +00:00
|
|
|
=begin
|
2010-10-08 17:31:08 +00:00
|
|
|
admin = false
|
2010-09-20 04:58:25 +00:00
|
|
|
begin
|
2010-10-08 19:36:34 +00:00
|
|
|
::Timeout.timeout(30) do
|
2010-09-20 04:58:25 +00:00
|
|
|
if session.railgun and session.railgun.shell32.IsUserAnAdmin()["return"] == true
|
2010-10-08 17:31:08 +00:00
|
|
|
admin = true
|
2010-09-20 04:58:25 +00:00
|
|
|
session.info += " (ADMIN)"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue ::Exception
|
2010-09-16 21:44:25 +00:00
|
|
|
end
|
2010-10-29 04:14:22 +00:00
|
|
|
=end
|
2010-11-11 16:15:26 +00:00
|
|
|
if session.platform =~ /win32|win64/i
|
|
|
|
session.load_priv rescue nil
|
|
|
|
end
|
2010-02-22 21:05:08 +00:00
|
|
|
end
|
2010-10-08 17:31:08 +00:00
|
|
|
|
|
|
|
|
2010-02-22 21:05:08 +00:00
|
|
|
|
|
|
|
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
|
|
|
|