Skip to content

Commit cbac6d1

Browse files
committed
Round 5 of documentation
1 parent f6bd747 commit cbac6d1

File tree

9 files changed

+106
-51
lines changed

9 files changed

+106
-51
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ def login(user,pass)
6464
# * A missing token (your client needs to authenticate).
6565
# * A unexpected response from the server, such as a timeout or unexpected HTTP code.
6666
# @raise [Msf::RPC::ServerException] The RPC service returns an error.
67-
# @return [Hash] The API response.
67+
# @return [Hash] The API response. It contains the following keys:
68+
# * 'version' [String] Framework version.
69+
# * 'ruby' [String] Ruby version.
70+
# * 'api' [String] API version.
6871
# @example
6972
# # This will return something like this:
7073
# # {"version"=>"4.11.0-dev", "ruby"=>"2.1.5 x86_64-darwin14.0 2014-11-13", "api"=>"1.0"}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class RPC_Auth < RPC_Base
1717
# @param [String] pass The password.
1818
# @raise [Msf::RPC::Exception] Something is wrong while authenticating, you can possibly get:
1919
# * 401 Failed authentication.
20-
# @return [Hash] A hash indicating a successful login.
20+
# @return [Hash] A hash indicating a successful login, it contains the following keys:
2121
# * 'result' [String] A successful message: 'success'.
2222
# * 'token' [String] A token for the authentication.
2323
# @example Here's how you would use this from the client:
@@ -61,7 +61,7 @@ def rpc_login_noauth(user,pass)
6161
# @raise [Msf::RPC::Exception] An error indicating a failed deauthentication, including:
6262
# * 500 Invalid authentication token.
6363
# * 500 Permanent authentication token.
64-
# @return [Hash] A hash indiciating the action was successful.
64+
# @return [Hash] A hash indiciating the action was successful. It contains the following key:
6565
# * 'result' [String] The successful message: 'success'
6666
# @example Here's how you would use this from the client:
6767
# # This returns something like:
@@ -81,7 +81,7 @@ def rpc_logout(token)
8181

8282
# Returns a list of authentication tokens.
8383
#
84-
# @return [Hash] A hash that contains a list of authentication tokens.
84+
# @return [Hash] A hash that contains a list of authentication tokens. It contains the following key:
8585
# * 'tokens' [Array<string>] An array of tokens.
8686
# @example Here's how you would use this from the client:
8787
# # This returns something like:
@@ -104,7 +104,7 @@ def rpc_token_list
104104
# Adds a new token to the database.
105105
#
106106
# @param [String] token A unique token.
107-
# @return [Hash] A hash indicating the action was successful.
107+
# @return [Hash] A hash indicating the action was successful. It contains the following key:
108108
# * 'result' [String] The successful message: 'success'
109109
# @example Here's how you would use this from the client:
110110
# rpc.call('auth.token_add', 'UNIQUE_TOKEN')
@@ -131,6 +131,7 @@ def rpc_token_add(token)
131131
# Generates a unique token, and automatically saved to the database.
132132
#
133133
# @return [Hash] A hash indicating the action was successful, also the new token.
134+
# It contains the following keys:
134135
# * 'result' [String] The successful message: 'success'
135136
# * 'token' [String] A new token.
136137
# @example Here's how you would use this from the client:
@@ -160,7 +161,7 @@ def rpc_token_generate
160161
# Removes a token from the database.
161162
#
162163
# @param [String] token The token to delete.
163-
# @return [Hash] A hash indicating the action was successful.
164+
# @return [Hash] A hash indicating the action was successful. It contains the following key:
164165
# * 'result' [String] The successful message: 'success'
165166
# @example Here's how you would use this from the client:
166167
# rpc.call('auth.token_remove', 'TEMPtcVmMld8w74zo0CYeosM3iXW0nJz')

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def initialize(*args)
1818
# Creates a new framework console.
1919
#
2020
# @param [Hash] opts See Msf::Ui::Web::Driver#create_console
21-
# @return [Hash] Information about the new console, such as:
21+
# @return [Hash] Information about the new console. It contains the following keys:
2222
# * 'id' [Fixnum] The console's ID.
2323
# * 'prompt' [String] The framework prompt (example: 'msf > ')
2424
# * 'busy' [TrueClass] The console's busy state, or
@@ -38,7 +38,7 @@ def rpc_create(opts={})
3838
# Returns a list of framework consoles.
3939
#
4040
# @return [Hash] Console information.
41-
# * 'consoles' [Array<Hash>] consoles, each element is another hash that includes:
41+
# * 'consoles' [Array<Hash>] consoles, each element is a hash that includes:
4242
# * 'id' [Fixnum] The console's ID
4343
# * 'prompt' [String] The framework prompt (example: 'msf > ')
4444
# * 'busy' [TrueClass] The console's busy state, or
@@ -62,7 +62,8 @@ def rpc_list
6262
#
6363
# @param [Fixnum] cid Framework console ID.
6464
# @return [Hash] A result indicating whether the action was successful or not.
65-
# * 'result' [String] Either 'success' or 'failure'.
65+
# It contains the following key:
66+
# * 'result' [String] Either 'success' or 'failure'.
6667
# @example Here's how you would use this from the client:
6768
# rpc.call('console.destroy', 1)
6869
def rpc_destroy(cid)

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def rpc_getg(var)
4646
#
4747
# @param [String] var The hash key of the global datastore option.
4848
# @param [String] val The value of the global datastore option.
49-
# @return [Hash] A hash indicating the action was successful.
49+
# @return [Hash] A hash indicating the action was successful. It contains the following key:
5050
# * 'result' [String] The successful message: 'success'
5151
# @example Here's how you would use this from the client:
5252
# rpc.call('core.setg', 'MyGlobal', 'foobar')
@@ -59,7 +59,7 @@ def rpc_setg(var, val)
5959
# Unsets a global datastore option.
6060
#
6161
# @param [String] var The global datastore option.
62-
# @return [Hash] A hash indicating the action was successful.
62+
# @return [Hash] A hash indicating the action was successful. It contains the following key:
6363
# * 'result' [String] The successful message: 'success'
6464
# @example Here's how you would use this from the client:
6565
# rpc.call('core.unsetg', 'MyGlobal')
@@ -71,7 +71,7 @@ def rpc_unsetg(var)
7171

7272
# Saves current framework settings.
7373
#
74-
# @return [Hash] A hash indicating the action was successful.
74+
# @return [Hash] A hash indicating the action was successful. It contains the following key:
7575
# * 'result' [String] The successful message: 'success'
7676
# @example Here's how you would use this from the client:
7777
# rpc.call('core.save')
@@ -83,7 +83,7 @@ def rpc_save
8383

8484
# Reloads framework modules. This will take some time to complete.
8585
#
86-
# @return [Hash] Module stats:
86+
# @return [Hash] Module stats that contain the following keys:
8787
# * 'exploits' [Fixnum] The number of exploits reloaded.
8888
# * 'auxiliary' [Fixnum] The number of auxiliary modules reloaded.
8989
# * 'post' [Fixnum] The number of post modules reloaded.
@@ -101,7 +101,7 @@ def rpc_reload_modules
101101
# Adds a new module path.
102102
#
103103
# @param [String] path The new path to load.
104-
# @return [Hash] Module stats:
104+
# @return [Hash] Module stats that contain the following keys:
105105
# * 'exploits' [Fixnum] The number of exploits loaded.
106106
# * 'auxiliary' [Fixnum] The number of auxiliary modules loaded.
107107
# * 'post' [Fixnum] The number of post modules loaded.
@@ -118,7 +118,7 @@ def rpc_add_module_path(path)
118118

119119
# Returns the module stats.
120120
#
121-
# @return [Hash] Module stats:
121+
# @return [Hash] Module stats that contain the following keys:
122122
# * 'exploits' [Fixnum] The number of exploits.
123123
# * 'auxiliary' [Fixnum] The number of auxiliary modules.
124124
# * 'post' [Fixnum] The number of post modules.
@@ -140,7 +140,12 @@ def rpc_module_stats
140140

141141
# Returns a list of framework threads.
142142
#
143-
# @return [Hash] A collection of threads such as: 'status', 'critical', 'name', 'started'
143+
# @return [Hash] A collection of threads. Each key is the thread ID, and the value is another hash
144+
# that contains the following:
145+
# * 'status' [String] Thread status.
146+
# * 'critical' [Boolean] Thread is critical.
147+
# * 'name' [String] Thread name.
148+
# * 'started' [String] Timestamp of when the thread started.
144149
# @example Here's how you would use this from the cient:
145150
# # You will get something like this:
146151
# # {0=>{"status"=>"sleep", "critical"=>false, "name"=>"StreamServerListener", "started"=>"2015-04-21 15:25:49 -0500"}}
@@ -163,7 +168,7 @@ def rpc_thread_list
163168
# Kills a framework thread.
164169
#
165170
# @param [Fixnum] tid The thread ID to kill.
166-
# @return [Hash] A hash indicating the action was successful.
171+
# @return [Hash] A hash indicating the action was successful. It contains the following key:
167172
# * 'result' [String] A successful message: 'success'
168173
# @example Here's how you would use this from the client:
169174
# rpc.call('core.thread_kill', 10)

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

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def rpc_create_cracked_credential(xopts)
140140
# Creates a credential.
141141
#
142142
# @param [Hash] xopts Credential options. (See #create_credential Documentation)
143-
# @return [Hash] Credential data.
143+
# @return [Hash] Credential data. It contains the following keys:
144144
# * :username [String] Username saved.
145145
# * :private [String] Password saved.
146146
# * :private_type [String] Password type.
@@ -211,6 +211,23 @@ def rpc_invalidate_login(xopts)
211211
invalidate_login(opts)
212212
end
213213

214+
215+
# Returns login credentials from a specific workspace.
216+
#
217+
# @param [Hash] xopts Options.
218+
# @option xopts [String] :workspace Name of the workspace.
219+
# @return [Hash] Credentials with the following hash key:
220+
# * '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.
229+
# @example Here's how you would use this from the client:
230+
# rpc.call('db.creds', {})
214231
def rpc_creds(xopts)
215232
::ActiveRecord::Base.connection_pool.with_connection {
216233
ret = {}
@@ -247,6 +264,27 @@ def rpc_creds(xopts)
247264
}
248265
end
249266

267+
268+
# Returns information about hosts.
269+
#
270+
# @param [Hash] xopts Options.
271+
# @option xopts [String] :workspace Name of the workspace.
272+
# @return [Hash] Host information that starts with the following hash key:
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.
286+
# @example Here's how you would use this from the client:
287+
# rpc.call('db.hosts', {})
250288
def rpc_hosts(xopts)
251289
::ActiveRecord::Base.connection_pool.with_connection {
252290
opts, wspace = init_db_opts_workspace(xopts)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ class RPC_Job < RPC_Base
55

66
# Returns a list of jobs.
77
#
8-
# @return [Hash] A list of jobs (IDs and names)
8+
# @return [Hash] A list of jobs (IDs and names).
9+
# Each key is the job ID, and each value is the job name.
910
# @example Here's how you would use this from the client:
1011
# # This will return ('0' is the job ID):
1112
# # {"0"=>"Exploit: windows/browser/ms14_064_ole_code_execution"
@@ -22,7 +23,7 @@ def rpc_list
2223
#
2324
# @param [Fixnum] jid Job ID.
2425
# @raise [Msf::RPC::Exception] A 500 response indicating an invalid job ID was given.
25-
# @return [Hash] A hash indicating the action was successful.
26+
# @return [Hash] A hash indicating the action was successful. It contains the following key:
2627
# * 'result' [String] A successful message: 'success'
2728
# @example Here's how you would use this from the client:
2829
# rpc.call('job.stop', 0)
@@ -37,7 +38,7 @@ def rpc_stop(jid)
3738
#
3839
# @param [Fixnum] jid Job ID.
3940
# @raise [Msf::RPC::Exception] A 500 response indicating an invalid job ID was given.
40-
# @return [Hash] A hash that contains information about the job, such as the following (and maybe more)
41+
# @return [Hash] A hash that contains information about the job, such as the following (and maybe more):
4142
# * 'jid' [Fixnum] The Job ID.
4243
# * 'name' [String] The name of the job.
4344
# * 'start_time' [Fixnum] The start time.

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class RPC_Module < RPC_Base
66

77
# Returns a list of exploit names.
88
#
9-
# @return [Hash] A list of exploit names.
9+
# @return [Hash] A list of exploit names. It contains the following key:
1010
# * 'modules' [Array<string>] Exploit names, for example: ['windows/wins/ms04_045_wins']
1111
# @example Here's how you would use this from the client:
1212
# rpc.call('module.exploits')
@@ -17,7 +17,7 @@ def rpc_exploits
1717

1818
# Returns a list of auxiliary module names.
1919
#
20-
# @return [Hash] A list of auxiliary module names.
20+
# @return [Hash] A list of auxiliary module names. It contains the following key:
2121
# * 'modules' [Array<string>] Auxiliary module names, for example: ['vsploit/pii/web_pii']
2222
# @example Here's how you would use this from the client:
2323
# rpc.call('module.auxiliary')
@@ -28,7 +28,7 @@ def rpc_auxiliary
2828

2929
# Returns a list of payload module names.
3030
#
31-
# @return [Hash] A list of payload module names.
31+
# @return [Hash] A list of payload module names. It contains the following key:
3232
# * 'modules' [Array<string>] Payload module names, for example: ['windows/x64/shell_reverse_tcp']
3333
# @example Here's how you would use this from the client:
3434
# rpc.call('module.payloads')
@@ -39,7 +39,7 @@ def rpc_payloads
3939

4040
# Returns a list of encoder module names.
4141
#
42-
# @return [Hash] A list of encoder module names.
42+
# @return [Hash] A list of encoder module names. It contains the following key:
4343
# * 'modules' [Array<string>] Encoder module names, for example: ['x86/unicode_upper']
4444
# @example Here's how you would use this from the client:
4545
# rpc.call('module.encoders')
@@ -50,7 +50,7 @@ def rpc_encoders
5050

5151
# Returns a list of NOP module names.
5252
#
53-
# @return [Hash] A list of NOP module names.
53+
# @return [Hash] A list of NOP module names. It contains the following key:
5454
# * 'modules' [Array<string>] NOP module names, for example: ['x86/single_byte']
5555
# @example Here's how you would use this from the client:
5656
# rpc.call('module.nops')
@@ -61,7 +61,7 @@ def rpc_nops
6161

6262
# Returns a list of post module names.
6363
#
64-
# @return [Hash] A list of post module names.
64+
# @return [Hash] A list of post module names. It contains the following key:
6565
# * 'modules' [Array<string>] Post module names, for example: ['windows/wlan/wlan_profile']
6666
# @example Here's how you would use this from the client:
6767
# rpc.call('module.post')
@@ -80,7 +80,7 @@ def rpc_post
8080
# * payload
8181
# @param [String] mname Module name. For example: 'windows/wlan/wlan_profile'.
8282
# @raise [Msf::RPC::Exception] Module not found (either the wrong type or name).
83-
# @return [Hash] The module's metadata.
83+
# @return [Hash] The module's metadata. The exact keys you will get depends on the module.
8484
# @example Here's how you would use this from the client:
8585
# # This gives us the metadata of ms08_067_netapi
8686
# rpc.call('module.info', 'exploit', 'windows/smb/ms08_067_netapi')
@@ -134,7 +134,7 @@ def rpc_info(mtype, mname)
134134
#
135135
# @param [String] mname Exploit module name. For example: 'windows/smb/ms08_067_netapi'.
136136
# @raise [Msf::RPC::Exception] Module not found (wrong name).
137-
# @return [Hash] The exploit's compatible payloads.
137+
# @return [Hash] The exploit's compatible payloads. It contains the following key:
138138
# * 'payloads' [Array<string>] A list of payloads. For example: ['generic/custom']
139139
# @example Here's how you would use this from the client:
140140
# rpc.call('module.compatible_payloads', 'windows/smb/ms08_067_netapi')
@@ -154,7 +154,7 @@ def rpc_compatible_payloads(mname)
154154
#
155155
# @param [String] mname Post module name. For example: 'windows/wlan/wlan_profile'.
156156
# @raise [Msf::RPC::Exception] Module not found (wrong name).
157-
# @return [Hash] The post module's compatible sessions.
157+
# @return [Hash] The post module's compatible sessions. It contains the following key:
158158
# * 'sessions' [Array<Fixnum>] A list of session IDs.
159159
# @example Here's how you would use this from the client:
160160
# rpc.call('module.compatible_sessions', 'windows/wlan/wlan_profile')
@@ -172,7 +172,7 @@ def rpc_compatible_sessions(mname)
172172
# @param [String] mname Exploit module name. For example: 'windows/smb/ms08_067_netapi'
173173
# @param [Fixnum] target A specific target the exploit module provides.
174174
# @raise [Msf::RPC::Exception] Module not found (wrong name).
175-
# @return [Hash] The exploit's target-specific payloads.
175+
# @return [Hash] The exploit's target-specific payloads. It contains the following key:
176176
# * 'payloads' [Array<string>] A list of payloads.
177177
# @example Here's how you would use this from the client:
178178
# # Find all the compatible payloads for target 1 (Windows 2000 Universal)
@@ -241,7 +241,7 @@ def rpc_options(mtype, mname)
241241
# @param [String] mname Module name. For example: 'windows/smb/ms08_067_netapi'.
242242
# @param [Hash] opts Options for the module (such as datastore options).
243243
# @raise [Msf::RPC::Exception] Module not found (either wrong type or name).
244-
# @return [Hash]
244+
# @return [Hash] It contains the following keys:
245245
# * 'job_id' [Fixnum] Job ID.
246246
# * 'uuid' [String] UUID.
247247
# @example Here's how you would use this from the client:
@@ -292,7 +292,7 @@ def rpc_encode_formats
292292
# @raise [Msf::RPC::Exception] Error could be one of these:
293293
# * 500 Invalid format
294294
# * 500 Failure to encode
295-
# @return The encoded data
295+
# @return The encoded data. It contains the following key:
296296
# * 'encoded' [String] The encoded data in the format you specify.
297297
# @example Here's how you would use this from the client:
298298
# # This will encode 'AAAA' with shikata_ga_nai, and prints the following:

0 commit comments

Comments
 (0)