Module: Msf::Sessions::Scriptable::ClassMethods

Defined in:
lib/msf/base/sessions/scriptable.rb

Instance Method Summary collapse

Instance Method Details

#find_script_path(script) ⇒ Object

If the script exists, return its path. Otherwise return nil



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/msf/base/sessions/scriptable.rb', line 15

def find_script_path(script)
  # Find the full file path of the specified argument
  check_paths =
    [
      script,
      ::File.join(script_base, "#{script}"),
      ::File.join(script_base, "#{script}.rb"),
      ::File.join(user_script_base, "#{script}"),
      ::File.join(user_script_base, "#{script}.rb")
    ]

  full_path = nil

  # Scan all of the path combinations
  check_paths.each { |path|
    if ::File.file?(path)
      full_path = path
      break
    end
  }

  full_path
end

#script_baseObject



38
39
40
# File 'lib/msf/base/sessions/scriptable.rb', line 38

def script_base
  ::File.join(Msf::Config.script_directory, self.type)
end

#user_script_baseObject



41
42
43
# File 'lib/msf/base/sessions/scriptable.rb', line 41

def user_script_base
  ::File.join(Msf::Config.user_script_directory, self.type)
end