From 8f95624bf7d8b167ef1779b6e5a6975a9d590d05 Mon Sep 17 00:00:00 2001 From: sinn3r Date: Wed, 25 Mar 2015 01:40:02 -0500 Subject: [PATCH] Add #send_request to Metasploit::Framework::LoginScanner::HTTP --- .../framework/login_scanner/http.rb | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/metasploit/framework/login_scanner/http.rb b/lib/metasploit/framework/login_scanner/http.rb index b54f4605df..a0ee6d8bab 100644 --- a/lib/metasploit/framework/login_scanner/http.rb +++ b/lib/metasploit/framework/login_scanner/http.rb @@ -187,6 +187,40 @@ module Metasploit error_message end + # Sends a HTTP request with Rex + # + # @param (see Rex::Proto::Http::Request#request_raw) + # @raise [Rex::ConnectionError] Something has gone wrong while sending the HTTP request + # @return [Rex::Proto::Http::Response] The HTTP response + def send_request(opts) + res = nil + cli = Rex::Proto::Http::Client.new(host, port, + { + 'Msf' => framework, + 'MsfExploit' => framework_module + }, + ssl, + ssl_version, + proxies + ) + configure_http_client(cli) + begin + cli.connect + req = cli.request_cgi(opts) + res = cli.send_recv(req) + rescue ::Errno::EPIPE, ::Timeout::Error => e + # We are trying to mimic the same type of exception rescuing in + # Msf::Exploit::Remote::HttpClient. But instead of returning nil, we'll consistently + # raise Rex::ConnectionError so the #attempt_login can return the error message back + # to the login module. + raise Rex::ConnectionError, e.message + ensure + cli.close + end + + res + end + # Attempt a single login with a single credential against the target. # # @param credential [Credential] The credential object to attempt to