Skip to content

Commit aba25cb

Browse files
committed
Make RPC creds work again
1 parent 6e39c5b commit aba25cb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

lib/msf/core/rpc/v10/rpc_db.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,42 @@ def rpc_invalidate_login(xopts)
140140
invalidate_login(opts)
141141
end
142142

143+
def rpc_creds(xopts)
144+
::ActiveRecord::Base.connection_pool.with_connection {
145+
ret = {}
146+
ret[:creds] = []
147+
opts, wspace = init_db_opts_workspace(xopts)
148+
limit = opts.delete(:limit) || 100
149+
offset = opts.delete(:offset) || 0
150+
query = Metasploit::Credential::Core.where(
151+
workspace_id: wspace
152+
).offset(offset).limit(limit)
153+
query.each do |cred|
154+
host = ''
155+
port = 0
156+
proto = ''
157+
sname = ''
158+
unless cred.logins.empty?
159+
login = cred.logins.first
160+
host = login.service.host.address.to_s
161+
sname = login.service.name.to_s if login.service.name.present?
162+
port = login.service.port.to_i
163+
proto = login.service.proto.to_s
164+
end
165+
ret[:creds] << {
166+
:user => cred.public.username.to_s,
167+
:pass => cred.private.data.to_s,
168+
:updated_at => cred.private.updated_at.to_i,
169+
:type => cred.private.type.to_s,
170+
:host => host,
171+
:port => port,
172+
:proto => proto,
173+
:sname => sname}
174+
end
175+
ret
176+
}
177+
end
178+
143179
def rpc_hosts(xopts)
144180
::ActiveRecord::Base.connection_pool.with_connection {
145181
opts, wspace = init_db_opts_workspace(xopts)

0 commit comments

Comments
 (0)