|
142 | 142 | end
|
143 | 143 |
|
144 | 144 | it 'returns status Metasploit::Model::Login::Status::SUCCESSFUL for a valid credential' do
|
145 |
| - http_scanner.try_glassfish_2(cred)[:status].should eq(Metasploit::Model::Login::Status::SUCCESSFUL) |
| 145 | + expect(http_scanner.try_glassfish_2(cred)[:status]).to eq(Metasploit::Model::Login::Status::SUCCESSFUL) |
146 | 146 | end
|
147 | 147 |
|
148 | 148 | it 'returns Metasploit::Model::Login::Status::INCORRECT for an invalid credential' do
|
149 |
| - http_scanner.try_glassfish_2(bad_cred)[:status].should eq(Metasploit::Model::Login::Status::INCORRECT) |
| 149 | + expect(http_scanner.try_glassfish_2(bad_cred)[:status]).to eq(Metasploit::Model::Login::Status::INCORRECT) |
150 | 150 | end
|
151 | 151 | end
|
152 | 152 |
|
|
188 | 188 | end
|
189 | 189 |
|
190 | 190 | it 'returns status Metasploit::Model::Login::Status::SUCCESSFUL for a valid credential' do
|
191 |
| - http_scanner.try_glassfish_3(cred)[:status].should eq(Metasploit::Model::Login::Status::SUCCESSFUL) |
| 191 | + expect(http_scanner.try_glassfish_3(cred)[:status]).to eq(Metasploit::Model::Login::Status::SUCCESSFUL) |
192 | 192 | end
|
193 | 193 |
|
194 | 194 | it 'returns status Metasploit::Model::Login::Status::SUCCESSFUL based on a disabled remote admin message' do
|
195 |
| - http_scanner.try_glassfish_3(disabled_cred)[:status].should eq(Metasploit::Model::Login::Status::SUCCESSFUL) |
| 195 | + expect(http_scanner.try_glassfish_3(disabled_cred)[:status]).to eq(Metasploit::Model::Login::Status::SUCCESSFUL) |
196 | 196 | end
|
197 | 197 |
|
198 | 198 | it 'returns status Metasploit::Model::Login::Status::INCORRECT for an invalid credential' do
|
199 |
| - http_scanner.try_glassfish_3(bad_cred)[:status].should eq(Metasploit::Model::Login::Status::INCORRECT) |
| 199 | + expect(http_scanner.try_glassfish_3(bad_cred)[:status]).to eq(Metasploit::Model::Login::Status::INCORRECT) |
200 | 200 | end
|
201 | 201 | end
|
202 | 202 |
|
|
229 | 229 | end
|
230 | 230 | end
|
231 | 231 |
|
| 232 | + context 'when Glassfish version 2' do |
| 233 | + let(:login_ok_message) do |
| 234 | + '<title>Deploy Enterprise Applications/Modules</title>' |
| 235 | + end |
| 236 | + |
| 237 | + it 'returns a Metasploit::Framework::LoginScanner::Result' do |
| 238 | + allow_any_instance_of(Rex::Proto::Http::Client).to receive(:send_recv) do |cli, req| |
| 239 | + if req.opts['uri'] && req.opts['uri'].include?('j_security_check') && |
| 240 | + req.opts['data'] && |
| 241 | + req.opts['data'].include?("j_username=#{username}") && |
| 242 | + req. opts['data'].include?("j_password=#{password}") |
| 243 | + res = Rex::Proto::Http::Response.new(302) |
| 244 | + res.headers['Location'] = '/applications/upload.jsf' |
| 245 | + res.headers['Set-Cookie'] = 'JSESSIONID=GOODSESSIONID' |
| 246 | + res |
| 247 | + elsif req.opts['uri'] && req.opts['uri'].include?('j_security_check') |
| 248 | + res = Rex::Proto::Http::Response.new(200) |
| 249 | + res.body = 'bad login' |
| 250 | + elsif req.opts['uri'] && |
| 251 | + req.opts['uri'].include?('/applications/upload.jsf') |
| 252 | + res = Rex::Proto::Http::Response.new(200) |
| 253 | + res.body = '<title>Deploy Enterprise Applications/Modules</title>' |
| 254 | + else |
| 255 | + res = Rex::Proto::Http::Response.new(404) |
| 256 | + end |
| 257 | + |
| 258 | + res |
| 259 | + end |
| 260 | + |
| 261 | + expect(http_scanner.attempt_login(cred)).to be_kind_of(Metasploit::Framework::LoginScanner::Result) |
| 262 | + end |
| 263 | + end |
| 264 | + |
| 265 | + context 'when Glassfish version 3' do |
| 266 | + let(:login_ok_message) do |
| 267 | + '<title>Deploy Enterprise Applications/Modules</title>' |
| 268 | + end |
| 269 | + |
| 270 | + |
| 271 | + it 'returns a Metasploit::Framework::LoginScanner::Result' do |
| 272 | + allow_any_instance_of(Rex::Proto::Http::Client).to receive(:send_recv) do |cli, req| |
| 273 | + if req.opts['uri'] && req.opts['uri'].include?('j_security_check') && |
| 274 | + req.opts['data'] && |
| 275 | + req.opts['data'].include?("j_username=#{username}") && |
| 276 | + req. opts['data'].include?("j_password=#{password}") |
| 277 | + res = Rex::Proto::Http::Response.new(302) |
| 278 | + res.headers['Location'] = '/common/applications/uploadFrame.jsf' |
| 279 | + res.headers['Set-Cookie'] = 'JSESSIONID=GOODSESSIONID' |
| 280 | + res |
| 281 | + elsif req.opts['uri'] && req.opts['uri'].include?('j_security_check') && |
| 282 | + req.opts['data'] && |
| 283 | + req.opts['data'].include?("j_username=#{username_disabled}") && |
| 284 | + req. opts['data'].include?("j_password=#{password_disabled}") |
| 285 | + res = Rex::Proto::Http::Response.new(200) |
| 286 | + res.body = 'Secure Admin must be enabled' |
| 287 | + elsif req.opts['uri'] && req.opts['uri'].include?('j_security_check') |
| 288 | + res = Rex::Proto::Http::Response.new(200) |
| 289 | + res.body = 'bad login' |
| 290 | + elsif req.opts['uri'] && |
| 291 | + req.opts['uri'].include?('/common/applications/uploadFrame.jsf') |
| 292 | + res = Rex::Proto::Http::Response.new(200) |
| 293 | + res.body = '<title>Deploy Applications or Modules' |
| 294 | + else |
| 295 | + res = Rex::Proto::Http::Response.new(404) |
| 296 | + end |
| 297 | + |
| 298 | + res |
| 299 | + end |
| 300 | + |
| 301 | + expect(http_scanner.attempt_login(cred)).to be_kind_of(Metasploit::Framework::LoginScanner::Result) |
| 302 | + end |
| 303 | + end |
232 | 304 | end
|
233 | 305 |
|
234 | 306 | end
|
|
0 commit comments