Class: Msf::Modules::External::PyBridge

Inherits:
Bridge
  • Object
show all
Defined in:
lib/msf/core/modules/external/bridge.rb

Constant Summary

Constants inherited from Bridge

Bridge::LOADERS

Instance Attribute Summary

Attributes inherited from Bridge

#buf, #cmd, #env, #exit_status, #framework, #ios, #messages, #path, #read_thread, #running, #wait_thread

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bridge

#cleanup, #close, #exec, #harvest_process, #next_message, open, #send, #success?, #threadme, #write_message

Constructor Details

#initialize(module_path, framework: nil) ⇒ PyBridge

Returns a new instance of PyBridge.



180
181
182
183
184
# File 'lib/msf/core/modules/external/bridge.rb', line 180

def initialize(module_path, framework: nil)
  super
  pythonpath = ENV['PYTHONPATH'] || ''
  self.env = self.env.merge({ 'PYTHONPATH' => File.expand_path('../python', __FILE__) + File::PATH_SEPARATOR + pythonpath})
end

Class Method Details

.applies?(module_name) ⇒ Boolean

Returns:

  • (Boolean)


176
177
178
# File 'lib/msf/core/modules/external/bridge.rb', line 176

def self.applies?(module_name)
  module_name.match? /\.py$/
end

Instance Method Details

#handle_exception(error) ⇒ Object



186
187
188
189
190
191
192
193
# File 'lib/msf/core/modules/external/bridge.rb', line 186

def handle_exception(error)
  case error
  when Errno::ENOENT
    LoadError.new('Failed to execute external Python module. Please ensure you have Python3 installed on your environment.')
  else
    super
  end
end