Skip to content

Commit 3c50feb

Browse files
committed
Round 6 of documentation
1 parent cbac6d1 commit 3c50feb

File tree

1 file changed

+104
-14
lines changed

1 file changed

+104
-14
lines changed

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

Lines changed: 104 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def rpc_invalidate_login(xopts)
214214

215215
# Returns login credentials from a specific workspace.
216216
#
217-
# @param [Hash] xopts Options.
217+
# @param [Hash] xopts Options:
218218
# @option xopts [String] :workspace Name of the workspace.
219219
# @return [Hash] Credentials with the following hash key:
220220
# * 'creds' [Array<Hash>] An array of credentials. Each hash in the array will have the following:
@@ -267,22 +267,22 @@ def rpc_creds(xopts)
267267

268268
# Returns information about hosts.
269269
#
270-
# @param [Hash] xopts Options.
270+
# @param [Hash] xopts Options:
271271
# @option xopts [String] :workspace Name of the workspace.
272272
# @return [Hash] Host information that starts with the following hash key:
273273
# * 'hosts' [Array<Hash>] An array of hosts. Each hash in the array will have the following:
274-
# * 'created_at' [Fixnum] Creation date.
275-
# * 'address' [String] IP address.
276-
# * 'mac' [String] MAC address.
277-
# * 'name' [String] Computer name.
278-
# * 'state' [String] Host's state.
279-
# * 'os_name' [String] Name of the operating system.
280-
# * 'os_flavor' [String] OS flavor.
281-
# * 'os_sp' [String] Service pack.
282-
# * 'os_lang' [String] OS language.
283-
# * 'updated_at' [Fixnum] Last updated at.
284-
# * 'purpose' [String] Host purpose (example: server)
285-
# * 'info' [String] Additional information about the host.
274+
# * 'created_at' [Fixnum] Creation date.
275+
# * 'address' [String] IP address.
276+
# * 'mac' [String] MAC address.
277+
# * 'name' [String] Computer name.
278+
# * 'state' [String] Host's state.
279+
# * 'os_name' [String] Name of the operating system.
280+
# * 'os_flavor' [String] OS flavor.
281+
# * 'os_sp' [String] Service pack.
282+
# * 'os_lang' [String] OS language.
283+
# * 'updated_at' [Fixnum] Last updated at.
284+
# * 'purpose' [String] Host purpose (example: server)
285+
# * 'info' [String] Additional information about the host.
286286
# @example Here's how you would use this from the client:
287287
# rpc.call('db.hosts', {})
288288
def rpc_hosts(xopts)
@@ -318,6 +318,29 @@ def rpc_hosts(xopts)
318318
}
319319
end
320320

321+
322+
# Returns information about services.
323+
#
324+
# @param [Hash] xopts Options:
325+
# @option xopts [String] :workspace Name of workspace.
326+
# @option xopts [Fixnum] :limit Limit.
327+
# @option xopts [Fixnum] :offset Offset.
328+
# @option xopts [String] :proto Protocol.
329+
# @option xopts [String] :address Address.
330+
# @option xopts [String] :ports Port range.
331+
# @option xopts [String] :names Names (Use ',' as the separator).
332+
# @return [Hash] A hash with the following keys:
333+
# * :services [Array<Hash>] In each hash of the array, you will get these keys:
334+
# * 'host' [String] Host.
335+
# * 'created_at' [Fixnum] Last created at.
336+
# * 'updated_at' [Fixnum] Last updated at.
337+
# * 'port' [Fixnum] Port.
338+
# * 'proto' [String] Protocol.
339+
# * 'state' [String] Service state.
340+
# * 'name' [String] Service name.
341+
# * 'info' [String] Additional information about the service.
342+
# @example Here's how you would use this from the client:
343+
# rpc.call('db.services')
321344
def rpc_services( xopts)
322345
::ActiveRecord::Base.connection_pool.with_connection {
323346
opts, wspace = init_db_opts_workspace(xopts)
@@ -351,6 +374,26 @@ def rpc_services( xopts)
351374
}
352375
end
353376

377+
378+
# Returns information about reported vulnerabilities.
379+
#
380+
# @param [Hash] xopts Options:
381+
# @option xopts [String] :workspace Name of workspace.
382+
# @option xopts [Fixnum] :limit Limit.
383+
# @option xopts [Fixnum] :offset Offset.
384+
# @option xopts [String] :proto Protocol.
385+
# @option xopts [String] :address Address.
386+
# @option xopts [String] :ports Port range.
387+
# @return [Hash] A hash with the following key:
388+
# * 'vulns' [Array<Hash>] In each hash of the array, you will get these keys:
389+
# * 'port' [Fixnum] Port.
390+
# * 'proto' [String] Protocol.
391+
# * 'time' [Fixnum] Time reported.
392+
# * 'host' [String] Vulnerable host.
393+
# * 'name' [String] Exploit that was used.
394+
# * 'refs' [String] Vulnerability references.
395+
# @example Here's how you would use this from the client:
396+
# rpc.call('db.vulns', {})
354397
def rpc_vulns(xopts)
355398
::ActiveRecord::Base.connection_pool.with_connection {
356399
opts, wspace = init_db_opts_workspace(xopts)
@@ -385,6 +428,18 @@ def rpc_vulns(xopts)
385428
}
386429
end
387430

431+
432+
# Returns information about workspaces.
433+
#
434+
# @raise [Msf::RPC::Exception] Database not loaded.
435+
# @return [Hash] A hash with the following key:
436+
# * 'workspaces' [Array<Hash>] In each hash of the array, you will get these keys:
437+
# * 'id' [Fixnum] Workspace ID.
438+
# * 'name' [String] Workspace name.
439+
# * 'created_at' [Fixnum] Last created at.
440+
# * 'updated_at' [Fixnum] Last updated at.
441+
# @example Here's how you would use this from the client:
442+
# rpc.call('db.workspaces')
388443
def rpc_workspaces
389444
db_check
390445

@@ -401,11 +456,35 @@ def rpc_workspaces
401456
res
402457
end
403458

459+
460+
# Returns the current workspace.
461+
#
462+
# @raise [Msf::RPC::Exception] Database not loaded.
463+
# @return [Hash] A hash with the following keys:
464+
# * 'workspace' [String] Workspace name.
465+
# * 'workspace_id' [Fixnum] Workspace ID.
466+
# @example Here's how you would use this from the client:
467+
# rpc.call('db.current_workspace')
404468
def rpc_current_workspace
405469
db_check
406470
{ "workspace" => self.framework.db.workspace.name, "workspace_id" => self.framework.db.workspace.id }
407471
end
408472

473+
474+
# Returns the current workspace.
475+
#
476+
# @param [String] wspace workspace name.
477+
# @raise [Msf::RPC::Exception] You might get one of the following errors:
478+
# * 500 Database not loaded.
479+
# * 500 Invalid workspace.
480+
# @return [Hash] A hash with the following key:
481+
# * 'workspace' [Array<Hash>] In each hash of the array, you will get these keys:
482+
# * 'name' [String] Workspace name.
483+
# * 'id' [Fixnum] Workspace ID.
484+
# * 'created_at' [Fixnum] Last created at.
485+
# * 'updated_at' [Fixnum] Last updated at.
486+
# @example Here's how you would use this from the client:
487+
# rpc.call('db.get_workspace')
409488
def rpc_get_workspace(wspace)
410489
db_check
411490
wspace = find_workspace(wspace)
@@ -422,6 +501,17 @@ def rpc_get_workspace(wspace)
422501
ret
423502
end
424503

504+
505+
# Sets a workspace.
506+
#
507+
# @param [String] wspace Workspace name.
508+
# @raise [Msf::RPC::Exception] You might get one of the following errors:
509+
# * 500 Database not loaded.
510+
# @return [Hash] A hash indicating whether the action was successful or not. You will get:
511+
# * 'result' [String] A message that says either 'success' or 'failed'
512+
# @example Here's how you would use this from the client:
513+
# # This will set the current workspace to 'default'
514+
# rpc.call('db.set_workspace', 'default')
425515
def rpc_set_workspace(wspace)
426516
::ActiveRecord::Base.connection_pool.with_connection {
427517
db_check

0 commit comments

Comments
 (0)