Skip to content

Commit adc9532

Browse files
author
HD Moore
committed
Reset this back to master's copy, fixes this pull
1 parent 43fe219 commit adc9532

File tree

1 file changed

+33
-29
lines changed

1 file changed

+33
-29
lines changed

lib/rex/proto/http/client.rb

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ def request_raw(opts={})
195195
# - cookie: Cookie header value
196196
# - ctype: Content-Type header value, default: +application/x-www-form-urlencoded+
197197
# - 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
199200
# - headers: HTTP headers as a hash, e.g. <code>{ "X-MyHeader" => "value" }</code>
200201
# - method: HTTP method to use in the request, not limited to standard methods defined by rfc2616, default: GET
201202
# - proto: protocol, default: HTTP
@@ -208,28 +209,28 @@ def request_raw(opts={})
208209
# - vhost: Host header value
209210
#
210211
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
233234

234235
if (config['pad_get_params'])
235236
1.upto(config['pad_get_params_count'].to_i) do |i|
@@ -242,25 +243,27 @@ def request_cgi(opts={})
242243

243244
c_varg.each_pair do |var,val|
244245
qstr << '&' if qstr.length > 0
245-
qstr << set_encode_uri(var)
246+
qstr << (c_enc_p ? set_encode_uri(var) : var)
246247
qstr << '='
247-
qstr << set_encode_uri(val)
248+
qstr << (c_enc_p ? set_encode_uri(val) : val)
248249
end
249250

250251
if (config['pad_post_params'])
251252
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)
252255
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)
254257
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)
256259
end
257260
end
258261

259262
c_varp.each_pair do |var,val|
260263
pstr << '&' if pstr.length > 0
261-
pstr << set_encode_uri(var)
264+
pstr << (c_enc_p ? set_encode_uri(var) : var)
262265
pstr << '='
263-
pstr << set_encode_uri(val)
266+
pstr << (c_enc_p ? set_encode_uri(val) : val)
264267
end
265268

266269
req = ''
@@ -294,6 +297,7 @@ def request_cgi(opts={})
294297
req << set_chunked_header()
295298
req << set_raw_headers(c_rawh)
296299
req << set_body(pstr)
300+
297301
req
298302
end
299303

0 commit comments

Comments
 (0)