|
3 | 3 |
|
4 | 4 | describe Metasploit::Framework::LoginScanner::Nessus do
|
5 | 5 |
|
| 6 | + subject(:http_scanner) { described_class.new } |
| 7 | + |
6 | 8 | it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false
|
7 | 9 | it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
|
8 | 10 |
|
|
26 | 28 | Rex::Proto::Http::Response.new(401, 'Unauthorized')
|
27 | 29 | end
|
28 | 30 |
|
29 |
| - subject do |
30 |
| - described_class.new |
31 |
| - end |
32 |
| - |
33 | 31 | let(:response) do
|
34 | 32 | Rex::Proto::Http::Response.new(200, 'OK')
|
35 | 33 | end
|
|
52 | 50 | context 'when target is Nessus' do
|
53 | 51 | let(:response) { msp_html_response }
|
54 | 52 | it 'returns true' do
|
55 |
| - expect(subject.check_setup).to be_truthy |
| 53 | + expect(http_scanner.check_setup).to be_truthy |
56 | 54 | end
|
57 | 55 | end
|
58 | 56 |
|
59 | 57 | context 'when target is not Nessus' do
|
60 | 58 | it 'returns false' do
|
61 |
| - expect(subject.check_setup).to be_falsey |
| 59 | + expect(http_scanner.check_setup).to be_falsey |
62 | 60 | end
|
63 | 61 | end
|
64 | 62 | end
|
|
76 | 74 | let(:response) { successful_auth_response }
|
77 | 75 | it 'returns a hash indicating a successful login' do
|
78 | 76 | successful_status = Metasploit::Model::Login::Status::SUCCESSFUL
|
79 |
| - expect(subject.get_login_state(username, good_password)[:status]).to eq(successful_status) |
| 77 | + expect(http_scanner.get_login_state(username, good_password)[:status]).to eq(successful_status) |
80 | 78 | end
|
81 | 79 | end
|
82 | 80 |
|
83 | 81 | context 'when the creential is invalid' do
|
84 | 82 | let(:response) { fail_auth_response }
|
85 | 83 | it 'returns a hash indicating an incorrect cred' do
|
86 | 84 | incorrect_status = Metasploit::Model::Login::Status::INCORRECT
|
87 |
| - expect(subject.get_login_state(username, good_password)[:status]).to eq(incorrect_status) |
| 85 | + expect(http_scanner.get_login_state(username, good_password)[:status]).to eq(incorrect_status) |
88 | 86 | end
|
89 | 87 | end
|
90 | 88 | end
|
|
95 | 93 |
|
96 | 94 | it 'returns a Result object indicating a successful login' do
|
97 | 95 | cred_obj = Metasploit::Framework::Credential.new(public: username, private: good_password)
|
98 |
| - result = subject.attempt_login(cred_obj) |
| 96 | + result = http_scanner.attempt_login(cred_obj) |
99 | 97 | expect(result).to be_kind_of(::Metasploit::Framework::LoginScanner::Result)
|
100 | 98 | expect(result.status).to eq(Metasploit::Model::Login::Status::SUCCESSFUL)
|
101 | 99 | end
|
|
105 | 103 | let(:response) { fail_auth_response }
|
106 | 104 | it 'returns a Result object indicating an incorrect cred' do
|
107 | 105 | cred_obj = Metasploit::Framework::Credential.new(public: username, private: bad_password)
|
108 |
| - result = subject.attempt_login(cred_obj) |
| 106 | + result = http_scanner.attempt_login(cred_obj) |
109 | 107 | expect(result).to be_kind_of(::Metasploit::Framework::LoginScanner::Result)
|
110 | 108 | expect(result.status).to eq(Metasploit::Model::Login::Status::INCORRECT)
|
111 | 109 | end
|
|
0 commit comments