Updates to the client API

git-svn-id: file:///home/svn/framework3/trunk@4242 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2006-12-28 23:42:54 +00:00
parent b221af7791
commit 2bc1d4be18
3 changed files with 11 additions and 9 deletions

View File

@ -70,7 +70,7 @@ module Exploit::Remote::HttpClient
# Configure the HTTP client with the supplied parameter
nclient.set_config(
'vhost' => datastore['VHOST'],
'vhost' => self.vhost(),
'uri_encode_mode' => datastore['HTTP::uri_encode'],
'agent' => datastore['UserAgent']
)

View File

@ -47,8 +47,9 @@ class Client
def request_raw(opts={})
c_enc = opts['encode'] || false
c_uri = opts['uri'] || '/'
c_body = opts['body'] || ''
c_body = opts['data'] || ''
c_meth = opts['method'] || 'GET'
c_prot = opts['proto'] || 'HTTP'
c_vers = opts['version'] || config['version'] || '1.1'
c_qs = opts['query']
c_ag = opts['agent'] || config['agent']
@ -71,7 +72,7 @@ class Client
req += set_uri_append()
req += set_uri_version_spacer()
req += set_version(c_vers)
req += set_version(c_prot, c_vers)
req += set_host_header(c_host)
req += set_agent_header(c_ag)
req += set_cookie_header(c_cook)
@ -88,9 +89,10 @@ class Client
#
def request_cgi(opts={})
c_enc = opts['encode'] || false
c_cgi = opts['cgi'] || '/'
c_body = opts['body'] || ''
c_cgi = opts['uri'] || '/'
c_body = opts['data'] || ''
c_meth = opts['method'] || 'GET'
c_prot = opts['proto'] || 'HTTP'
c_vers = opts['version'] || config['version'] || '1.1'
c_qs = opts['query'] || ''
c_varg = opts['vars_get'] || {}
@ -134,7 +136,7 @@ class Client
req += set_path_info(c_path)
req += set_uri_append()
req += set_uri_version_spacer()
req += set_version(c_vers)
req += set_version(c_prot, c_vers)
req += set_host_header(c_host)
req += set_agent_header(c_ag)
req += set_cookie_header(c_cook)
@ -378,12 +380,12 @@ class Client
#
# Return the HTTP version string
#
def set_version(version)
def set_version(protocol, version)
# TODO:
# * Randomize case
# * Replace with random valid versions
# * Replace with random invalid versions
"HTTP/" + version + "\r\n"
protocol + "/" + version + "\r\n"
end
#

View File

@ -62,7 +62,7 @@ class Rex::Proto::Http::Client::UnitTest < Test::Unit::TestCase
r = c.request_cgi(
'method' => 'POST',
'cgi' => '/',
'uri' => '/',
'vars_post' => { 'var' => 'val' },
'ctype' => 'application/x-www-form-urlencoded'
)