Skip to content

Commit 8f95624

Browse files
committed
Add #send_request to Metasploit::Framework::LoginScanner::HTTP
1 parent 376bf13 commit 8f95624

File tree

1 file changed

+34
-0
lines changed
  • lib/metasploit/framework/login_scanner

1 file changed

+34
-0
lines changed

lib/metasploit/framework/login_scanner/http.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,40 @@ def check_setup
187187
error_message
188188
end
189189

190+
# Sends a HTTP request with Rex
191+
#
192+
# @param (see Rex::Proto::Http::Request#request_raw)
193+
# @raise [Rex::ConnectionError] Something has gone wrong while sending the HTTP request
194+
# @return [Rex::Proto::Http::Response] The HTTP response
195+
def send_request(opts)
196+
res = nil
197+
cli = Rex::Proto::Http::Client.new(host, port,
198+
{
199+
'Msf' => framework,
200+
'MsfExploit' => framework_module
201+
},
202+
ssl,
203+
ssl_version,
204+
proxies
205+
)
206+
configure_http_client(cli)
207+
begin
208+
cli.connect
209+
req = cli.request_cgi(opts)
210+
res = cli.send_recv(req)
211+
rescue ::Errno::EPIPE, ::Timeout::Error => e
212+
# We are trying to mimic the same type of exception rescuing in
213+
# Msf::Exploit::Remote::HttpClient. But instead of returning nil, we'll consistently
214+
# raise Rex::ConnectionError so the #attempt_login can return the error message back
215+
# to the login module.
216+
raise Rex::ConnectionError, e.message
217+
ensure
218+
cli.close
219+
end
220+
221+
res
222+
end
223+
190224
# Attempt a single login with a single credential against the target.
191225
#
192226
# @param credential [Credential] The credential object to attempt to

0 commit comments

Comments
 (0)