Class: Metasploit::Aggregator::Http::Request

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_headers, request_body, socket) ⇒ Request

Returns a new instance of Request.



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

def initialize(request_headers, request_body, socket)
  @headers = request_headers
  @body = request_body
  @socket = socket
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/metasploit/aggregator/http/request.rb', line 6

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/metasploit/aggregator/http/request.rb', line 5

def headers
  @headers
end

#socketObject (readonly)

Returns the value of attribute socket.



7
8
9
# File 'lib/metasploit/aggregator/http/request.rb', line 7

def socket
  @socket
end

Class Method Details

.from_msgpack(string) ⇒ Object



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

def self.from_msgpack(string)
  data = MessagePack.load string
  self.new(data['headers'], data['body'].force_encoding(Encoding::ASCII_8BIT), nil)
end

.parkedObject

provide a default response in Request form



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/metasploit/aggregator/http/request.rb', line 39

def self.parked()
  parked_message = []
  parked_message << 'HTTP/1.1 200 OK'
  parked_message << 'Content-Type: application/octet-stream'
  parked_message << 'Connection: close'
  parked_message << 'Server: Apache'
  parked_message << 'Content-Length: 0'
  parked_message << ' '
  parked_message << ' '
  self.new(parked_message, '', nil)
end

.parse_uri(http_request) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/metasploit/aggregator/http/request.rb', line 15

def self.parse_uri(http_request)
  req = http_request.headers[0]
  parts = req.split(/ /)
  uri = nil
  if parts.length >= 2
    uri = req.split(/ /)[1]
    uri = uri.chomp('/')
  end
  uri
end

Instance Method Details

#to_msgpackObject



26
27
28
29
30
31
# File 'lib/metasploit/aggregator/http/request.rb', line 26

def to_msgpack
  MessagePack.dump ({
      :headers => headers,
      :body => body
  })
end