Skip to content

Commit 39f206b

Browse files
committed
Round 2 of documentation
1 parent 4add407 commit 39f206b

File tree

4 files changed

+152
-3
lines changed

4 files changed

+152
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def login(user,pass)
5757
# Calls an API.
5858
#
5959
# @param [String] meth The RPC API to call.
60-
# @param [Array] args The arguments to pass.
60+
# @param [Array<string>] args The arguments to pass.
6161
# @raise [RuntimeError] Something is wrong while calling the remote API, including:
6262
# * A missing token (your client needs to authenticate).
6363
# * A unexpected response from the server, such as a timeout or unexpected HTTP code.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def rpc_logout(token)
8282
# Returns a list of authentication tokens.
8383
#
8484
# @return [Hash] A hash that contains a list of authentication tokens.
85-
# * 'tokens' [Array] An array of tokens.
85+
# * 'tokens' [Array<string>] An array of tokens.
8686
# @example Here's how you would use this from the client:
8787
# # This returns something like:
8888
# # {"tokens"=>["TEMPf5I4Ec8cBEKVD8D7xtIbTXWoKapP", "TEMPtcVmMld8w74zo0CYeosM3iXW0nJz"]}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def rpc_list
1818
res
1919
end
2020

21-
# Returns a job.
21+
# Stops a job.
2222
#
2323
# @param [Fixnum] jid Job ID.
2424
# @raise [Msf::RPC::Exception] A 500 response indicating an invalid job ID was given.

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

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,86 @@ module Msf
44
module RPC
55
class RPC_Module < RPC_Base
66

7+
# Returns a list of exploit names.
8+
#
9+
# @return [Hash] A list of exploit names.
10+
# * 'modules' [Array] Exploit names, for example: ['windows/wins/ms04_045_wins']
11+
# @example Here's how you would use this from the client:
12+
# rpc.call('module.exploits')
713
def rpc_exploits
814
{ "modules" => self.framework.exploits.keys }
915
end
1016

17+
18+
# Returns a list of auxiliary module names.
19+
#
20+
# @return [Hash] A list of auxiliary module names.
21+
# * 'modules' [Array] Auxiliary module names, for example: ['vsploit/pii/web_pii']
22+
# @example Here's how you would use this from the client:
23+
# rpc.call('module.auxiliary')
1124
def rpc_auxiliary
1225
{ "modules" => self.framework.auxiliary.keys }
1326
end
1427

28+
29+
# Returns a list of payload module names.
30+
#
31+
# @return [Hash] A list of payload module names.
32+
# * 'modules' [Array] Payload module names, for example: ['windows/x64/shell_reverse_tcp']
33+
# @example Here's how you would use this from the client:
34+
# rpc.call('module.payloads')
1535
def rpc_payloads
1636
{ "modules" => self.framework.payloads.keys }
1737
end
1838

39+
40+
# Returns a list of encoder module names.
41+
#
42+
# @return [Hash] A list of encoder module names.
43+
# * 'modules' [Array] Encoder module names, for example: ['x86/unicode_upper']
44+
# @example Here's how you would use this from the client:
45+
# rpc.call('module.encoders')
1946
def rpc_encoders
2047
{ "modules" => self.framework.encoders.keys }
2148
end
2249

50+
51+
# Returns a list of NOP module names.
52+
#
53+
# @return [Hash] A list of NOP module names.
54+
# * 'modules' [Array] NOP module names, for example: ['x86/single_byte']
55+
# @example Here's how you would use this from the client:
56+
# rpc.call('module.nops')
2357
def rpc_nops
2458
{ "modules" => self.framework.nops.keys }
2559
end
2660

61+
62+
# Returns a list of post module names.
63+
#
64+
# @return [Hash] A list of post module names.
65+
# * 'modules' [Array] Post module names, for example: ['windows/wlan/wlan_profile']
66+
# @example Here's how you would use this from the client:
67+
# rpc.call('module.post')
2768
def rpc_post
2869
{ "modules" => self.framework.post.keys }
2970
end
3071

72+
73+
# Returns the metadata of the module.
74+
#
75+
# @param [String] mtype Module type. Supported types include (case-sensitive):
76+
# * exploit
77+
# * auxiliary
78+
# * post
79+
# * nop
80+
# * payload
81+
# @param [String] mname Module name. For example: 'windows/wlan/wlan_profile'.
82+
# @raise [Msf::RPC::Exception] Module not found (either the wrong type or name).
83+
# @return [Hash] The module's metadata.
84+
# @example Here's how you would use this from the client:
85+
# # This gives us the metadata of ms08_067_netapi
86+
# rpc.call('module.info', 'exploit', 'windows/smb/ms08_067_netapi')
3187
def rpc_info(mtype, mname)
3288
m = _find_module(mtype,mname)
3389
res = {}
@@ -74,6 +130,14 @@ def rpc_info(mtype, mname)
74130
end
75131

76132

133+
# Returns the compatible payloads for a specific exploit.
134+
#
135+
# @param [String] mname Exploit module name. For example: 'windows/smb/ms08_067_netapi'.
136+
# @raise [Msf::RPC::Exception] Module not found (wrong name).
137+
# @return [Hash] The exploit's compatible payloads.
138+
# * 'payloads' [Array<string>] A list of payloads. For example: ['generic/custom']
139+
# @example Here's how you would use this from the client:
140+
# rpc.call('module.compatible_payloads', 'windows/smb/ms08_067_netapi')
77141
def rpc_compatible_payloads(mname)
78142
m = _find_module('exploit',mname)
79143
res = {}
@@ -85,6 +149,15 @@ def rpc_compatible_payloads(mname)
85149
res
86150
end
87151

152+
153+
# Returns the compatible sessions for a specific post module.
154+
#
155+
# @param [String] mname Post module name. For example: 'windows/wlan/wlan_profile'.
156+
# @raise [Msf::RPC::Exception] Module not found (wrong name).
157+
# @return [Hash] The post module's compatible sessions.
158+
# * 'sessions' [Array<Fixnum>] A list of session IDs.
159+
# @example Here's how you would use this from the client:
160+
# rpc.call('module.compatible_sessions', 'windows/wlan/wlan_profile')
88161
def rpc_compatible_sessions(mname)
89162
m = _find_module('post',mname)
90163
res = {}
@@ -93,6 +166,17 @@ def rpc_compatible_sessions(mname)
93166
res
94167
end
95168

169+
170+
# Returns the compatible target-specific payloads for an exploit.
171+
#
172+
# @param [String] mname Exploit module name. For example: 'windows/smb/ms08_067_netapi'
173+
# @param [Fixnum] target A specific target the exploit module provides.
174+
# @raise [Msf::RPC::Exception] Module not found (wrong name).
175+
# @return [Hash] The exploit's target-specific payloads.
176+
# * 'payloads' [Array<string>] A list of payloads.
177+
# @example Here's how you would use this from the client:
178+
# # Find all the compatible payloads for target 1 (Windows 2000 Universal)
179+
# rpc.call('module.target_compatible_payloads', 'windows/smb/ms08_067_netapi', 1)
96180
def rpc_target_compatible_payloads(mname, target)
97181
m = _find_module('exploit',mname)
98182
res = {}
@@ -105,6 +189,21 @@ def rpc_target_compatible_payloads(mname, target)
105189
res
106190
end
107191

192+
193+
# Returns the module's datastore options.
194+
#
195+
# @param [String] mtype Module type. Supported types include (case-sensitive):
196+
# * exploit
197+
# * auxiliary
198+
# * post
199+
# * nop
200+
# * payload
201+
# @param [String] mname Module name. For example: 'windows/wlan/wlan_profile'.
202+
# @raise [Msf::RPC::Exception] Module not found (either wrong type or name).
203+
# @return [Hash] The module's datastore options. This will actually give you each option's
204+
# data type, requirement state, basic/advanced type, description, default value, etc.
205+
# @example Here's how you would use this from the client:
206+
# rpc.call('module.options', 'exploit', 'windows/smb/ms08_067_netapi')
108207
def rpc_options(mtype, mname)
109208
m = _find_module(mtype,mname)
110209
res = {}
@@ -131,6 +230,24 @@ def rpc_options(mtype, mname)
131230
res
132231
end
133232

233+
234+
# Executes a module.
235+
#
236+
# @param [String] mtype Module type. Supported types include (case-sensitive):
237+
# * exploit
238+
# * auxiliary
239+
# * post
240+
# * payload
241+
# @param [String] mname Module name. For example: 'windows/smb/ms08_067_netapi'.
242+
# @param [Hash] opts Options for the module (such as datastore options).
243+
# @raise [Msf::RPC::Exception] Module not found (either wrong type or name).
244+
# @return [Hash]
245+
# * 'job_id' [Fixnum] Job ID.
246+
# * 'uuid' [String] UUID.
247+
# @example Here's how you would use this from the client:
248+
# # Starts a windows/meterpreter/reverse_tcp on port 6669
249+
# opts = {'LHOST' => '0.0.0.0', 'LPORT'=>6669, 'PAYLOAD'=>'windows/meterpreter/reverse_tcp'}
250+
# rpc.call('module.execute', 'exploit', 'multi/handler', opts)
134251
def rpc_execute(mtype, mname, opts)
135252
mod = _find_module(mtype,mname)
136253
case mtype
@@ -146,11 +263,43 @@ def rpc_execute(mtype, mname, opts)
146263

147264
end
148265

266+
267+
# Returns a list of encoding formats.
268+
#
269+
# @return [Array] Encoding foramts.
270+
# @example Here's how you would use this from the client:
271+
# rpc.call('module.encode_formats')
149272
def rpc_encode_formats
150273
# Supported formats
151274
Msf::Simple::Buffer.transform_formats + Msf::Util::EXE.to_executable_fmt_formats
152275
end
153276

277+
278+
# Encoders data with an encoder.
279+
#
280+
# @param [String] data Data to encode.
281+
# @param [encoder] encoder Encoder module name. For example: 'x86/single_byte'.
282+
# @param [Hash] options Encoding options, such as:
283+
# * 'format' [String] Encoding format.
284+
# * 'badchars' [String] Bad characters.
285+
# * 'platform' [String] Platform.
286+
# * 'arch' [String] Architecture.
287+
# * 'ecount' [Fixnum] Number of times to encode.
288+
# * 'inject' [TrueClass] To enable injection.
289+
# * 'template' [String] The template file (an executable).
290+
# * 'template_path' [String] Template path.
291+
# * 'addshellcode' [String] Custom shellcode.
292+
# @raise [Msf::RPC::Exception] Invalid format (Error 500).
293+
# @raise [Msf::RPC::Exception] Failure to encode (Error 500).
294+
# @return The encoded data
295+
# * 'encoded' [String] The encoded data in the format you specify.
296+
# @example Here's how you would use this from the client:
297+
# # This will encode 'AAAA' with shikata_ga_nai, and prints the following:
298+
# # unsigned char buf[] =
299+
# # "\xba\x9e\xb5\x91\x66\xdb\xd2\xd9\x74\x24\xf4\x5f\x29\xc9\xb1"
300+
# # "\x01\x31\x57\x15\x03\x57\x15\x83\xc7\x04\xe2\x6b\xf4\xd0\x27";
301+
# result = rpc.call('module.encode', 'AAAA', 'x86/shikata_ga_nai', {'format'=>'c'})
302+
# puts result['encoded']
154303
def rpc_encode(data, encoder, options)
155304
# Load supported formats
156305
supported_formats = Msf::Simple::Buffer.transform_formats + Msf::Util::EXE.to_executable_fmt_formats

0 commit comments

Comments
 (0)