class Metasploit::Aggregator::Server

Public Class Methods

new() click to toggle source
# File lib/metasploit/aggregator.rb, line 451
def initialize
  @router = Router.instance
  @manager = ConnectionManager.instance
end

Public Instance Methods

add_cable(type, host, port, certificate = nil) click to toggle source
# File lib/metasploit/aggregator.rb, line 485
def add_cable(type, host, port, certificate = nil)
  unless @manager.nil?
    case type
      when Cable::HTTPS
        # TODO: check if already listening on that port
        @manager.add_cable_https(host, port, certificate)
      when Cable::HTTP
        @manager.add_cable_http(host, port)
      else
        Logger.log("#{type} cables are not supported.")
    end
  end
  true
end
available?() click to toggle source
# File lib/metasploit/aggregator.rb, line 456
def available?
  !@manager.nil?
end
available_addresses() click to toggle source
# File lib/metasploit/aggregator.rb, line 518
def available_addresses
  addr_list = Socket.ip_address_list
  addresses = []
  addr_list.each do |addr|
    addresses << addr.ip_address
  end
  addresses
end
cables() click to toggle source
# File lib/metasploit/aggregator.rb, line 464
def cables
  @manager.cables
end
default() click to toggle source
# File lib/metasploit/aggregator.rb, line 513
def default
  _send, _recv, console = @router.get_forward('default')
  console
end
obtain_session(payload, uuid) click to toggle source
# File lib/metasploit/aggregator.rb, line 468
def obtain_session(payload, uuid)
  # return session object details or UUID/uri
  # forwarding will cause new session creation on the console
  # TODO: check and set lock on payload requested see note below in register_default
  @manager.register_forward(uuid, [ payload ])
  true # update later to return if lock obtained
end
register_default(uuid, payload_list) click to toggle source
# File lib/metasploit/aggregator.rb, line 506
def register_default(uuid, payload_list)
  # add this payload list to each forwarder for this remote console
  # TODO: consider adding boolean param to ConnectionManager.register_forward to 'lock'
  @manager.register_forward(uuid, payload_list)
  true
end
register_response_channel(io) click to toggle source
# File lib/metasploit/aggregator.rb, line 550
def register_response_channel(io)
  # not implemented "client only method"
  response = "register_response_channel not implemented on server"
  Logger.log response
  response
end
release_session(payload) click to toggle source
# File lib/metasploit/aggregator.rb, line 476
def release_session(payload)
  @manager.park(payload)
  true # return always return success for now
end
remove_cable(host, port) click to toggle source
# File lib/metasploit/aggregator.rb, line 500
def remove_cable(host, port)
  unless @manager.nil?
    @manager.remove_cable(host, port)
  end
end
request(uuid) click to toggle source
# File lib/metasploit/aggregator.rb, line 535
def request(uuid)
  # return requests here
  send, _recv = @router.reverse_route(uuid)
  if send.length > 0
    result = send.pop
  end
  result
end
respond(uuid, data) click to toggle source
# File lib/metasploit/aggregator.rb, line 544
def respond(uuid, data)
  _send, recv = @router.get_forward(uuid)
  recv << data unless recv.nil?
  true
end
session_details(payload) click to toggle source
# File lib/metasploit/aggregator.rb, line 481
def session_details(payload)
  @manager.connection_details(payload)
end
sessions() click to toggle source
# File lib/metasploit/aggregator.rb, line 460
def sessions
  @manager.connections
end
stop() click to toggle source
# File lib/metasploit/aggregator.rb, line 527
def stop
  unless @manager.nil?
    @manager.stop
  end
  @manager = nil
  true
end