Files
metasploit-gs/lib/msf/base/sessions/command_shell_options.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.8 KiB
Ruby
Raw Normal View History

# -*- coding: binary -*-
2010-02-24 01:19:59 +00:00
##
# 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.
2017-07-24 06:26:21 -07:00
# https://metasploit.com/framework/
2010-02-24 01:19:59 +00:00
##
module Msf
module Sessions
module CommandShellOptions
def initialize(info = {})
super(info)
2013-08-30 16:28:33 -05:00
2010-02-24 01:19:59 +00:00
register_advanced_options(
[
OptString.new('InitialAutoRunScript', "An initial script to run on session creation (before AutoRunScript)"),
OptString.new('AutoRunScript', "A script to run automatically on session creation."),
2021-04-15 10:32:09 -04:00
OptString.new('CommandShellCleanupCommand', "A command to run before the session is closed"),
OptBool.new('AutoVerifySession', [true, 'Automatically verify and drop invalid sessions', true])
]
)
2010-02-24 01:19:59 +00:00
end
2013-08-30 16:28:33 -05:00
2010-02-24 01:19:59 +00:00
def on_session(session)
super
2013-08-30 16:28:33 -05:00
2010-02-24 01:19:59 +00:00
# Configure input/output to match the payload
session.user_input = self.user_input if self.user_input
session.user_output = self.user_output if self.user_output
platform = nil
if self.platform and self.platform.kind_of? Msf::Module::PlatformList
platform = self.platform.platforms.first.realname.downcase
end
if self.platform and self.platform.kind_of? Msf::Module::Platform
platform = self.platform.realname.downcase
end
# a blank platform is *all* platforms and used by the generic modules, in that case only set this instance if it was
# not previously set to a more specific value through some means
session.platform = platform unless platform.blank? && !session.platform.blank?
if self.arch
if self.arch.kind_of?(Array)
session.arch = self.arch.join('')
else
session.arch = self.arch
end
end
2010-02-24 01:19:59 +00:00
end
end
end
end