Class: Metasploit::Aggregator::Http::Request
- Inherits:
-
Object
- Object
- Metasploit::Aggregator::Http::Request
- Defined in:
- lib/metasploit/aggregator/http/request.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Class Method Summary collapse
- .forge_request(uri, body, socket = nil) ⇒ Object
- .generate_response(http_request) ⇒ Object
-
.parked ⇒ Object
provide a default response in Request form.
- .parse_uri(http_request) ⇒ Object
Instance Method Summary collapse
-
#initialize(request_headers, request_body, socket) ⇒ Request
constructor
A new instance of Request.
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
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/metasploit/aggregator/http/request.rb', line 6 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/metasploit/aggregator/http/request.rb', line 5 def headers @headers end |
#socket ⇒ Object (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
.forge_request(uri, body, socket = nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/metasploit/aggregator/http/request.rb', line 48 def self.forge_request(uri, body, socket = nil) = [] << "POST #{uri}/ HTTP/1.1" + "\n" << 'Accept-Encoding: identity' + "\n" << 'Content-Length: ' + body.length.to_s + "\n" << 'Host: 127.0.0.1:2447' + "\n" # this value is defaulted to reflect the aggregator << 'Content-Type: application/octet-stream' + "\n" << 'Connection: close' + "\n" << 'User-Agent: Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko'+ "\n" << '' + "\n" self.new(, body, socket) end |
.generate_response(http_request) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/metasploit/aggregator/http/request.rb', line 31 def self.generate_response(http_request) socket = nil body = '' unless http_request.nil? || http_request.body.nil? body = http_request.body end = [] << 'HTTP/1.1 200 OK' + "\n" << 'Content-Type: application/octet-stream' + "\n" << 'Connection: close' + "\n" << 'Server: Apache' + "\n" << 'Content-Length: ' + body.length.to_s + "\n" << '' + "\n" << '' + "\n" self.new(, body, socket) end |
.parked ⇒ Object
provide a default response in Request form
27 28 29 |
# File 'lib/metasploit/aggregator/http/request.rb', line 27 def self.parked() generate_response(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 |