File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,42 @@ def rpc_invalidate_login(xopts)
140
140
invalidate_login ( opts )
141
141
end
142
142
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
+
143
179
def rpc_hosts ( xopts )
144
180
::ActiveRecord ::Base . connection_pool . with_connection {
145
181
opts , wspace = init_db_opts_workspace ( xopts )
You can’t perform that action at this time.
0 commit comments