- APP: yxcms
最后一波, go…
0x01 分析
分析了yxcms的model层后发现在底层实现了过滤,几乎所有的过滤都会走底层,那么如何实现过滤呢?
0x02 SQLi
第一处是我们的数字型注入,数字型注入无需引号。
位置于: apps/member/controller/photoController.php, 在r=member/photo/del调用的方法下,如果用post传如此部分代码:
首先$delid传入一个被implode成字符串的东西,implode方法传入的要是一个数组。而通过超全局变量传入程序的可以是字符串,数组,NULL三种, 这里我们可用通过dotype=del&delid[]=111&delid[]=222构造控制$delid变量,传入,单引号闭合。
经过photoModel直接来到model层的select 语句:
<phppublic function select($condition = '', $field = '', $order = '', $limit = ''){return $this->model->table($this->table, $this->ignoreTablePrefix)->field($field)->where($condition)->order($order)->limit($limit)->select();}$condition = 'id in ([可控])'$field = 'id,photolist,sort,extfield,account'
传入cpMysql解析查询条件:
$condition = WHERE id in ([可控])
最终落实在持久层的查询语句: SELECT id,photolist,sort,extfield,account FROM yx_photo WHERE id in (111) 因为这里是数字型内容,不用引号闭合,有没有检查和转化类型所以用户可以输入字符串又不需要引号闭合,构成了一处注入。
dotype=del&delid[]=1) and sleep(5)#
后边就可以盲注或显错了。
此处漏洞如何修补的呢:
intval,在开发的时候要特别注意拼接的整形参数,需要intval。至少还有一处:
<?phppublic function colchange(){if('change'!=$_POST['dotype']) $this->error('操作类型错误~',url('photo/index'));if(empty($_POST['delid'])||empty($_POST['col'])) $this->error('您没有选择~',url('photo/index'));foreach($_POST['delid'] as $value){$changeid .= intval($value).',';}$changeid = substr($changeid,0,-1);$data['sort']=$_POST['col'];model('photo')->update("id in ('".$changeid."') and account='".$this->mesprefix.$this->auth['account']."'",$data);$this->success('栏目移动成功~',url('photo/index'));}
(也已经修复)
