Module: MeterpreterBinaries

Defined in:
lib/meterpreter_bins.rb,
lib/meterpreter_bins/version.rb

Constant Summary collapse

EXTENSION_PREFIX =
'ext_server_'
METERPRETER_SUBFOLDER =
'meterpreter'
VERSION =
'0.0.22'

Class Method Summary collapse

Class Method Details

.ext_path(ext_name, binary_suffix) ⇒ Object

Get the path to an extension based on its name (no prefix).



13
14
15
# File 'lib/meterpreter_bins.rb', line 13

def self.ext_path(ext_name, binary_suffix)
  path("#{EXTENSION_PREFIX}#{ext_name}", binary_suffix)
end

.list_extensions(binary_suffix) ⇒ Object

List all the available extensions for the given suffix.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/meterpreter_bins.rb', line 42

def self.list_extensions(binary_suffix)
  extensions = []

  root_dirs = [local_dir]
  # Find the valid extensions in the data folder first, if MSF
  # is installed.
  root_dirs.unshift(metasploit_data_dir) if metasploit_installed?

  until root_dirs.length.zero?
    # Merge in any that don't already exist in the collection.
    enum_ext(root_dirs.shift, binary_suffix).each do |e|
      extensions.push(e) unless extensions.include?(e)
    end
  end

  extensions
end

.path(name, binary_suffix) ⇒ Object

Get the path to a meterpreter binary by full name.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/meterpreter_bins.rb', line 20

def self.path(name, binary_suffix)
  file_name = "#{name}.#{binary_suffix}".downcase
  root_dirs = [local_dir]

  # Try the data folder first to see if the extension exists, as this
  # allows for the MSF data/meterpreter folder to override what is
  # in the gem. This is very helpful for testing/development without
  # having to move the binaries to the gem folder each time. We only
  # do this is MSF is installed.
  root_dirs.unshift(metasploit_data_dir) if metasploit_installed?

  until root_dirs.length.zero?
    file_path = expand(root_dirs.shift, file_name)
    return file_path if ::File.readable?(file_path)
  end

  nil
end

.versionObject



5
6
7
# File 'lib/meterpreter_bins/version.rb', line 5

def self.version
  VERSION
end