@@ -13,7 +13,7 @@ def name
13
13
14
14
def commands
15
15
{
16
- 'request' => ' Make a request of the specified type' ,
16
+ 'request' => " Make a request of the specified type ( #{ types . join ( ', ' ) } )" ,
17
17
}
18
18
end
19
19
@@ -31,14 +31,17 @@ def cmd_request(*args)
31
31
return help if ( !type || type =~ /^-?-h(?:elp)?$/ )
32
32
type . downcase!
33
33
opts , opt_parser = parse_args ( type , args )
34
+
34
35
if opts && opt_parser
36
+ # handle any "global" options
35
37
if opts [ :output_file ]
36
38
begin
37
39
opts [ :output_file ] = File . new ( opts [ :output_file ] , 'w' )
38
40
rescue ::Errno ::EACCES , Errno ::EISDIR , Errno ::ENOTDIR
39
41
return help ( opt_parser , 'Failed to open the specified file for output' )
40
42
end
41
43
end
44
+ # hand off the actual request to the appropriate request handler
42
45
handler_method = "handle_request_#{ type } " . to_sym
43
46
if self . respond_to? ( handler_method )
44
47
# call the appropriate request handler
@@ -63,6 +66,7 @@ def parse_args(type, args)
63
66
end
64
67
end
65
68
69
+ # arg parsing for requests of type 'http'
66
70
def parse_args_http ( args = [ ] , type = 'http' )
67
71
opt_parser = Rex ::Parser ::Arguments . new (
68
72
'-0' => [ false , 'Use HTTP 1.0' ] ,
@@ -78,7 +82,9 @@ def parse_args_http(args = [], type = 'http')
78
82
'-I' => [ false , 'Show document info only' ] ,
79
83
'-o' => [ true , 'Write output to <file> instead of stdout' ] ,
80
84
'-u' => [ true , 'Server user and password' ] ,
81
- '-X' => [ true , 'Request method to use' ]
85
+ '-X' => [ true , 'Request method to use' ] ,
86
+ '-x' => [ true , 'Proxy to use, format: [proto://][user:pass@]host[:port]' +
87
+ ' Proto defaults to http:// and port to 1080' ] ,
82
88
)
83
89
84
90
options = {
@@ -126,6 +132,8 @@ def parse_args_http(args = [], type = 'http')
126
132
options [ :auth_password ] = val
127
133
when '-X'
128
134
options [ :method ] = val
135
+ #when '-x'
136
+ # @TODO proxy
129
137
else
130
138
options [ :uri ] = val
131
139
end
@@ -138,6 +146,7 @@ def parse_args_http(args = [], type = 'http')
138
146
[ options , opt_parser ]
139
147
end
140
148
149
+ # handling for requests of type 'http'
141
150
def handle_request_http ( opts , opt_parser )
142
151
uri = opts [ :uri ]
143
152
http_client = Rex ::Proto ::Http ::Client . new (
0 commit comments