b391abd32d
1. InitialAutoRunScript and AutoRunScript vars work 2. scripts/shells was created to hold them 3. *_shell methods were renamed shell_* 4. added "shell_command" method to command shell sessions 5. converted all uses of *_shell to shell_* 6. all payloads that produce command shell sessions include Msf::Sessions::CommandShellOptions git-svn-id: file:///home/svn/framework3/trunk@8615 4d416f70-5f16-0410-b530-b9f4589650da
54 lines
1.5 KiB
Ruby
54 lines
1.5 KiB
Ruby
##
|
|
# $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 CommandShellOptions
|
|
|
|
def initialize(info = {})
|
|
super(info)
|
|
|
|
register_advanced_options(
|
|
[
|
|
OptString.new('InitialAutoRunScript', [false, "An initial script to run on session created (before AutoRunScript)", '']),
|
|
OptString.new('AutoRunScript', [false, "A script to automatically on session creation.", ''])
|
|
], 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
|
|
|
|
# Configure input/output to match the payload
|
|
session.user_input = self.user_input
|
|
session.user_output = self.user_output
|
|
|
|
if (datastore['InitialAutoRunScript'].empty? == false)
|
|
args = datastore['InitialAutoRunScript'].split
|
|
print_status("Session ID #{session.sid} (#{session.tunnel_to_s}) processing InitialAutoRunScript '#{datastore['InitialAutoRunScript']}'")
|
|
session.execute_script(args.shift, args)
|
|
end
|
|
|
|
if (datastore['AutoRunScript'].empty? == false)
|
|
args = datastore['AutoRunScript'].split
|
|
print_status("Session ID #{session.sid} (#{session.tunnel_to_s}) processing AutoRunScript '#{datastore['AutoRunScript']}'")
|
|
session.execute_script(args.shift, args)
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|