Skip to content

Commit d292cc9

Browse files
committed
Round 8 of documentation
1 parent 86a7e36 commit d292cc9

File tree

1 file changed

+86
-1
lines changed

1 file changed

+86
-1
lines changed

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

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,30 @@ def rpc_get_service(xopts)
754754
}
755755
end
756756

757+
758+
# Returns a note.
759+
#
760+
# @param [Hash] xopts Options.
761+
# @option xopts [String] :proto Protocol.
762+
# @option xopts [Fixnum] :port Port.
763+
# @option xopts [String] :ntype Note type.
764+
# @raise [Msf::RPC::ServerException] You might get one of these errors:
765+
# * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
766+
# * 500 Database not loaded. Try: rpc.call('console.create')
767+
# * 500 Invalid workspace.
768+
# @return [Hash] A hash that contains the following:
769+
# * 'note' [Array<Hash>] Each hash in the array contains the following:
770+
# * 'host' [String] Host.
771+
# * 'port' [Fixnum] Port.
772+
# * 'proto' [String] Protocol.
773+
# * 'created_at' [Fixnum] Last created at.
774+
# * 'updated_at' [Fixnum] Last updated at.
775+
# * 'ntype' [String] Note type.
776+
# * 'data' [String] Note data.
777+
# * 'critical' [String] A boolean indicating criticality.
778+
# * 'seen' [String] A boolean indicating whether the note has been seen before.
779+
# @example Here's how you would use this from the client:
780+
# rpc.call('db.get_note', {:proto => 'tcp', :port => 80})
757781
def rpc_get_note(xopts)
758782
::ActiveRecord::Base.connection_pool.with_connection {
759783
opts, wspace = init_db_opts_workspace(xopts)
@@ -806,6 +830,27 @@ def rpc_get_note(xopts)
806830
}
807831
end
808832

833+
834+
# Returns information about a client connection.
835+
#
836+
# @param [Hash] xopts Options:
837+
# @option xopts [String] :workspace Workspace name.
838+
# @option xopts [String] :ua_string User agent string.
839+
# @option xopts [String] :host Host IP.
840+
# @raise [Msf::RPC::ServerException] You might get one of these errors:
841+
# * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
842+
# * 500 Database not loaded. Try: rpc.call('console.create')
843+
# * 500 Invalid workspace.
844+
# @return [Hash] A hash that contains the client connection:
845+
# * 'client' [Array<Hash>] Each hash of the array contains the following:
846+
# * 'host' [String] Host IP.
847+
# * 'created_at' [Fixnum] Created date.
848+
# * 'updated_at' [Fixnum] Last updated at.
849+
# * 'ua_string' [String] User-Agent string.
850+
# * 'ua_name' [String] User-Agent name.
851+
# * 'ua_ver' [String] User-Agent version.
852+
# @example Here's how you would use this from the client:
853+
# rpc.call('db.get_client', {:workspace=>'default', :ua_string=>user_agent, :host=>ip})
809854
def rpc_get_client(xopts)
810855
::ActiveRecord::Base.connection_pool.with_connection {
811856
opts, wspace = init_db_opts_workspace(xopts)
@@ -827,6 +872,24 @@ def rpc_get_client(xopts)
827872
}
828873
end
829874

875+
876+
# Reports a client connection.
877+
#
878+
# @param [Hash] xopts Information about the client.
879+
# @option xopts [String] :ua_string Required. User-Agent string.
880+
# @option xopts [String] :host Required. Host IP.
881+
# @option xopts [String] :ua_name One of the Msf::HttpClients constants. (See Msf::HttpClient Documentation.)
882+
# @option xopts [String] :ua_ver Detected version of the given client.
883+
# @option xopts [String] An id or Campaign object.
884+
# @see https://github.com/rapid7/metasploit-framework/blob/master/lib/msf/core/constants.rb#L52 Msf::HttpClient Documentation.
885+
# @raise [Msf::RPC::ServerException] You might get one of these errors:
886+
# * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
887+
# * 500 Database not loaded. Try: rpc.call('console.create')
888+
# * 500 Invalid workspace.
889+
# @return [Hash] A hash indicating whether the action was successful or not. It contains:
890+
# * 'result' [String] A message that says either 'success' or 'failed'.
891+
# @example Here's how you would use this from the client:
892+
# rpc.call('db.report_client', {:workspace=>'default', :ua_string=>user_agent, :host=>ip})
830893
def rpc_report_client(xopts)
831894
::ActiveRecord::Base.connection_pool.with_connection {
832895
opts, wspace = init_db_opts_workspace(xopts)
@@ -836,7 +899,29 @@ def rpc_report_client(xopts)
836899
}
837900
end
838901

839-
#DOC NOTE: :data and :ntype are REQUIRED
902+
903+
# Reports a note.
904+
#
905+
# @param [Hash] xopts Information about the note.
906+
# @option xopts [String] :type Required. The type of note, e.g. smb_peer_os.
907+
# @option xopts [String] :workspace The workspace to associate with this note.
908+
# @option xopts [String] :host An IP address or a Host object to associate with this note.
909+
# @option xopts [String] :service A Service object to associate with this note.
910+
# @option xopts [String] :data Whatever it is you're making a note of.
911+
# @option xopts [Fixnum] :port Along with +:host+ and +:proto+, a service to associate with this note.
912+
# @option xopts [String] :proto Along with +:host+ and +:port+, a service to associate with this note.
913+
# @option xopts [Hash] A hash that contains the following information.
914+
# * :unique [Boolean] Allow only a single Note per +:host+/+:type+ pair.
915+
# * :unique_data [Boolean] Like +:uniqe+, but also compare +:data+.
916+
# * :insert [Boolean] Always insert a new Note even if one with identical values exists.
917+
# @raise [Msf::RPC::ServerException] You might get one of these errors:
918+
# * 500 ActiveRecord::ConnectionNotEstablished. Try: rpc.call('console.create').
919+
# * 500 Database not loaded. Try: rpc.call('console.create')
920+
# * 500 Invalid workspace.
921+
# @return [Hash] A hash indicating whether the action was successful or not. It contains:
922+
# * 'result' [String] A message that says either 'success' or 'failed'.
923+
# @example Here's how you would use this from the client:
924+
# rpc.call('db.report_note', {:type=>'http_data', :host=>'192.168.1.123', :data=>'data'})
840925
def rpc_report_note(xopts)
841926
::ActiveRecord::Base.connection_pool.with_connection {
842927
opts, wspace = init_db_opts_workspace(xopts)

0 commit comments

Comments
 (0)