Skip to content

Commit bcdea05

Browse files
author
Pedro Ribeiro
committed
Merge pull request #1 from rapid7/master
Update from original
2 parents 0c9daff + b3e8987 commit bcdea05

File tree

97 files changed

+2820
-1300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2820
-1300
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ group :db do
77
# Needed for Msf::DbManager
88
gem 'activerecord', '>= 3.0.0', '< 4.0.0'
99
# Metasploit::Credential database models
10-
gem 'metasploit-credential', '>= 0.8.6', '< 0.9'
10+
gem 'metasploit-credential', '>= 0.9.0'
1111
# Database models shared between framework and Pro.
1212
gem 'metasploit_data_models', '~> 0.19'
1313
# Needed for module caching in Mdm::ModuleDetails

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PATH
77
bcrypt
88
json
99
metasploit-model (~> 0.26.1)
10-
meterpreter_bins (= 0.0.6)
10+
meterpreter_bins (= 0.0.7)
1111
msgpack
1212
nokogiri
1313
packetfu (= 1.1.9)
@@ -62,7 +62,7 @@ GEM
6262
json (1.8.1)
6363
metasploit-concern (0.1.1)
6464
activesupport (~> 3.0, >= 3.0.0)
65-
metasploit-credential (0.8.6)
65+
metasploit-credential (0.9.0)
6666
metasploit-concern (~> 0.1.0)
6767
metasploit-model (~> 0.26.1)
6868
metasploit_data_models (~> 0.19.4)
@@ -78,7 +78,7 @@ GEM
7878
metasploit-concern (~> 0.1.0)
7979
metasploit-model (~> 0.26.1)
8080
pg
81-
meterpreter_bins (0.0.6)
81+
meterpreter_bins (0.0.7)
8282
method_source (0.8.2)
8383
mini_portile (0.6.0)
8484
msgpack (0.5.8)
@@ -160,7 +160,7 @@ DEPENDENCIES
160160
factory_girl (>= 4.1.0)
161161
factory_girl_rails
162162
fivemat (= 1.2.1)
163-
metasploit-credential (>= 0.8.6, < 0.9)
163+
metasploit-credential (>= 0.9.0)
164164
metasploit-framework!
165165
metasploit_data_models (~> 0.19)
166166
network_interface (~> 0.0.1)

lib/metasploit/framework/credential.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ def to_credential
9191
self
9292
end
9393

94+
# This method takes all of the attributes of the {Credential} and spits
95+
# them out in a hash compatible with the create_credential calls.
96+
#
97+
# @return [Hash] a hash compatible with #create_credential
98+
def to_h
99+
{
100+
private_data: private,
101+
private_type: private_type,
102+
username: public,
103+
realm_key: realm_key,
104+
realm_value: realm
105+
}
106+
end
107+
94108
private
95109

96110
def at_realm

lib/metasploit/framework/credential_collection.rb

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ def each
8686

8787
if username.present?
8888
if password.present?
89-
yield Metasploit::Framework::Credential.new(public: username, private: password, realm: realm)
89+
yield Metasploit::Framework::Credential.new(public: username, private: password, realm: realm, private_type: private_type(password))
9090
end
9191
if user_as_pass
92-
yield Metasploit::Framework::Credential.new(public: username, private: username, realm: realm)
92+
yield Metasploit::Framework::Credential.new(public: username, private: username, realm: realm, private_type: :password)
9393
end
9494
if blank_passwords
95-
yield Metasploit::Framework::Credential.new(public: username, private: "", realm: realm)
95+
yield Metasploit::Framework::Credential.new(public: username, private: "", realm: realm, private_type: :password)
9696
end
9797
if pass_fd
9898
pass_fd.each_line do |pass_from_file|
9999
pass_from_file.chomp!
100-
yield Metasploit::Framework::Credential.new(public: username, private: pass_from_file, realm: realm)
100+
yield Metasploit::Framework::Credential.new(public: username, private: pass_from_file, realm: realm, private_type: private_type(pass_from_file))
101101
end
102102
pass_fd.seek(0)
103103
end
@@ -108,18 +108,18 @@ def each
108108
user_fd.each_line do |user_from_file|
109109
user_from_file.chomp!
110110
if password
111-
yield Metasploit::Framework::Credential.new(public: user_from_file, private: password, realm: realm)
111+
yield Metasploit::Framework::Credential.new(public: user_from_file, private: password, realm: realm, private_type: private_type(password) )
112112
end
113113
if user_as_pass
114-
yield Metasploit::Framework::Credential.new(public: user_from_file, private: user_from_file, realm: realm)
114+
yield Metasploit::Framework::Credential.new(public: user_from_file, private: user_from_file, realm: realm, private_type: :password)
115115
end
116116
if blank_passwords
117-
yield Metasploit::Framework::Credential.new(public: user_from_file, private: "", realm: realm)
117+
yield Metasploit::Framework::Credential.new(public: user_from_file, private: "", realm: realm, private_type: :password)
118118
end
119119
if pass_fd
120120
pass_fd.each_line do |pass_from_file|
121121
pass_from_file.chomp!
122-
yield Metasploit::Framework::Credential.new(public: user_from_file, private: pass_from_file, realm: realm)
122+
yield Metasploit::Framework::Credential.new(public: user_from_file, private: pass_from_file, realm: realm, private_type: private_type(pass_from_file))
123123
end
124124
pass_fd.seek(0)
125125
end
@@ -145,4 +145,14 @@ def each
145145
pass_fd.close if pass_fd && !pass_fd.closed?
146146
end
147147

148+
private
149+
150+
def private_type(private)
151+
if private =~ /[0-9a-f]{32}:[0-9a-f]{32}/
152+
:ntlm_hash
153+
else
154+
:password
155+
end
156+
end
157+
148158
end

lib/metasploit/framework/login_scanner/afp.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ def attempt_login(credential)
3535
status = (success == true) ? Metasploit::Model::Login::Status::SUCCESSFUL : Metasploit::Model::Login::Status::INCORRECT
3636
end
3737

38-
Result.new(credential: credential, status: status)
38+
result = Result.new(credential: credential, status: status)
39+
result.host = host
40+
result.port = port
41+
result.protocol = 'tcp'
42+
result.service_name = 'afp'
43+
result
3944
end
4045

4146
def set_sane_defaults

lib/metasploit/framework/login_scanner/axis2.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ def attempt_login(credential)
2121
)
2222

2323
result_opts = {
24-
credential: credential
24+
credential: credential,
25+
host: host,
26+
port: port,
27+
protocol: 'tcp'
2528
}
29+
if ssl
30+
result_opts[:service_name] = 'https'
31+
else
32+
result_opts[:service_name] = 'http'
33+
end
34+
2635
begin
2736
http_client.connect
2837
body = "userName=#{Rex::Text.uri_encode(credential.public)}&password=#{Rex::Text.uri_encode(credential.private)}&submit=+Login+"

lib/metasploit/framework/login_scanner/db2.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ def attempt_login(credential)
4646
})
4747
end
4848

49-
::Metasploit::Framework::LoginScanner::Result.new(result_options)
49+
result = ::Metasploit::Framework::LoginScanner::Result.new(result_options)
50+
result.host = host
51+
result.port = port
52+
result.protocol = 'tcp'
53+
result.service_name = 'db2'
54+
result
5055
end
5156

5257
private

lib/metasploit/framework/login_scanner/ftp.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ def attempt_login(credential)
5353
result_options[:status] = Metasploit::Model::Login::Status::INCORRECT
5454
end
5555

56-
::Metasploit::Framework::LoginScanner::Result.new(result_options)
57-
56+
result = ::Metasploit::Framework::LoginScanner::Result.new(result_options)
57+
result.host = host
58+
result.port = port
59+
result.protocol = 'tcp'
60+
result.service_name = 'ftp'
61+
result
5862
end
5963

6064
private

lib/metasploit/framework/login_scanner/http.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,18 @@ def attempt_login(credential)
4646
result_opts = {
4747
credential: credential,
4848
status: Metasploit::Model::Login::Status::INCORRECT,
49-
proof: nil
49+
proof: nil,
50+
host: host,
51+
port: port,
52+
protocol: 'tcp'
5053
}
5154

55+
if ssl
56+
result_opts[:service_name] = 'https'
57+
else
58+
result_opts[:service_name] = 'http'
59+
end
60+
5261
http_client = Rex::Proto::Http::Client.new(
5362
host, port, {}, ssl, ssl_version,
5463
nil, credential.public, credential.private

lib/metasploit/framework/login_scanner/mssql.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ class MSSQL
3434

3535
def attempt_login(credential)
3636
result_options = {
37-
credential: credential
37+
credential: credential,
38+
host: host,
39+
port: port,
40+
protocol: 'tcp',
41+
service_name: 'mssql'
3842
}
3943

4044
begin

0 commit comments

Comments
 (0)