@@ -8,9 +8,7 @@ module Msf
8
8
###
9
9
module Auxiliary ::Fuzzer
10
10
11
- #
12
- # Creates an instance of a fuzzer module
13
- #
11
+
14
12
def initialize ( info = { } )
15
13
super
16
14
register_advanced_options ( [
@@ -20,9 +18,12 @@ def initialize(info = {})
20
18
end
21
19
22
20
21
+ # Will return or yield numbers based on the presence of a block.
23
22
#
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
+
26
27
def fuzz_numbers
27
28
res = [ ]
28
29
self . methods . sort . grep ( /^fuzzer_number/ ) . each do |m |
@@ -32,6 +33,12 @@ def fuzz_numbers
32
33
res
33
34
end
34
35
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
+
35
42
def fuzz_strings
36
43
res = [ ]
37
44
self . methods . sort . grep ( /^fuzzer_string/ ) . each do |m |
@@ -41,11 +48,11 @@ def fuzz_strings
41
48
res
42
49
end
43
50
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
47
55
48
- # Modify each byte of the string moving forward
49
56
def fuzz_string_corrupt_byte ( str , max = nil )
50
57
res = [ ]
51
58
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)
59
66
res
60
67
end
61
68
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
+
63
75
def fuzz_string_corrupt_byte_reverse ( str , max = nil )
64
76
res = [ ]
65
77
( 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)
73
85
res
74
86
end
75
87
76
- #
77
88
# Useful generators (many derived from AxMan)
78
89
#
90
+ # @returns [Array] Returns and array of strings.
79
91
80
92
def fuzzer_string_format
81
93
res = %W{ %s %p %n %x %@ %.257d %.65537d %.2147483648d %.257f %.65537f %.2147483648f }
82
94
block_given? ? res . each { |n | yield ( n ) } : res
83
95
end
84
96
97
+ # Reserved filename array
98
+ # Useful generators (many derived from AxMan)
99
+ #
100
+ # @returns [Array] Returns and array of reserved filenames in Windows.
101
+
85
102
def fuzzer_string_filepath_dos
86
103
res = %W{ aux con nul com1 com2 com3 com4 lpt1 lpt2 lp3 lpt4 prn }
87
104
block_given? ? res . each { |n | yield ( n ) } : res
88
105
end
89
106
107
+ # Fuzzer Numbers by Powers of Two
108
+ #
109
+ # @returns [Array] Returns an array with pre-set values
110
+
90
111
def fuzzer_number_power2
91
112
res = [
92
113
0x100000000 ,
@@ -105,6 +126,10 @@ def fuzzer_number_power2
105
126
block_given? ? res . each { |n | yield ( n ) } : res
106
127
end
107
128
129
+ # Powers of two by some fuzzing factor.
130
+ #
131
+ # @returns [Array] Returns and array of integers.
132
+
108
133
def fuzzer_number_power2_plus
109
134
res = [ ]
110
135
fuzzer_number_power2 do |num |
@@ -119,6 +144,11 @@ def fuzzer_number_power2_plus
119
144
block_given? ? res . each { |n | yield ( n ) } : res
120
145
end
121
146
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
+
122
152
def fuzzer_gen_string ( len )
123
153
@gen_string_block ||= datastore [ 'FuzzChar' ] [ 0 , 1 ] * ( 1024 * 512 )
124
154
res = ''
@@ -128,6 +158,9 @@ def fuzzer_gen_string(len)
128
158
res [ 0 , len ]
129
159
end
130
160
161
+ # Creates a smaller fuzz string starting from length 16 -> 512 bytes long
162
+ #
163
+ # @return [Array] Returns an array of characters
131
164
def fuzzer_string_small
132
165
res = [ ]
133
166
16 . step ( 512 , 16 ) do |len |
@@ -137,6 +170,9 @@ def fuzzer_string_small
137
170
res
138
171
end
139
172
173
+ # Creates a longer fuzz string from length 64 -> 8192 bytes long
174
+ #
175
+ # @return [Array] Returns an array of characters
140
176
def fuzzer_string_long
141
177
res = [ ]
142
178
64 . step ( 8192 , 64 ) do |len |
@@ -147,6 +183,9 @@ def fuzzer_string_long
147
183
res
148
184
end
149
185
186
+ # Creates a giant fuzz string from length 512 -> 131,064 bytes long
187
+ #
188
+ # @return [Array] Returns an array of characters
150
189
def fuzzer_string_giant
151
190
res = [ ]
152
191
512 . step ( 65532 * 2 , 512 ) do |len |
@@ -157,6 +196,9 @@ def fuzzer_string_giant
157
196
res
158
197
end
159
198
199
+ # Various URI types
200
+ #
201
+ # @returns [Array] Returns an array of strings
160
202
def fuzzer_string_uri_types
161
203
res = %W{
162
204
aaa aaas about acap adiumxtra afp aim apt aw bolo callto cap chrome cid
@@ -174,16 +216,28 @@ def fuzzer_string_uri_types
174
216
block_given? ? res . each { |n | yield ( n ) } : res
175
217
end
176
218
219
+ # Generator for common URI dividers
220
+ #
221
+ # @return [Array] Returns an array of strings
222
+
177
223
def fuzzer_string_uri_dividers
178
224
res = %W{ : :// }
179
225
block_given? ? res . each { |n | yield ( n ) } : res
180
226
end
181
227
228
+ # Generator for common path prefixes
229
+ #
230
+ # @return [Array] Returns an array of strings
231
+
182
232
def fuzzer_string_path_prefixes
183
233
res = %W{ C:\\ \\ \\ localhost\\ / }
184
234
block_given? ? res . each { |n | yield ( n ) } : res
185
235
end
186
236
237
+ # Generates various small URI string types
238
+ #
239
+ # @return [Array] Returns an array of stings
240
+
187
241
def fuzzer_string_uris_small
188
242
res = [ ]
189
243
fuzzer_string_uri_types do |proto |
@@ -197,6 +251,10 @@ def fuzzer_string_uris_small
197
251
res
198
252
end
199
253
254
+ # Generates various long URI string types
255
+ #
256
+ # @return [Array] Returns an array of stings
257
+
200
258
def fuzzer_string_uris_long
201
259
res = [ ]
202
260
fuzzer_string_uri_types do |proto |
@@ -210,6 +268,10 @@ def fuzzer_string_uris_long
210
268
res
211
269
end
212
270
271
+ # Generates various giant URI string types
272
+ #
273
+ # @return [Array] Returns an array of stings
274
+
213
275
def fuzzer_string_uris_giant
214
276
res = [ ]
215
277
fuzzer_string_uri_types do |proto |
@@ -223,6 +285,10 @@ def fuzzer_string_uris_giant
223
285
res
224
286
end
225
287
288
+ # Format for the URI string generator
289
+ #
290
+ # @return [Array] Returns an array of stings
291
+
226
292
def fuzzer_string_uris_format
227
293
res = [ ]
228
294
fuzzer_string_uri_types do |proto |
@@ -236,6 +302,11 @@ def fuzzer_string_uris_format
236
302
res
237
303
end
238
304
305
+
306
+ # Generates various small strings
307
+ #
308
+ # @return [Array] Returns an array of stings
309
+
239
310
def fuzzer_string_uris_dos
240
311
res = [ ]
241
312
fuzzer_string_uri_types do |proto |
@@ -249,6 +320,11 @@ def fuzzer_string_uris_dos
249
320
res
250
321
end
251
322
323
+
324
+ # Generates various small strings
325
+ #
326
+ # @return [Array] Returns an array of stings
327
+
252
328
def fuzzer_string_paths_small
253
329
res = [ ]
254
330
fuzzer_string_path_prefixes do |pre |
@@ -260,6 +336,11 @@ def fuzzer_string_paths_small
260
336
res
261
337
end
262
338
339
+
340
+ # Generates various small strings
341
+ #
342
+ # @return [Array] Returns an array of stings
343
+
263
344
def fuzzer_string_paths_long
264
345
res = [ ]
265
346
fuzzer_string_path_prefixes do |pre |
@@ -271,6 +352,11 @@ def fuzzer_string_paths_long
271
352
res
272
353
end
273
354
355
+
356
+ # Generates various giant strings
357
+ #
358
+ # @return [Array] Returns an array of stings
359
+
274
360
def fuzzer_string_paths_giant
275
361
res = [ ]
276
362
fuzzer_string_path_prefixes do |pre |
@@ -282,6 +368,11 @@ def fuzzer_string_paths_giant
282
368
res
283
369
end
284
370
371
+
372
+ # Format for the path generator
373
+ #
374
+ # @return [Array] Returns an array of stings
375
+
285
376
def fuzzer_string_paths_format
286
377
res = [ ]
287
378
fuzzer_string_path_prefixes do |pre |
@@ -293,6 +384,11 @@ def fuzzer_string_paths_format
293
384
res
294
385
end
295
386
387
+
388
+ # Generates fuzzer strings using path prefixes
389
+ #
390
+ # @return [Array] Returns an array of stings
391
+
296
392
def fuzzer_string_paths_dos
297
393
res = [ ]
298
394
fuzzer_string_path_prefixes do |pre |
0 commit comments