@@ -141,14 +141,14 @@ def rpc_create_cracked_credential(xopts)
141
141
#
142
142
# @param [Hash] xopts Credential options. (See #create_credential Documentation)
143
143
# @return [Hash] Credential data. It contains the following keys:
144
- # * : username [String] Username saved.
145
- # * : private [String] Password saved.
146
- # * : private_type [String] Password type.
147
- # * : realm_value [String] Realm.
148
- # * : realm_key [String] Realm key.
149
- # * : host [String] Host (Only avilable if there's a :last_attempted_at and :status)
150
- # * : sname [String] Service name (only available if there's a :last_attempted_at and :status)
151
- # * : status [Status] Login status (only available if there's a :last_attempted_at and :status)
144
+ # * ' username' [String] Username saved.
145
+ # * ' private' [String] Password saved.
146
+ # * ' private_type' [String] Password type.
147
+ # * ' realm_value' [String] Realm.
148
+ # * ' realm_key' [String] Realm key.
149
+ # * ' host' [String] Host (Only avilable if there's a :last_attempted_at and :status)
150
+ # * ' sname' [String] Service name (only available if there's a :last_attempted_at and :status)
151
+ # * ' status' [Status] Login status (only available if there's a :last_attempted_at and :status)
152
152
# @see https://github.com/rapid7/metasploit-credential/blob/master/lib/metasploit/credential/creation.rb#L107 #create_credential Documentation.
153
153
# @example Here's how you would use this from the client:
154
154
# opts = {
@@ -216,16 +216,20 @@ def rpc_invalidate_login(xopts)
216
216
#
217
217
# @param [Hash] xopts Options:
218
218
# @option xopts [String] :workspace Name of the workspace.
219
+ # @raise [Msf::RPC::ServerException] You might get one of these errors:
220
+ # * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
221
+ # * 500 Database not loaded. Try: rpc.call('console.create')
222
+ # * 500 Invalid workspace.
219
223
# @return [Hash] Credentials with the following hash key:
220
224
# * 'creds' [Array<Hash>] An array of credentials. Each hash in the array will have the following:
221
- # * 'user' [String] Username.
222
- # * 'pass' [String] Password.
223
- # * 'updated_at' [Fixnum] Last updated at.
224
- # * 'type' [String] Password type.
225
- # * 'host' [String] Host.
226
- # * 'port' [Fixnum] Port.
227
- # * 'proto' [String] Protocol.
228
- # * 'sname' [String] Service name.
225
+ # * 'user' [String] Username.
226
+ # * 'pass' [String] Password.
227
+ # * 'updated_at' [Fixnum] Last updated at.
228
+ # * 'type' [String] Password type.
229
+ # * 'host' [String] Host.
230
+ # * 'port' [Fixnum] Port.
231
+ # * 'proto' [String] Protocol.
232
+ # * 'sname' [String] Service name.
229
233
# @example Here's how you would use this from the client:
230
234
# rpc.call('db.creds', {})
231
235
def rpc_creds ( xopts )
@@ -269,6 +273,11 @@ def rpc_creds(xopts)
269
273
#
270
274
# @param [Hash] xopts Options:
271
275
# @option xopts [String] :workspace Name of the workspace.
276
+ # @raise [Msf::RPC::ServerException] You might get one of these errors:
277
+ # * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
278
+ # * 500 Database not loaded. Try: rpc.call('console.create')
279
+ # * 500 Invalid workspace.
280
+ # You probably want to run: rpc.call('console.create').
272
281
# @return [Hash] Host information that starts with the following hash key:
273
282
# * 'hosts' [Array<Hash>] An array of hosts. Each hash in the array will have the following:
274
283
# * 'created_at' [Fixnum] Creation date.
@@ -329,8 +338,12 @@ def rpc_hosts(xopts)
329
338
# @option xopts [String] :address Address.
330
339
# @option xopts [String] :ports Port range.
331
340
# @option xopts [String] :names Names (Use ',' as the separator).
341
+ # @raise [Msf::RPC::ServerException] You might get one of these errors:
342
+ # * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
343
+ # * 500 Database not loaded. Try: rpc.call('console.create')
344
+ # * 500 Invalid workspace.
332
345
# @return [Hash] A hash with the following keys:
333
- # * : services [Array<Hash>] In each hash of the array, you will get these keys:
346
+ # * ' services' [Array<Hash>] In each hash of the array, you will get these keys:
334
347
# * 'host' [String] Host.
335
348
# * 'created_at' [Fixnum] Last created at.
336
349
# * 'updated_at' [Fixnum] Last updated at.
@@ -340,7 +353,7 @@ def rpc_hosts(xopts)
340
353
# * 'name' [String] Service name.
341
354
# * 'info' [String] Additional information about the service.
342
355
# @example Here's how you would use this from the client:
343
- # rpc.call('db.services')
356
+ # rpc.call('db.services', {} )
344
357
def rpc_services ( xopts )
345
358
::ActiveRecord ::Base . connection_pool . with_connection {
346
359
opts , wspace = init_db_opts_workspace ( xopts )
@@ -384,6 +397,10 @@ def rpc_services( xopts)
384
397
# @option xopts [String] :proto Protocol.
385
398
# @option xopts [String] :address Address.
386
399
# @option xopts [String] :ports Port range.
400
+ # @raise [Msf::RPC::ServerException] You might get one of these errors:
401
+ # * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
402
+ # * 500 Database not loaded. Try: rpc.call('console.create')
403
+ # * 500 Invalid workspace.
387
404
# @return [Hash] A hash with the following key:
388
405
# * 'vulns' [Array<Hash>] In each hash of the array, you will get these keys:
389
406
# * 'port' [Fixnum] Port.
@@ -459,7 +476,7 @@ def rpc_workspaces
459
476
460
477
# Returns the current workspace.
461
478
#
462
- # @raise [Msf::RPC::Exception] Database not loaded.
479
+ # @raise [Msf::RPC::Exception] Database not loaded. Try: rpc.call('console.create')
463
480
# @return [Hash] A hash with the following keys:
464
481
# * 'workspace' [String] Workspace name.
465
482
# * 'workspace_id' [Fixnum] Workspace ID.
@@ -505,8 +522,7 @@ def rpc_get_workspace(wspace)
505
522
# Sets a workspace.
506
523
#
507
524
# @param [String] wspace Workspace name.
508
- # @raise [Msf::RPC::Exception] You might get one of the following errors:
509
- # * 500 Database not loaded.
525
+ # @raise [Msf::RPC::Exception] 500 Database not loaded.
510
526
# @return [Hash] A hash indicating whether the action was successful or not. You will get:
511
527
# * 'result' [String] A message that says either 'success' or 'failed'
512
528
# @example Here's how you would use this from the client:
@@ -524,6 +540,18 @@ def rpc_set_workspace(wspace)
524
540
}
525
541
end
526
542
543
+
544
+ # Deletes a workspace.
545
+ #
546
+ # @param [String] wspace Workspace name.
547
+ # @raise [Msf::RPC::ServerException] You might get one of these errors:
548
+ # * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
549
+ # * 500 Database not loaded. Try: rpc.call('console.create')
550
+ # * 404 Workspace not found.
551
+ # @return [Hash] A hash indicating the action was successful. It contains the following:
552
+ # * 'result' [String] A message that says 'success'.
553
+ # @example Here's how you would use this from the client:
554
+ # rpc.call('db.wspace', 'temp_workspace')
527
555
def rpc_del_workspace ( wspace )
528
556
::ActiveRecord ::Base . connection_pool . with_connection {
529
557
db_check
@@ -544,6 +572,18 @@ def rpc_del_workspace(wspace)
544
572
}
545
573
end
546
574
575
+
576
+ # Adds a new workspace.
577
+ #
578
+ # @param [String] wspace Workspace name.
579
+ # @raise [Msf::RPC::ServerException] You might get one of these errors:
580
+ # * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
581
+ # * 500 Database not loaded. Try: rpc.call('console.create')
582
+ # * 500 Invalid workspace.
583
+ # @return [Hash] A hash indicating whether the action was successful or not. You get:
584
+ # * 'result' [String] A message that says either 'success' or 'failed'.
585
+ # @example Here's how you would use this from the client:
586
+ # * rpc.call('db.add_workspace', 'my_new_workspace')
547
587
def rpc_add_workspace ( wspace )
548
588
::ActiveRecord ::Base . connection_pool . with_connection {
549
589
db_check
@@ -553,6 +593,33 @@ def rpc_add_workspace(wspace)
553
593
}
554
594
end
555
595
596
+
597
+ # Returns information about a host.
598
+ #
599
+ # @param [Hash] xopts Options (:addr, :address, :host are the same thing, and you only need one):
600
+ # @option xopts [String] :addr Host address.
601
+ # @option xopts [String] :address Same as :addr.
602
+ # @option xopts [String] :host Same as :address.
603
+ # @raise [Msf::RPC::ServerException] You might get one of these errors:
604
+ # * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
605
+ # * 500 Database not loaded. Try: rpc.call('console.create')
606
+ # * 500 Invalid workspace.
607
+ # @return [Hash] A hash that contains the following:
608
+ # * 'host' [Array<Hash>] Each hash in the array contains the following:
609
+ # * 'created_at' [Fixnum] Last created at.
610
+ # * 'address' [String] Address.
611
+ # * 'mac' [String] Mac address.
612
+ # * 'name' [String] Host name.
613
+ # * 'state' [String] Host state.
614
+ # * 'os_name' [String] OS name.
615
+ # * 'os_flavor' [String] OS flavor.
616
+ # * 'os_sp' [String] OS service pack.
617
+ # * 'os_lang' [String] OS language.
618
+ # * 'updated_at' [Fixnum] Last updated at.
619
+ # * 'purpose' [String] Purpose. Example: 'server'.
620
+ # * 'info' [String] Additional information.
621
+ # @example Here's how you would use this from the client:
622
+ # rpc.call('db.get_host', {:host => ip})
556
623
def rpc_get_host ( xopts )
557
624
::ActiveRecord ::Base . connection_pool . with_connection {
558
625
opts , wspace = init_db_opts_workspace ( xopts )
@@ -581,6 +648,30 @@ def rpc_get_host(xopts)
581
648
}
582
649
end
583
650
651
+
652
+ # Reports a new host to the database.
653
+ #
654
+ # @param [Hash] xopts Information about the host.
655
+ # @option xopts [String] :host IP address. You msut supply this.
656
+ # @option xopts [String] :state One of the Msf::HostState constants. (See Most::HostState Documentation)
657
+ # @option xopts [String] :os_name Something like "Windows", "Linux", or "Mac OS X".
658
+ # @option xopts [String] :os_flavor Something like "Enterprise", "Pro", or "Home".
659
+ # @option xopts [String] :os_sp Something like "SP2".
660
+ # @option xopts [String] :os_lang Something like "English", "French", or "en-US".
661
+ # @option xopts [String] :arch one of the ARCH_* constants. (see ARCH Documentation)
662
+ # @option xopts [String] :mac Mac address.
663
+ # @option xopts [String] :scope Interface identifier for link-local IPv6.
664
+ # @option xopts [String] :virtual_host The name of the VM host software, eg "VMWare", "QEMU", "Xen", etc.
665
+ # @see https://github.com/rapid7/metasploit-framework/blob/master/lib/msf/core/host_state.rb Most::HostState Documentation.
666
+ # @see https://github.com/rapid7/metasploit-framework/blob/master/lib/rex/constants.rb#L66 ARCH Documentation.
667
+ # @raise [Msf::RPC::ServerException] You might get one of these errors:
668
+ # * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
669
+ # * 500 Database not loaded. Try: rpc.call('console.create')
670
+ # * 500 Invalid workspace.
671
+ # @return [Hash] A hash indicating whether the action was successful or not. It contains the following:
672
+ # * 'result' [String] A message that says either 'success' or 'failed'.
673
+ # @example Here's how you would use this from the client:
674
+ # rpc.call('db.report_host', {:host => ip})
584
675
def rpc_report_host ( xopts )
585
676
::ActiveRecord ::Base . connection_pool . with_connection {
586
677
opts , wspace = init_db_opts_workspace ( xopts )
@@ -591,6 +682,23 @@ def rpc_report_host(xopts)
591
682
}
592
683
end
593
684
685
+
686
+ # Reports a service to the database.
687
+ #
688
+ # @param [Hash] xopts Information about the service.
689
+ # @option xopts [String] :host Required. The host where this service is running.
690
+ # @option xopts [String] :port Required. The port where this service listens.
691
+ # @option xopts [String] :proto Required. The transport layer protocol (e.g. tcp, udp).
692
+ # @option xopts [String] :name The application layer protocol (e.g. ssh, mssql, smb).
693
+ # @option xopts [String] :sname An alias for the above
694
+ # @raise [Msf::RPC::ServerException] You might get one of these errors:
695
+ # * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
696
+ # * 500 Database not loaded. Try: rpc.call('console.create')
697
+ # * 500 Invalid workspace.
698
+ # @return [Hash] A hash indicating whether the action was successful or not. It contains:
699
+ # * 'result' [String] A message that says either 'success' or 'failed'.
700
+ # @example Here's how you would use this from the client:
701
+ # rpc.call('db.report_service', {:host=>ip, :port=>8181, :proto=>'tcp', :name=>'http'})
594
702
def rpc_report_service ( xopts )
595
703
::ActiveRecord ::Base . connection_pool . with_connection {
596
704
opts , wspace = init_db_opts_workspace ( xopts )
@@ -1262,6 +1370,17 @@ def rpc_connect(xopts)
1262
1370
1263
1371
end
1264
1372
1373
+
1374
+ # Returns the database status.
1375
+ #
1376
+ # @raise [Msf::RPC::ServerException] You might get one of these errors:
1377
+ # * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
1378
+ # * 500 Database not loaded. Try: rpc.call('console.create')
1379
+ # @return [Hash] A hash that contains the following keys:
1380
+ # * 'driver' [String] Name of the database driver.
1381
+ # * 'db' [String] Name of the database.
1382
+ # @example Here's how you would use this from the client:
1383
+ # rpc.call('db.status')
1265
1384
def rpc_status
1266
1385
if ( not self . framework . db . driver )
1267
1386
return { :driver => 'None' }
@@ -1283,6 +1402,11 @@ def rpc_status
1283
1402
{ :driver => 'None' }
1284
1403
end
1285
1404
1405
+
1406
+ # Disconnects the database.
1407
+ #
1408
+ # @return [Hash] A hash that indicates whether the action was successful or not. It contains:
1409
+ # 'result' [String] A message that says either 'success' or 'failed'.
1286
1410
def rpc_disconnect
1287
1411
if ( self . framework . db )
1288
1412
self . framework . db . disconnect ( )
0 commit comments