Skip to content

Commit 3bffd24

Browse files
committed
Land rapid7#4056, @wchen-r7's fix for Loginscanner specs
2 parents d6f4c02 + 49b088d commit 3bffd24

File tree

37 files changed

+507
-565
lines changed

37 files changed

+507
-565
lines changed

lib/metasploit/framework/login_scanner/axis2.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Axis2 < HTTP
1717
# (see Base#attempt_login)
1818
def attempt_login(credential)
1919
http_client = Rex::Proto::Http::Client.new(
20-
host, port, {}, ssl, ssl_version
20+
host, port, {}, ssl, ssl_version, proxies
2121
)
2222

2323
http_client = config_client(http_client)
@@ -49,8 +49,8 @@ def attempt_login(credential)
4949
else
5050
result_opts.merge!(status: Metasploit::Model::Login::Status::INCORRECT, proof: response)
5151
end
52-
rescue ::EOFError, Rex::ConnectionError, ::Timeout::Error
53-
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
52+
rescue ::EOFError, Rex::ConnectionError, ::Timeout::Error => e
53+
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, proof: e)
5454
end
5555

5656
Result.new(result_opts)

lib/metasploit/framework/login_scanner/db2.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ def attempt_login(credential)
3939
result_options[:status] = Metasploit::Model::Login::Status::INCORRECT
4040
end
4141
end
42-
rescue ::Rex::ConnectionError, ::Rex::ConnectionTimeout, ::Rex::Proto::DRDA::RespError,::Timeout::Error => e
42+
rescue ::Rex::ConnectionError, ::Rex::Proto::DRDA::RespError, ::Timeout::Error => e
4343
result_options.merge!({
4444
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
45-
proof: e.message
45+
proof: e,
4646
})
4747
end
4848

lib/metasploit/framework/login_scanner/glassfish.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def check_setup
6161
# @param (see Rex::Proto::Http::Resquest#request_raw)
6262
# @return [Rex::Proto::Http::Response] The HTTP response
6363
def send_request(opts)
64-
cli = Rex::Proto::Http::Client.new(host, port, {}, ssl, ssl_version)
64+
cli = Rex::Proto::Http::Client.new(host, port, {}, ssl, ssl_version, proxies)
6565
cli.connect
6666
req = cli.request_raw(opts)
6767
res = cli.send_recv(req)
@@ -182,8 +182,8 @@ def attempt_login(credential)
182182
status = try_glassfish_3(credential)
183183
result_opts.merge!(status)
184184
end
185-
rescue ::EOFError, Rex::ConnectionError, ::Timeout::Error
186-
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
185+
rescue ::EOFError, Rex::ConnectionError, ::Timeout::Error => e
186+
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, proof: e)
187187
end
188188

189189
Result.new(result_opts)

lib/metasploit/framework/login_scanner/http.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class HTTP
4747
# (see Base#check_setup)
4848
def check_setup
4949
http_client = Rex::Proto::Http::Client.new(
50-
host, port, {}, ssl, ssl_version
50+
host, port, {}, ssl, ssl_version, proxies
5151
)
5252
request = http_client.request_cgi(
5353
'uri' => uri,
@@ -96,7 +96,7 @@ def attempt_login(credential)
9696

9797
http_client = Rex::Proto::Http::Client.new(
9898
host, port, {}, ssl, ssl_version,
99-
nil, credential.public, credential.private
99+
proxies, credential.public, credential.private
100100
)
101101

102102
http_client = config_client(http_client)
@@ -116,8 +116,8 @@ def attempt_login(credential)
116116
if response && response.code == 200
117117
result_opts.merge!(status: Metasploit::Model::Login::Status::SUCCESSFUL, proof: response.headers)
118118
end
119-
rescue ::EOFError, Errno::ETIMEDOUT, Rex::ConnectionError, ::Timeout::Error
120-
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
119+
rescue ::EOFError, Errno::ETIMEDOUT, Rex::ConnectionError, ::Timeout::Error => e
120+
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, proof: e)
121121
ensure
122122
http_client.close
123123
end

lib/metasploit/framework/login_scanner/ipboard.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class IPBoard < HTTP
1010
# (see Base#attempt_login)
1111
def attempt_login(credential)
1212
http_client = Rex::Proto::Http::Client.new(
13-
host, port, {}, ssl, ssl_version
13+
host, port, {}, ssl, ssl_version, proxies
1414
)
1515

1616
http_client = config_client(http_client)
@@ -75,8 +75,8 @@ def attempt_login(credential)
7575
else
7676
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, proof: "Server nonce not present, potentially not an IP Board install or bad URI.")
7777
end
78-
rescue ::EOFError, Rex::ConnectionError, ::Timeout::Error
79-
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
78+
rescue ::EOFError, Rex::ConnectionError, ::Timeout::Error => e
79+
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, proof: e)
8080
end
8181

8282
Result.new(result_opts)

lib/metasploit/framework/login_scanner/jenkins.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def attempt_login(credential)
3333
result_opts[:service_name] = 'http'
3434
end
3535
begin
36-
cli = Rex::Proto::Http::Client.new(host, port, {}, ssl, ssl_version)
36+
cli = Rex::Proto::Http::Client.new(host, port, {}, ssl, ssl_version, proxies)
3737
cli.connect
3838
req = cli.request_cgi({
3939
'method'=>'POST',
@@ -49,8 +49,8 @@ def attempt_login(credential)
4949
else
5050
result_opts.merge!(status: Metasploit::Model::Login::Status::INCORRECT, proof: res)
5151
end
52-
rescue ::EOFError, Errno::ETIMEDOUT, Rex::ConnectionError, ::Timeout::Error
53-
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT)
52+
rescue ::EOFError, Errno::ETIMEDOUT, Rex::ConnectionError, ::Timeout::Error => e
53+
result_opts.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, proof: e)
5454
end
5555
Result.new(result_opts)
5656
end

lib/metasploit/framework/login_scanner/mysql.rb

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,40 +46,30 @@ def attempt_login(credential)
4646
:db => ''
4747
})
4848

49-
rescue Rex::HostUnreachable
49+
rescue ::SystemCallError, Rex::ConnectionError => e
5050
result_options.merge!({
5151
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
52-
proof: "Host was unreachable"
52+
proof: e
5353
})
54-
rescue Errno::ECONNREFUSED, Rex::ConnectionRefused
54+
rescue RbMysql::ClientError => e
5555
result_options.merge!({
5656
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
57-
proof: "Connection refused"
57+
proof: e
5858
})
59-
rescue RbMysql::ClientError
59+
rescue RbMysql::HostNotPrivileged => e
6060
result_options.merge!({
6161
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
62-
proof: "Connection timeout"
62+
proof: e
6363
})
64-
rescue Errno::ETIMEDOUT, Rex::ConnectionTimeout
65-
result_options.merge!({
66-
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
67-
proof: "Operation Timed out"
68-
})
69-
rescue RbMysql::HostNotPrivileged
70-
result_options.merge!({
71-
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
72-
proof: "Unable to login from this host due to policy"
73-
})
74-
rescue RbMysql::AccessDeniedError
64+
rescue RbMysql::AccessDeniedError => e
7565
result_options.merge!({
7666
status: Metasploit::Model::Login::Status::INCORRECT,
77-
proof: "Access Denied"
67+
proof: e
7868
})
79-
rescue RbMysql::HostIsBlocked
69+
rescue RbMysql::HostIsBlocked => e
8070
result_options.merge!({
8171
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
82-
proof: "Host blocked"
72+
proof: e
8373
})
8474
end
8575

@@ -103,4 +93,4 @@ def set_sane_defaults
10393

10494
end
10595
end
106-
end
96+
end

lib/metasploit/framework/login_scanner/pop3.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def attempt_login(credential)
6363

6464
rescue Rex::ConnectionError, EOFError, Timeout::Error, Errno::EPIPE => e
6565
result_options.merge!(
66-
proof: e.message,
66+
proof: e,
6767
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
6868
)
6969
end

lib/metasploit/framework/login_scanner/postgres.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def attempt_login(credential)
6060
proof: e.message
6161
})
6262
end
63-
rescue Rex::ConnectionError, EOFError, Timeout::Error
64-
result_options.merge!({status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT })
63+
rescue Rex::ConnectionError, EOFError, Timeout::Error => e
64+
result_options.merge!(status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, proof: e)
6565
end
6666

6767
if pg_conn

lib/metasploit/framework/login_scanner/result.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Result
2121
# @return [Fixnum] the port number of the service for this result
2222
attr_accessor :port
2323
# @!attribute proof
24-
# @return [String,nil] the proof that the login was successful
24+
# @return [#to_s] the proof of the login's success or failure
2525
attr_accessor :proof
2626
# @!attribute protocol
2727
# @return [String] the transport protocol used for this result (tcp/udp)

0 commit comments

Comments
 (0)