Skip to content

Commit 0c4e53c

Browse files
David MaloneyDavid Maloney
authored andcommitted
fix up specs
a whole bunch of spec changes needed for these changes. alos the axis2 spec was actually testing the winrm class due to copypasta error.
1 parent c7b3774 commit 0c4e53c

File tree

17 files changed

+33
-25
lines changed

17 files changed

+33
-25
lines changed

lib/metasploit/framework/login_scanner/axis2.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def attempt_login(credential)
2020
host, port, {}, ssl, ssl_version
2121
)
2222

23+
result_opts = {
24+
credential: credential
25+
}
2326
begin
2427
http_client.connect
2528
body = "userName=#{Rex::Text.uri_encode(credential.public)}&password=#{Rex::Text.uri_encode(credential.private)}&submit=+Login+"
@@ -29,13 +32,18 @@ def attempt_login(credential)
2932
'data' => body,
3033
)
3134
response = http_client.send_recv(request)
32-
end
3335

34-
if response && response.code == 200 && response.body.include?("upload")
35-
Result.new(status: :success, credential: credential, proof: response)
36-
else
37-
Result.new(status: :failed, credential: credential, proof: response)
36+
if response && response.code == 200 && response.body.include?("upload")
37+
result_opts.merge!(status: :success, proof: response)
38+
else
39+
result_opts.merge!(status: :failed, proof: response)
40+
end
41+
rescue ::EOFError, Rex::ConnectionError, ::Timeout::Error
42+
result_opts.merge!(status: :connection_error)
3843
end
44+
45+
Result.new(result_opts)
46+
3947
end
4048

4149
# (see Base#set_sane_defaults)

lib/metasploit/framework/login_scanner/base.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ def scan!
137137

138138
if result.success?
139139
consecutive_error_count = 0
140-
break if stop_on_success
140+
return nil if stop_on_success
141141
else
142142
if result.status == :connection_error
143143
consecutive_error_count += 1
144144
total_error_count += 1
145-
break if consecutive_error_count >= 3
146-
break if total_error_count >= 10
145+
return nil if consecutive_error_count >= 3
146+
return nil if total_error_count >= 10
147147
end
148148
end
149149
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
subject(:scanner) { described_class.new }
88

9-
it_behaves_like 'Metasploit::Framework::LoginScanner::Base'
9+
it_behaves_like 'Metasploit::Framework::LoginScanner::Base', false
1010
it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
1111

1212
it { should respond_to :login_timeout }

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
require 'spec_helper'
3-
require 'metasploit/framework/login_scanner/winrm'
3+
require 'metasploit/framework/login_scanner/axis2'
44

5-
describe Metasploit::Framework::LoginScanner::WinRM do
5+
describe Metasploit::Framework::LoginScanner::Axis2 do
66

7-
it_behaves_like 'Metasploit::Framework::LoginScanner::Base'
7+
it_behaves_like 'Metasploit::Framework::LoginScanner::Base', false
88
it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
99
it_behaves_like 'Metasploit::Framework::LoginScanner::HTTP'
1010

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
subject(:login_scanner) { described_class.new }
1111

12-
it_behaves_like 'Metasploit::Framework::LoginScanner::Base'
12+
it_behaves_like 'Metasploit::Framework::LoginScanner::Base', true
1313
it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
1414

1515
context '#attempt_login' do

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
described_class.new
4646
}
4747

48-
it_behaves_like 'Metasploit::Framework::LoginScanner::Base'
48+
it_behaves_like 'Metasploit::Framework::LoginScanner::Base', false
4949
it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
5050

5151

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
describe Metasploit::Framework::LoginScanner::HTTP do
66

7-
it_behaves_like 'Metasploit::Framework::LoginScanner::Base'
7+
it_behaves_like 'Metasploit::Framework::LoginScanner::Base', false
88
it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
99
it_behaves_like 'Metasploit::Framework::LoginScanner::HTTP'
1010

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
subject(:login_scanner) { described_class.new }
3434

35-
it_behaves_like 'Metasploit::Framework::LoginScanner::Base'
35+
it_behaves_like 'Metasploit::Framework::LoginScanner::Base', true
3636
it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
3737
it_behaves_like 'Metasploit::Framework::LoginScanner::NTLM'
3838

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
subject(:login_scanner) { described_class.new }
3232

33-
it_behaves_like 'Metasploit::Framework::LoginScanner::Base'
33+
it_behaves_like 'Metasploit::Framework::LoginScanner::Base', false
3434
it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
3535

3636
context '#attempt_login' do

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
describe Metasploit::Framework::LoginScanner::POP3 do
55
subject(:scanner) { described_class.new }
66

7-
it_behaves_like 'Metasploit::Framework::LoginScanner::Base'
7+
it_behaves_like 'Metasploit::Framework::LoginScanner::Base', false
88
it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
99

1010
context "#attempt_login" do

0 commit comments

Comments
 (0)