@@ -214,7 +214,7 @@ def rpc_invalidate_login(xopts)
214
214
215
215
# Returns login credentials from a specific workspace.
216
216
#
217
- # @param [Hash] xopts Options.
217
+ # @param [Hash] xopts Options:
218
218
# @option xopts [String] :workspace Name of the workspace.
219
219
# @return [Hash] Credentials with the following hash key:
220
220
# * 'creds' [Array<Hash>] An array of credentials. Each hash in the array will have the following:
@@ -267,22 +267,22 @@ def rpc_creds(xopts)
267
267
268
268
# Returns information about hosts.
269
269
#
270
- # @param [Hash] xopts Options.
270
+ # @param [Hash] xopts Options:
271
271
# @option xopts [String] :workspace Name of the workspace.
272
272
# @return [Hash] Host information that starts with the following hash key:
273
273
# * '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.
286
286
# @example Here's how you would use this from the client:
287
287
# rpc.call('db.hosts', {})
288
288
def rpc_hosts ( xopts )
@@ -318,6 +318,29 @@ def rpc_hosts(xopts)
318
318
}
319
319
end
320
320
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')
321
344
def rpc_services ( xopts )
322
345
::ActiveRecord ::Base . connection_pool . with_connection {
323
346
opts , wspace = init_db_opts_workspace ( xopts )
@@ -351,6 +374,26 @@ def rpc_services( xopts)
351
374
}
352
375
end
353
376
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', {})
354
397
def rpc_vulns ( xopts )
355
398
::ActiveRecord ::Base . connection_pool . with_connection {
356
399
opts , wspace = init_db_opts_workspace ( xopts )
@@ -385,6 +428,18 @@ def rpc_vulns(xopts)
385
428
}
386
429
end
387
430
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')
388
443
def rpc_workspaces
389
444
db_check
390
445
@@ -401,11 +456,35 @@ def rpc_workspaces
401
456
res
402
457
end
403
458
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')
404
468
def rpc_current_workspace
405
469
db_check
406
470
{ "workspace" => self . framework . db . workspace . name , "workspace_id" => self . framework . db . workspace . id }
407
471
end
408
472
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')
409
488
def rpc_get_workspace ( wspace )
410
489
db_check
411
490
wspace = find_workspace ( wspace )
@@ -422,6 +501,17 @@ def rpc_get_workspace(wspace)
422
501
ret
423
502
end
424
503
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')
425
515
def rpc_set_workspace ( wspace )
426
516
::ActiveRecord ::Base . connection_pool . with_connection {
427
517
db_check
0 commit comments