Method: Msf::Exploit::Remote::HttpClient#send_request_raw

Defined in:
lib/msf/core/exploit/remote/http_client.rb

#send_request_raw(opts = {}, timeout = 20, disconnect = false) ⇒ Object

Connects to the server, creates a request, sends the request, reads the response.

In certain cases such as when the response is a 401 and the client is configured for authentication, more than one request may be sent to the server. A degree of control over disconnecting the client’s underlying socket can be obtained by toggling the disconnect option.

Passes opts through directly to Rex::Proto::Http::Client#request_raw.

Parameters:

  • opts (Hash) (defaults to: {})

    Options with which to make the HTTP request

  • timeout (Integer) (defaults to: 20)

    The timeout for requests and responses

  • disconnect (Boolean) (defaults to: false)

    Whether to disconnect the client's socket after the last request has been made



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/msf/core/exploit/remote/http_client.rb', line 368

def send_request_raw(opts = {}, timeout = 20, disconnect = false)
  if datastore['HttpClientTimeout'] && datastore['HttpClientTimeout'] > 0
    actual_timeout = datastore['HttpClientTimeout']
  else
    actual_timeout = opts[:timeout] || timeout
  end

  c = opts['client'] || connect(opts)
  r = opts['cgi'] ? c.request_cgi(opts) : c.request_raw(opts)

  res = c.send_recv(r, actual_timeout)

  disconnect(c) if disconnect

  res
rescue ::Errno::EPIPE, ::Timeout::Error => e
  print_line(e.message) if datastore['HttpTrace']
  nil
rescue Rex::ConnectionError => e
  vprint_error(e.to_s)
  nil
rescue ::Exception => e
  print_line(e.message) if datastore['HttpTrace']
  raise e
end