Skip to content

Commit f6ae1f4

Browse files
committed
Merge branch 'upstream/master' into android-java-transport-refactor
2 parents a773979 + 15f9fc5 commit f6ae1f4

File tree

3 files changed

+116
-14
lines changed

3 files changed

+116
-14
lines changed

lib/msf/core/auxiliary/fuzzer.rb

Lines changed: 107 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ module Msf
88
###
99
module Auxiliary::Fuzzer
1010

11-
#
12-
# Creates an instance of a fuzzer module
13-
#
11+
1412
def initialize(info = {})
1513
super
1614
register_advanced_options([
@@ -20,9 +18,12 @@ def initialize(info = {})
2018
end
2119

2220

21+
# Will return or yield numbers based on the presence of a block.
2322
#
24-
# Self-reflective iterators
25-
#
23+
# @return [Array<Array>] Returns an array of arrays of numbers if there is no block given
24+
# @yield [Array<Fixnum>] Yields an array of numbers if there is a block given
25+
# @see #fuzzer_number_power2
26+
2627
def fuzz_numbers
2728
res = []
2829
self.methods.sort.grep(/^fuzzer_number/).each do |m|
@@ -32,6 +33,12 @@ def fuzz_numbers
3233
res
3334
end
3435

36+
37+
# Will return or yield a string based on the presense of a block
38+
#
39+
# @return [Array] Returns and array of arrays of strings if there is no block given
40+
# @yield [Array] Yields array of strings if there is a block given
41+
3542
def fuzz_strings
3643
res = []
3744
self.methods.sort.grep(/^fuzzer_string/).each do |m|
@@ -41,11 +48,11 @@ def fuzz_strings
4148
res
4249
end
4350

44-
#
45-
# General input mangling routines
46-
#
51+
# Modifies each byte of the string from beginning to end, packing each element as an 8 bit character.
52+
#
53+
# @returns [Array] Returns an array of an array of strings
54+
# @see #fuzzer_string_format
4755

48-
# Modify each byte of the string moving forward
4956
def fuzz_string_corrupt_byte(str,max=nil)
5057
res = []
5158
0.upto(max ? [max,str.length-1].min : (str.length - 1)) do |offset|
@@ -59,7 +66,12 @@ def fuzz_string_corrupt_byte(str,max=nil)
5966
res
6067
end
6168

62-
# Modify each byte of the string moving backward
69+
# Modifies each byte of the string from beginning to end, packing each element as an 8 bit character.
70+
#
71+
#
72+
# @returns [Array] Returns an array of an array of strings
73+
# @see fuzzer_string_format
74+
6375
def fuzz_string_corrupt_byte_reverse(str,max=nil)
6476
res = []
6577
(max ? [max,str.length-1].min : (str.length - 1)).downto(0) do |offset|
@@ -73,20 +85,29 @@ def fuzz_string_corrupt_byte_reverse(str,max=nil)
7385
res
7486
end
7587

76-
#
7788
# Useful generators (many derived from AxMan)
7889
#
90+
# @returns [Array] Returns and array of strings.
7991

8092
def fuzzer_string_format
8193
res = %W{ %s %p %n %x %@ %.257d %.65537d %.2147483648d %.257f %.65537f %.2147483648f}
8294
block_given? ? res.each { |n| yield(n) } : res
8395
end
8496

97+
# Reserved filename array
98+
# Useful generators (many derived from AxMan)
99+
#
100+
# @returns [Array] Returns and array of reserved filenames in Windows.
101+
85102
def fuzzer_string_filepath_dos
86103
res = %W{ aux con nul com1 com2 com3 com4 lpt1 lpt2 lp3 lpt4 prn }
87104
block_given? ? res.each { |n| yield(n) } : res
88105
end
89106

107+
# Fuzzer Numbers by Powers of Two
108+
#
109+
# @returns [Array] Returns an array with pre-set values
110+
90111
def fuzzer_number_power2
91112
res = [
92113
0x100000000,
@@ -105,6 +126,10 @@ def fuzzer_number_power2
105126
block_given? ? res.each { |n| yield(n) } : res
106127
end
107128

129+
# Powers of two by some fuzzing factor.
130+
#
131+
# @returns [Array] Returns and array of integers.
132+
108133
def fuzzer_number_power2_plus
109134
res = []
110135
fuzzer_number_power2 do |num|
@@ -119,6 +144,11 @@ def fuzzer_number_power2_plus
119144
block_given? ? res.each { |n| yield(n) } : res
120145
end
121146

147+
# Generates a fuzz string
148+
# If no block set, will retrive characters from the FuzzChar datastore option
149+
#
150+
# @return [String] Returns a string of size 1024 * 512 specified by the user
151+
122152
def fuzzer_gen_string(len)
123153
@gen_string_block ||= datastore['FuzzChar'][0,1] * (1024 * 512)
124154
res = ''
@@ -128,6 +158,9 @@ def fuzzer_gen_string(len)
128158
res[0,len]
129159
end
130160

161+
# Creates a smaller fuzz string starting from length 16 -> 512 bytes long
162+
#
163+
# @return [Array] Returns an array of characters
131164
def fuzzer_string_small
132165
res = []
133166
16.step(512,16) do |len|
@@ -137,6 +170,9 @@ def fuzzer_string_small
137170
res
138171
end
139172

173+
# Creates a longer fuzz string from length 64 -> 8192 bytes long
174+
#
175+
# @return [Array] Returns an array of characters
140176
def fuzzer_string_long
141177
res = []
142178
64.step(8192,64) do |len|
@@ -147,6 +183,9 @@ def fuzzer_string_long
147183
res
148184
end
149185

186+
# Creates a giant fuzz string from length 512 -> 131,064 bytes long
187+
#
188+
# @return [Array] Returns an array of characters
150189
def fuzzer_string_giant
151190
res = []
152191
512.step(65532 * 2, 512) do |len|
@@ -157,6 +196,9 @@ def fuzzer_string_giant
157196
res
158197
end
159198

199+
# Various URI types
200+
#
201+
# @returns [Array] Returns an array of strings
160202
def fuzzer_string_uri_types
161203
res = %W{
162204
aaa aaas about acap adiumxtra afp aim apt aw bolo callto cap chrome cid
@@ -174,16 +216,28 @@ def fuzzer_string_uri_types
174216
block_given? ? res.each { |n| yield(n) } : res
175217
end
176218

219+
# Generator for common URI dividers
220+
#
221+
# @return [Array] Returns an array of strings
222+
177223
def fuzzer_string_uri_dividers
178224
res = %W{ : :// }
179225
block_given? ? res.each { |n| yield(n) } : res
180226
end
181227

228+
# Generator for common path prefixes
229+
#
230+
# @return [Array] Returns an array of strings
231+
182232
def fuzzer_string_path_prefixes
183233
res = %W{ C:\\ \\\\localhost\\ / }
184234
block_given? ? res.each { |n| yield(n) } : res
185235
end
186236

237+
# Generates various small URI string types
238+
#
239+
# @return [Array] Returns an array of stings
240+
187241
def fuzzer_string_uris_small
188242
res = []
189243
fuzzer_string_uri_types do |proto|
@@ -197,6 +251,10 @@ def fuzzer_string_uris_small
197251
res
198252
end
199253

254+
# Generates various long URI string types
255+
#
256+
# @return [Array] Returns an array of stings
257+
200258
def fuzzer_string_uris_long
201259
res = []
202260
fuzzer_string_uri_types do |proto|
@@ -210,6 +268,10 @@ def fuzzer_string_uris_long
210268
res
211269
end
212270

271+
# Generates various giant URI string types
272+
#
273+
# @return [Array] Returns an array of stings
274+
213275
def fuzzer_string_uris_giant
214276
res = []
215277
fuzzer_string_uri_types do |proto|
@@ -223,6 +285,10 @@ def fuzzer_string_uris_giant
223285
res
224286
end
225287

288+
# Format for the URI string generator
289+
#
290+
# @return [Array] Returns an array of stings
291+
226292
def fuzzer_string_uris_format
227293
res = []
228294
fuzzer_string_uri_types do |proto|
@@ -236,6 +302,11 @@ def fuzzer_string_uris_format
236302
res
237303
end
238304

305+
306+
# Generates various small strings
307+
#
308+
# @return [Array] Returns an array of stings
309+
239310
def fuzzer_string_uris_dos
240311
res = []
241312
fuzzer_string_uri_types do |proto|
@@ -249,6 +320,11 @@ def fuzzer_string_uris_dos
249320
res
250321
end
251322

323+
324+
# Generates various small strings
325+
#
326+
# @return [Array] Returns an array of stings
327+
252328
def fuzzer_string_paths_small
253329
res = []
254330
fuzzer_string_path_prefixes do |pre|
@@ -260,6 +336,11 @@ def fuzzer_string_paths_small
260336
res
261337
end
262338

339+
340+
# Generates various small strings
341+
#
342+
# @return [Array] Returns an array of stings
343+
263344
def fuzzer_string_paths_long
264345
res = []
265346
fuzzer_string_path_prefixes do |pre|
@@ -271,6 +352,11 @@ def fuzzer_string_paths_long
271352
res
272353
end
273354

355+
356+
# Generates various giant strings
357+
#
358+
# @return [Array] Returns an array of stings
359+
274360
def fuzzer_string_paths_giant
275361
res = []
276362
fuzzer_string_path_prefixes do |pre|
@@ -282,6 +368,11 @@ def fuzzer_string_paths_giant
282368
res
283369
end
284370

371+
372+
# Format for the path generator
373+
#
374+
# @return [Array] Returns an array of stings
375+
285376
def fuzzer_string_paths_format
286377
res = []
287378
fuzzer_string_path_prefixes do |pre|
@@ -293,6 +384,11 @@ def fuzzer_string_paths_format
293384
res
294385
end
295386

387+
388+
# Generates fuzzer strings using path prefixes
389+
#
390+
# @return [Array] Returns an array of stings
391+
296392
def fuzzer_string_paths_dos
297393
res = []
298394
fuzzer_string_path_prefixes do |pre|

lib/msf/core/post/windows/file_info.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ def loword(num)
1313
num & 0xffff
1414
end
1515

16+
# File Version
17+
# @param [String] filepath The path of the file you are targeting
18+
#
19+
# @return [String] Returns the file version of target
20+
1621
def file_version(filepath)
1722
file_version_info_size = client.railgun.version.GetFileVersionInfoSizeA(
1823
filepath,

lib/rex/post/meterpreter/client_core.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,10 @@ def machine_id(timeout=nil)
320320

321321
# Normalise the format of the incoming machine id so that it's consistent
322322
# regardless of case and leading/trailing spaces. This means that the
323-
# individual meterpreters don't have to care
324-
mid.downcase!.strip! if mid
325-
return Rex::Text.md5(mid)
323+
# individual meterpreters don't have to care.
324+
325+
# Note that the machine ID may be blank or nil and that is OK
326+
Rex::Text.md5(mid.to_s.downcase.strip)
326327
end
327328

328329
def transport_remove(opts={})

0 commit comments

Comments
 (0)