File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed
lib/metasploit/framework/login_scanner
spec/lib/metasploit/framework/login_scanner Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,6 @@ def check_setup
34
34
# * :status [Metasploit::Model::Login::Status]
35
35
# * :proof [String] the HTTP response body
36
36
def get_login_state ( username , password )
37
- # Prep the data needed for login
38
- #protocol = ssl ? 'https' : 'http'
39
- #peer = "#{host}:#{port}"
40
37
login_uri = "#{ uri } "
41
38
42
39
res = send_request ( {
@@ -83,6 +80,13 @@ def attempt_login(credential)
83
80
Result . new ( result_opts )
84
81
end
85
82
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
+
86
90
end
87
91
end
88
92
end
Original file line number Diff line number Diff line change 21
21
end
22
22
23
23
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
25
27
end
26
28
27
29
let ( :fail_auth_response ) do
63
65
64
66
describe '#get_login_state' do
65
67
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 )
67
70
end
68
71
69
72
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 )
71
81
end
72
82
73
83
context 'when the credential is valid' do
You can’t perform that action at this time.
0 commit comments