Skip to content

Commit 0adc558

Browse files
author
root
committed
Merge branch 'wchen-r7-pr5112_update' into aux-scanner-nessus
2 parents 7e6461a + 19fe226 commit 0adc558

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

lib/metasploit/framework/login_scanner/nessus.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ def check_setup
3434
# * :status [Metasploit::Model::Login::Status]
3535
# * :proof [String] the HTTP response body
3636
def get_login_state(username, password)
37-
# Prep the data needed for login
38-
#protocol = ssl ? 'https' : 'http'
39-
#peer = "#{host}:#{port}"
4037
login_uri = "#{uri}"
4138

4239
res = send_request({
@@ -83,6 +80,13 @@ def attempt_login(credential)
8380
Result.new(result_opts)
8481
end
8582

83+
def set_sane_defaults
84+
super
85+
# nessus_rest_login has the same default in TARGETURI, but rspec doesn't check nessus_rest_login
86+
# so we have to set the default here, too.
87+
self.uri = '/session'
88+
end
89+
8690
end
8791
end
8892
end

spec/lib/metasploit/framework/login_scanner/nessus_spec.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
end
2222

2323
let(:successful_auth_response) do
24-
Rex::Proto::Http::Response.new(200, 'OK')
24+
res = Rex::Proto::Http::Response.new(200, 'OK')
25+
res.body = 'token'
26+
res
2527
end
2628

2729
let(:fail_auth_response) do
@@ -63,11 +65,19 @@
6365

6466
describe '#get_login_state' do
6567
it 'sends a login request to /session' do
66-
expect(http_scanner).to receive(:send_request).with(hash_including('uri'=>'/session'))
68+
allow(http_scanner).to receive(:send_request).with(hash_including('uri'=>'/session')).and_return(response)
69+
http_scanner.get_login_state(username, good_password)
6770
end
6871

6972
it 'sends a login request containing the username and password' do
70-
expect(http_scanner).to receive(:send_request).with(hash_including('data'=>"username=#{username}&password=#{password}"))
73+
expected_hash = {
74+
'vars_post' => {
75+
"username" => username,
76+
"password" => good_password
77+
}
78+
}
79+
allow(http_scanner).to receive(:send_request).with(hash_including(expected_hash)).and_return(response)
80+
http_scanner.get_login_state(username, good_password)
7181
end
7282

7383
context 'when the credential is valid' do

0 commit comments

Comments
 (0)