@@ -32,7 +32,7 @@ def parse_args(args)
32
32
'-i' => [ false , 'Include headers in the output' ] ,
33
33
'-I' => [ false , 'Show document info only' ] ,
34
34
'-o' => [ true , 'Write output to <file> instead of stdout' ] ,
35
- '-u' => [ true , 'Server user and password' , ] ,
35
+ '-u' => [ true , 'Server user and password' ] ,
36
36
'-X' => [ true , 'Request method to use' ]
37
37
)
38
38
@@ -140,6 +140,14 @@ def cmd_http_request(*args)
140
140
opts [ :ssl_version ]
141
141
)
142
142
143
+ unless opts [ :auth_username ] . nil?
144
+ auth_str = opts [ :auth_username ] . to_s + ':' + opts [ :auth_password ] . to_s
145
+ auth_str = 'Basic ' + Rex ::Text . encode_base64 ( auth_str )
146
+ opts [ :headers ] [ 'Authorization' ] = auth_str
147
+ end
148
+
149
+ uri . path = '/' if uri . path . length == 0
150
+
143
151
begin
144
152
http_client . connect
145
153
request = http_client . request_cgi (
@@ -161,8 +169,8 @@ def cmd_http_request(*args)
161
169
print_error ( 'The connection was reset by the peer' )
162
170
rescue ::EOFError , Errno ::ETIMEDOUT , Rex ::ConnectionError , ::Timeout ::Error
163
171
print_error ( 'Encountered an error' )
164
- rescue ::Exception => ex
165
- print_line ( "An error of type #{ ex . class } happened, message is #{ ex . message } " )
172
+ # rescue ::Exception => ex
173
+ # print_line("An error of type #{ex.class} happened, message is #{ex.message}")
166
174
ensure
167
175
http_client . close
168
176
end
@@ -193,7 +201,7 @@ def name
193
201
end
194
202
195
203
def desc
196
- 'Make Requests '
204
+ 'Make HTTP requests from within Metasploit. '
197
205
end
198
206
199
207
protected
0 commit comments