Skip to content

Commit 1691795

Browse files
committed
Land rapid7#3598 to electro-release - Refactor sso to use Credential::Creation
2 parents 594b0e1 + 6224053 commit 1691795

File tree

1 file changed

+29
-14
lines changed
  • modules/post/windows/gather/credentials

1 file changed

+29
-14
lines changed

modules/post/windows/gather/credentials/sso.rb

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,24 +101,39 @@ def report_creds(domain, user, pass)
101101
return if (user.empty? or pass.empty?)
102102
return if pass.include?("n.a.")
103103

104-
if session.db_record
105-
source_id = session.db_record.id
106-
else
107-
source_id = nil
104+
# Assemble data about the credential objects we will be creating
105+
credential_data = {
106+
origin_type: :session,
107+
post_reference_name: self.refname,
108+
private_data: pass,
109+
private_type: :password,
110+
session_id: session_db_id,
111+
username: user,
112+
workspace_id: myworkspace_id
113+
}
114+
115+
unless domain.blank?
116+
credential_data[:realm_key] = Metasploit::Model::Realm::Key::ACTIVE_DIRECTORY_DOMAIN
117+
credential_data[:realm_value] = domain
108118
end
109119

110-
report_auth_info(
111-
:host => session.session_host,
112-
:port => 445,
113-
:sname => 'smb',
114-
:proto => 'tcp',
115-
:source_id => source_id,
116-
:source_type => "exploit",
117-
:user => "#{domain}\\#{user}",
118-
:pass => pass
119-
)
120+
credential_core = create_credential(credential_data)
121+
122+
# Assemble the options hash for creating the Metasploit::Credential::Login object
123+
login_data = {
124+
core: credential_core,
125+
status: Metasploit::Model::Login::Status::UNTRIED,
126+
address: ::Rex::Socket.getaddress(session.sock.peerhost, true),
127+
port: 445,
128+
service_name: 'smb',
129+
protocol: 'tcp',
130+
workspace_id: myworkspace_id
131+
}
132+
133+
create_credential_login(login_data)
120134
end
121135

136+
122137
def is_system_user?(user)
123138
system_users = [
124139
/^$/,

0 commit comments

Comments
 (0)