Skip to content

Commit d79f4fb

Browse files
committed
Update cisco_firepower_spec
1 parent 9983a7d commit d79f4fb

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,68 @@
1+
require 'spec_helper'
12
require 'metasploit/framework/login_scanner/cisco_firepower'
23

34
RSpec.describe Metasploit::Framework::LoginScanner::CiscoFirepower do
45

56
it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false
67
it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
78

9+
subject do
10+
described_class.new
11+
end
12+
13+
let(:successful_auth_response) do
14+
res = Rex::Proto::Http::Response.new(302, 'Found')
15+
res.headers['Location'] = '/'
16+
res.headers['Set-Cookie'] = 'CGISESSID=NEWSESSIONID;'
17+
res
18+
end
19+
20+
let(:fail_auth_response) do
21+
Rex::Proto::Http::Response.new(200, 'OK')
22+
end
23+
24+
describe '#attempt_login' do
25+
26+
context 'when the credential is valid' do
27+
let(:username) { 'user' }
28+
let(:password) { 'goddpass' }
29+
30+
before do
31+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:request_cgi).with(any_args)
32+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:send_recv).with(any_args).and_return(successful_auth_response)
33+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:set_config).with(any_args)
34+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:close)
35+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect)
36+
end
37+
38+
it 'returns a Result object indicating a successful login' do
39+
cred = Metasploit::Framework::Credential.new(public: username, private: password)
40+
result = subject.attempt_login(cred)
41+
expect(result).to be_kind_of(Metasploit::Framework::LoginScanner::Result)
42+
expect(result.status).to eq(Metasploit::Model::Login::Status::SUCCESSFUL)
43+
end
44+
end
45+
46+
context 'when the credential is invalid' do
47+
let(:username) { 'admin' }
48+
let(:password) { 'badpass' }
49+
50+
before(:example) do
51+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:request_cgi).with(any_args)
52+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:send_recv).with(any_args).and_return(fail_auth_response)
53+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:set_config).with(any_args)
54+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:close)
55+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect)
56+
end
57+
58+
it 'returns a Result object indicating a failed login' do
59+
cred = Metasploit::Framework::Credential.new(public: username, private: password)
60+
result = subject.attempt_login(cred)
61+
expect(result).to be_kind_of(Metasploit::Framework::LoginScanner::Result)
62+
expect(result.status).to eq(Metasploit::Model::Login::Status::INCORRECT)
63+
end
64+
end
65+
end
66+
67+
868
end

0 commit comments

Comments
 (0)