Module: Msf::Sessions::CommandShellOptions

Included in:
Auxiliary::CommandShell
Defined in:
lib/msf/base/sessions/command_shell_options.rb

Instance Method Summary collapse

Instance Method Details

#initialize(info = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/msf/base/sessions/command_shell_options.rb', line 15

def initialize(info = {})
  super(info)

  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."),
      OptString.new('CommandShellCleanupCommand', "A command to run before the session is closed"),
      OptBool.new('AutoVerifySession', [true, 'Automatically verify and drop invalid sessions', true])
    ]
  )
end

#on_session(session) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/msf/base/sessions/command_shell_options.rb', line 28

def on_session(session)
  super

  # 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

end