Skip to content

Commit b5e6465

Browse files
committed
Adding db.add_host() and workspace
- Adding add_host() Although Report host exists, this is a straightforward method to metasploit-credential::creation::add_host() - Add workspace.id to the responses of db.current_workspace and db.workspace and db.get_workspace
1 parent b0e388f commit b5e6465

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ def rpc_workspaces
285285
res[:workspaces] = []
286286
self.framework.db.workspaces.each do |j|
287287
ws = {}
288+
ws[:id] = j.id
288289
ws[:name] = j.name
289290
ws[:created_at] = j.created_at.to_i
290291
ws[:updated_at] = j.updated_at.to_i
@@ -295,7 +296,7 @@ def rpc_workspaces
295296

296297
def rpc_current_workspace
297298
db_check
298-
{ "workspace" => self.framework.db.workspace.name }
299+
{ "workspace" => self.framework.db.workspace.name, "workspace_id" => self.framework.db.workspace.id }
299300
end
300301

301302
def rpc_get_workspace(wspace)
@@ -306,6 +307,7 @@ def rpc_get_workspace(wspace)
306307
if(wspace)
307308
w = {}
308309
w[:name] = wspace.name
310+
w[:id] = wspace.id
309311
w[:created_at] = wspace.created_at.to_i
310312
w[:updated_at] = wspace.updated_at.to_i
311313
ret[:workspace] << w
@@ -354,6 +356,15 @@ def rpc_add_workspace(wspace)
354356
}
355357
end
356358

359+
def rpc_add_host(xopts)
360+
::ActiveRecord::Base.connection_pool.with_connection {
361+
opts, wspace = init_db_opts_workspace(xopts)
362+
host = self.framework.db.add_host(opts)
363+
return { 'result' => 'success' } if(host)
364+
{ 'result' => 'failed' }
365+
}
366+
end
367+
357368
def rpc_get_host(xopts)
358369
::ActiveRecord::Base.connection_pool.with_connection {
359370
opts, wspace = init_db_opts_workspace(xopts)

0 commit comments

Comments
 (0)