Class: Metasploit::Aggregator::Http::Requester

Inherits:
Object
  • Object
show all
Defined in:
lib/metasploit/aggregator/http/requester.rb

Overview

a Requester takes in Request object and to send to a known port and protocol and receives a response that it also returns as a Request object

Direct Known Subclasses

SslRequester

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ Requester

Returns a new instance of Requester.



10
11
12
13
# File 'lib/metasploit/aggregator/http/requester.rb', line 10

def initialize(host, port)
  @host = host
  @port = port
end

Instance Method Details

#close_connection(connection) ⇒ Object



34
35
36
# File 'lib/metasploit/aggregator/http/requester.rb', line 34

def close_connection(connection)
  connection.close
end

#get_connection(host, port) ⇒ Object



30
31
32
# File 'lib/metasploit/aggregator/http/requester.rb', line 30

def get_connection(host, port)
  TCPSocket.new host, port
end

#process_request(request) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/metasploit/aggregator/http/requester.rb', line 15

def process_request(request)
  socket = get_connection(@host, @port)
  write_request(socket, request)
  response_obj = Metasploit::Aggregator::Http::Responder.get_data(socket, true)
  close_connection(socket)
  response_obj
end

#write_request(connection, request) ⇒ Object



23
24
25
26
27
28
# File 'lib/metasploit/aggregator/http/requester.rb', line 23

def write_request(connection, request)
  request.headers.each do |header|
    connection.write(header)
  end
  connection.write(request.body) unless request.body.nil?
end