Class: Msf::Modules::External::GoBridge

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) ⇒ GoBridge

Returns a new instance of GoBridge.


213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/msf/core/modules/external/bridge.rb', line 213

def initialize(module_path, framework: nil)
  super
  default_go_path = ENV['GOPATH'] || ''
  shared_module_lib_path = File.dirname(module_path) + "/shared"
  go_path = File.expand_path('../go', __FILE__)

  if File.exist?(default_go_path)
    go_path = go_path + File::PATH_SEPARATOR + default_go_path
  end

  if File.exist?(shared_module_lib_path)
    go_path = go_path + File::PATH_SEPARATOR + shared_module_lib_path
  end

  self.env = self.env.merge({'GOPATH' => go_path})
  self.cmd = ['go', 'run', self.path]
end

Class Method Details

.applies?(module_name) ⇒ Boolean

Returns:

  • (Boolean)

209
210
211
# File 'lib/msf/core/modules/external/bridge.rb', line 209

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

Instance Method Details

#handle_exception(error) ⇒ Object


231
232
233
234
235
236
237
238
# File 'lib/msf/core/modules/external/bridge.rb', line 231

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