@@ -195,7 +195,8 @@ def request_raw(opts={})
195
195
# - cookie: Cookie header value
196
196
# - ctype: Content-Type header value, default: +application/x-www-form-urlencoded+
197
197
# - data: HTTP data (only useful with some methods, see rfc2616)
198
- # - encode: URI encode the supplied URI
198
+ # - encode: URI encode the supplied URI, default: false
199
+ # - encode_params: URI encode the GET or POST variables (names and values), default: true
199
200
# - headers: HTTP headers as a hash, e.g. <code>{ "X-MyHeader" => "value" }</code>
200
201
# - method: HTTP method to use in the request, not limited to standard methods defined by rfc2616, default: GET
201
202
# - proto: protocol, default: HTTP
@@ -208,28 +209,28 @@ def request_raw(opts={})
208
209
# - vhost: Host header value
209
210
#
210
211
def request_cgi ( opts = { } )
211
- c_enc = opts [ 'encode' ] || false
212
- c_cgi = opts [ 'uri ' ] || '/'
213
- c_body = opts [ 'data ' ] || ''
214
- c_meth = opts [ 'method ' ] || 'GET '
215
- c_prot = opts [ 'proto ' ] || 'HTTP '
216
- c_vers = opts [ 'version ' ] || config [ 'version' ] || '1.1 '
217
- c_qs = opts [ 'query ' ] || ''
218
- c_varg = opts [ 'vars_get ' ] || { }
219
- c_varp = opts [ 'vars_post' ] || { }
220
- c_head = opts [ 'headers ' ] || config [ 'headers' ] || { }
221
- c_rawh = opts [ 'raw_headers' ] || config [ 'raw_headers ' ] || ''
222
- c_type = opts [ 'ctype ' ] || 'application/x-www-form-urlencoded '
223
- c_ag = opts [ 'agent ' ] || config [ 'agent' ]
224
- c_cook = opts [ 'cookie ' ] || config [ 'cookie ' ]
225
- c_host = opts [ 'vhost ' ] || config [ 'vhost ' ]
226
- c_conn = opts [ 'connection ' ]
227
- c_path = opts [ 'path_info ' ]
228
- c_auth = opts [ 'basic_auth' ] || config [ 'basic_auth' ] || ''
229
-
230
- uri = set_cgi ( c_cgi )
231
- qstr = c_qs
232
- pstr = c_body
212
+ c_enc = opts [ 'encode' ] || false
213
+ c_enc_p = ( opts [ 'encode_params ' ] == true or opts [ 'encode_params' ] . nil? ? true : false )
214
+ c_cgi = opts [ 'uri ' ] || '/ '
215
+ c_body = opts [ 'data ' ] || ''
216
+ c_meth = opts [ 'method ' ] || 'GET '
217
+ c_prot = opts [ 'proto ' ] || 'HTTP '
218
+ c_vers = opts [ 'version ' ] || config [ 'version' ] || '1.1 '
219
+ c_qs = opts [ 'query ' ] || ''
220
+ c_varg = opts [ 'vars_get' ] || { }
221
+ c_varp = opts [ 'vars_post ' ] || { }
222
+ c_head = opts [ 'headers' ] || config [ 'headers ' ] || { }
223
+ c_rawh = opts [ 'raw_headers ' ] || config [ 'raw_headers' ] || ''
224
+ c_type = opts [ 'ctype ' ] || 'application/x-www-form-urlencoded'
225
+ c_ag = opts [ 'agent ' ] || config [ 'agent ' ]
226
+ c_cook = opts [ 'cookie ' ] || config [ 'cookie ' ]
227
+ c_host = opts [ 'vhost' ] || config [ 'vhost ']
228
+ c_conn = opts [ 'connection ' ]
229
+ c_path = opts [ 'path_info' ]
230
+ c_auth = opts [ 'basic_auth' ] || config [ 'basic_auth' ] || ''
231
+ uri = set_cgi ( c_cgi )
232
+ qstr = c_qs
233
+ pstr = c_body
233
234
234
235
if ( config [ 'pad_get_params' ] )
235
236
1 . upto ( config [ 'pad_get_params_count' ] . to_i ) do |i |
@@ -242,25 +243,27 @@ def request_cgi(opts={})
242
243
243
244
c_varg . each_pair do |var , val |
244
245
qstr << '&' if qstr . length > 0
245
- qstr << set_encode_uri ( var )
246
+ qstr << ( c_enc_p ? set_encode_uri ( var ) : var )
246
247
qstr << '='
247
- qstr << set_encode_uri ( val )
248
+ qstr << ( c_enc_p ? set_encode_uri ( val ) : val )
248
249
end
249
250
250
251
if ( config [ 'pad_post_params' ] )
251
252
1 . upto ( config [ 'pad_post_params_count' ] . to_i ) do |i |
253
+ rand_var = Rex ::Text . rand_text_alphanumeric ( rand ( 32 ) +1 )
254
+ rand_val = Rex ::Text . rand_text_alphanumeric ( rand ( 32 ) +1 )
252
255
pstr << '&' if pstr . length > 0
253
- pstr << set_encode_uri ( Rex :: Text . rand_text_alphanumeric ( rand ( 32 ) + 1 ) )
256
+ pstr << ( c_enc_p ? set_encode_uri ( rand_var ) : rand_var )
254
257
pstr << '='
255
- pstr << set_encode_uri ( Rex :: Text . rand_text_alphanumeric ( rand ( 32 ) + 1 ) )
258
+ pstr << ( c_enc_p ? set_encode_uri ( rand_val ) : rand_val )
256
259
end
257
260
end
258
261
259
262
c_varp . each_pair do |var , val |
260
263
pstr << '&' if pstr . length > 0
261
- pstr << set_encode_uri ( var )
264
+ pstr << ( c_enc_p ? set_encode_uri ( var ) : var )
262
265
pstr << '='
263
- pstr << set_encode_uri ( val )
266
+ pstr << ( c_enc_p ? set_encode_uri ( val ) : val )
264
267
end
265
268
266
269
req = ''
@@ -294,6 +297,7 @@ def request_cgi(opts={})
294
297
req << set_chunked_header ( )
295
298
req << set_raw_headers ( c_rawh )
296
299
req << set_body ( pstr )
300
+
297
301
req
298
302
end
299
303
0 commit comments