module MetasploitPayloads::Mettle
Constants
- VERSION
Public Class Methods
read(triple, file)
click to toggle source
Get the contents of any file packaged in this gem by local path and name.
# File lib/metasploit_payloads/mettle.rb, line 27 def self.read(triple, file) file_path = path("cross-#{triple}", 'bin', file) if file_path.nil? full_path = ::File.join([triple, file]) fail RuntimeError, "#{full_path} not found", caller end ::File.binread(file_path) end
readable_path(gem_path, msf_path)
click to toggle source
# File lib/metasploit_payloads/mettle.rb, line 11 def self.readable_path(gem_path, msf_path) # Try the MSF path first to see if the file exists, allowing the MSF data # 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. if ::File.readable? msf_path warn_local_path(msf_path) if ::File.readable? gem_path msf_path elsif ::File.readable? gem_path gem_path end end
version()
click to toggle source
# File lib/metasploit_payloads/mettle/version.rb, line 5 def self.version VERSION end
Private Class Methods
data_directory()
click to toggle source
Full path to the local gem folder containing the base data
# File lib/metasploit_payloads/mettle.rb, line 54 def self.data_directory ::File.realpath(::File.join(::File.dirname(__FILE__), '..', '..', 'build')) end
expand(root_dir, file_name)
click to toggle source
Expand the given root path and file name into a full file location.
# File lib/metasploit_payloads/mettle.rb, line 68 def self.expand(root_dir, file_name) ::File.expand_path(::File.join(root_dir, file_name)) end
metasploit_installed?()
click to toggle source
Determine if MSF has been installed and is being used.
# File lib/metasploit_payloads/mettle.rb, line 61 def self.metasploit_installed? defined? Msf::Config end
path(*path_parts)
click to toggle source
Get the full path to any file packaged in this gem by local path and name.
# File lib/metasploit_payloads/mettle.rb, line 42 def self.path(*path_parts) gem_path = expand(data_directory, ::File.join(path_parts)) msf_path = 'thisisnotthefileyouarelookingfor' if metasploit_installed? msf_path = expand(Msf::Config.data_directory, ::File.join('mettle', path_parts)) end readable_path(gem_path, msf_path) end
warn_local_path(path)
click to toggle source
# File lib/metasploit_payloads/mettle.rb, line 74 def self.warn_local_path(path) unless @local_paths.include?(path) STDERR.puts("WARNING: Local file #{path} is being used") if @local_paths.empty? STDERR.puts('WARNING: Local files may be incompatible Metasploit framework') end @local_paths << path end end