@@ -198,8 +198,9 @@ def send_request(opts)
198
198
cli_ssl = opts [ 'ssl' ] || ssl
199
199
cli_ssl_version = opts [ 'ssl_version' ] || ssl_version
200
200
cli_proxies = opts [ 'proxies' ] || proxies
201
- username = opts [ 'username' ] || ''
202
- password = opts [ 'password' ] || ''
201
+ username = opts [ 'credential' ] ? opts [ 'credential' ] . public : ''
202
+ password = opts [ 'credential' ] ? opts [ 'credential' ] . private : ''
203
+ realm = opts [ 'credential' ] ? opts [ 'credential' ] . realm : nil
203
204
context = opts [ 'context' ] || { 'Msf' => framework , 'MsfExploit' => framework_module }
204
205
205
206
res = nil
@@ -214,6 +215,11 @@ def send_request(opts)
214
215
password
215
216
)
216
217
configure_http_client ( cli )
218
+
219
+ if realm
220
+ cli . set_config ( 'domain' => credential . realm )
221
+ end
222
+
217
223
begin
218
224
cli . connect
219
225
req = cli . request_cgi ( opts )
@@ -227,13 +233,13 @@ def send_request(opts)
227
233
res
228
234
end
229
235
236
+
230
237
# Attempt a single login with a single credential against the target.
231
238
#
232
239
# @param credential [Credential] The credential object to attempt to
233
240
# login with.
234
241
# @return [Result] A Result object indicating success or failure
235
242
def attempt_login ( credential )
236
-
237
243
result_opts = {
238
244
credential : credential ,
239
245
status : Metasploit ::Model ::Login ::Status ::INCORRECT ,
@@ -249,32 +255,13 @@ def attempt_login(credential)
249
255
result_opts [ :service_name ] = 'http'
250
256
end
251
257
252
- http_client = Rex ::Proto ::Http ::Client . new (
253
- host , port , { 'Msf' => framework , 'MsfExploit' => framework_module } , ssl , ssl_version ,
254
- proxies , credential . public , credential . private
255
- )
256
-
257
- configure_http_client ( http_client )
258
-
259
- if credential . realm
260
- http_client . set_config ( 'domain' => credential . realm )
261
- end
262
-
263
258
begin
264
- http_client . connect
265
- request = http_client . request_cgi (
266
- 'uri' => uri ,
267
- 'method' => method
268
- )
269
-
270
- response = http_client . send_recv ( request )
259
+ response = send_request ( 'credential' => credential , 'uri' => uri , 'method' => method )
271
260
if response && response . code == 200
272
261
result_opts . merge! ( status : Metasploit ::Model ::Login ::Status ::SUCCESSFUL , proof : response . headers )
273
262
end
274
- rescue :: EOFError , Errno :: ETIMEDOUT , Rex ::ConnectionError , :: Timeout :: Error => e
263
+ rescue Rex ::ConnectionError => e
275
264
result_opts . merge! ( status : Metasploit ::Model ::Login ::Status ::UNABLE_TO_CONNECT , proof : e )
276
- ensure
277
- http_client . close
278
265
end
279
266
280
267
Result . new ( result_opts )
0 commit comments